Package zeroecho.core.alg.elgamal
Class ElgamalKeyGenSpec
java.lang.Object
zeroecho.core.alg.elgamal.ElgamalKeyGenSpec
- All Implemented Interfaces:
Describable,AlgorithmKeySpec
ElGamal Key Generation Specification
Parameters controlling ElGamal key pair generation. This specification provides the modulus size and the certainty parameter for primality testing.
When generating a new ElGamal key pair, the modulus p must be chosen
as a large safe prime. The keySize determines the bit length of
p, and certainty controls the statistical strength of
Miller–Rabin primality checks.
Validation rules
keySizemust be at least 1024 bits.certaintymust be at least 64, which ensures negligible error probability in primality testing.
Factory
elgamal2048()returns a commonly used default spec with a 2048-bit modulus and 128 Miller–Rabin iterations.
Usage
ElgamalKeyGenSpec spec = ElgamalKeyGenSpec.elgamal2048();
KeyPair kp = algo.generateKeyPair(spec);
Thread-safety
Instances are immutable and can be freely shared between threads.- Since:
- 1.0
-
Constructor Summary
ConstructorsConstructorDescriptionElgamalKeyGenSpec(int keySize, int certainty) Constructs a new ElGamal key generation spec. -
Method Summary
Modifier and TypeMethodDescriptionintReturns the Miller–Rabin certainty parameter.Human-readable description of this spec.static ElgamalKeyGenSpecReturns a default ElGamal spec with a 2048-bit modulus and 128 iterations for primality testing.intkeySize()Returns the modulus size in bits.
-
Constructor Details
-
ElgamalKeyGenSpec
public ElgamalKeyGenSpec(int keySize, int certainty) Constructs a new ElGamal key generation spec.- Parameters:
keySize- desired modulus size in bits (minimum 1024)certainty- number of Miller–Rabin iterations for primality testing (minimum 64)- Throws:
IllegalArgumentException- ifkeySize< 1024 orcertainty< 64
-
-
Method Details
-
keySize
public int keySize()Returns the modulus size in bits.- Returns:
- number of bits for the prime modulus p
-
certainty
public int certainty()Returns the Miller–Rabin certainty parameter.- Returns:
- number of iterations used in primality testing
-
elgamal2048
Returns a default ElGamal spec with a 2048-bit modulus and 128 iterations for primality testing.- Returns:
- default ElGamal key generation specification
-
description
Human-readable description of this spec.Example:
"p=2048, certainty=128".- Specified by:
descriptionin interfaceDescribable- Returns:
- descriptive string including modulus size and certainty
-