Class DiffieHellman

java.lang.Object
com.helixframework.crypto.diffiehellman.DiffieHellman

public final class DiffieHellman extends Object
Utility methods for Diffie-Hellman key exchange.
  • Method Details

    • generateKeyPair

      public static KeyPair 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

      public static byte[] generateSecret(PrivateKey privateKey, PublicKey publicKey)
      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

      public static byte[] encode(PublicKey publicKey)
      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

      public static PublicKey decode(byte[] encodedKey)
      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