Class DiffieHellman
java.lang.Object
com.helixframework.crypto.diffiehellman.DiffieHellman
Utility methods for Diffie-Hellman key exchange.
-
Method Summary
Modifier and TypeMethodDescriptionstatic PublicKeydecode(byte[] encodedKey) Decodes a byte array into a public key.static byte[]Encodes a public key into a byte array.static KeyPairGenerates a key pair for Diffie-Hellman key exchange.static byte[]generateSecret(PrivateKey privateKey, PublicKey publicKey) Generates a shared secret key using Diffie-Hellman key exchange.
-
Method Details
-
generateKeyPair
Generates a key pair for Diffie-Hellman key exchange.- Returns:
- the generated key pair
- Throws:
RuntimeException- if an error occurs during key generation
-
generateSecret
Generates a shared secret key using Diffie-Hellman key exchange.- Parameters:
privateKey- the private key to be used for key generation (your private key)publicKey- the public key to be used for key generation (their public key)- Returns:
- the generated shared secret key as a byte array
- Throws:
RuntimeException- if an error occurs during key generation
-
encode
Encodes a public key into a byte array.- Parameters:
publicKey- the public key to be encoded- Returns:
- the encoded public key as a byte array
-
decode
Decodes a byte array into a public key.- Parameters:
encodedKey- the encoded public key as a byte array- Returns:
- the decoded public key
- Throws:
RuntimeException- if an error occurs during decoding
-