Class ElGamalKeyPairGenerator
java.lang.Object
java.security.KeyPairGeneratorSpi
edu.fiu.adwise.homomorphic_encryption.elgamal.ElGamalKeyPairGenerator
- All Implemented Interfaces:
CipherConstants
This class is responsible for generating ElGamal key pairs.
It supports both additive and multiplicative modes of the ElGamal cryptosystem.
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionElGamalKeyPairGenerator(boolean additive) Constructs an ElGamalKeyPairGenerator. -
Method Summary
Modifier and TypeMethodDescriptionGenerates an ElGamal key pair.static BigIntegerReturn a prime p = 2 * p' + 1voidinitialize(int key_size, SecureRandom random) Initializes the key pair generator with the specified key size and random number generator.Methods inherited from class java.security.KeyPairGeneratorSpi
initialize
-
Constructor Details
-
ElGamalKeyPairGenerator
public ElGamalKeyPairGenerator(boolean additive) Constructs an ElGamalKeyPairGenerator.- Parameters:
additive- Specifies whether the key pair supports additive operations.
-
-
Method Details
-
initialize
Initializes the key pair generator with the specified key size and random number generator.- Specified by:
initializein classKeyPairGeneratorSpi- 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
Generates an ElGamal key pair.- Specified by:
generateKeyPairin classKeyPairGeneratorSpi- Returns:
- A
KeyPaircontaining the public and private keys.
-
getPrime
Return a prime p = 2 * p' + 1- Parameters:
nb_bits- is the prime representationprg- random- Returns:
- p
-