Class ElGamalKeyPairGenerator

java.lang.Object
java.security.KeyPairGeneratorSpi
edu.fiu.adwise.homomorphic_encryption.elgamal.ElGamalKeyPairGenerator
All Implemented Interfaces:
CipherConstants

public class ElGamalKeyPairGenerator extends KeyPairGeneratorSpi implements CipherConstants
This class is responsible for generating ElGamal key pairs. It supports both additive and multiplicative modes of the ElGamal cryptosystem.
  • Constructor Details

    • ElGamalKeyPairGenerator

      public ElGamalKeyPairGenerator(boolean additive)
      Constructs an ElGamalKeyPairGenerator.
      Parameters:
      additive - Specifies whether the key pair supports additive operations.
  • Method Details

    • initialize

      public void initialize(int key_size, SecureRandom random)
      Initializes the key pair generator with the specified key size and random number generator.
      Specified by:
      initialize in class KeyPairGeneratorSpi
      Parameters:
      key_size - The size of the key to generate (in bits).
      random - The secure random number generator to use.
      Throws:
      IllegalArgumentException - If the key size is less than half of the default key size.
    • generateKeyPair

      public KeyPair generateKeyPair()
      Generates an ElGamal key pair.
      Specified by:
      generateKeyPair in class KeyPairGeneratorSpi
      Returns:
      A KeyPair containing the public and private keys.
    • getPrime

      public static BigInteger getPrime(int nb_bits, Random prg)
      Return a prime p = 2 * p' + 1
      Parameters:
      nb_bits - is the prime representation
      prg - random
      Returns:
      p