Class ElgamalParamSpec
java.lang.Object
zeroecho.core.alg.elgamal.ElgamalParamSpec
- All Implemented Interfaces:
Describable, AlgorithmKeySpec
ElGamal Parameter Specification
Wrapper for ElGamal domain parameters(p, g). Unlike
ElgamalKeyGenSpec, which requests new random primes,
ElgamalParamSpec directly encapsulates an explicit safe prime modulus
and generator.
An ElGamalParameterSpec instance defines the cyclic subgroup of
integers modulo p, generated by g, in which all ElGamal
operations occur. The modulus p should be a large safe prime to
resist discrete logarithm attacks.
Contents
parameters()exposes the wrapped BouncyCastleElGamalParameterSpecobject.keySize()reports the bit length of the modulusp.
Predefined parameters
ffdhe2048()returns the 2048-bit safe prime from RFC 7919 (FFDHE2048), with generatorg = 2. This provides a widely accepted interoperable parameter set.
Usage
ElgamalParamSpec spec = ElgamalParamSpec.ffdhe2048();
KeyPair kp = algo.asymmetricKeyPairGenerator(ElgamalParamSpec.class).generateKeyPair(spec);
Thread-safety
Instances are immutable and safe to share between threads.- Since:
- 1.0
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new ElGamal parameter spec with modulus and generator. -
Method Summary
Modifier and TypeMethodDescriptionHuman-readable description of this spec.static ElgamalParamSpecReturns the RFC 7919 FFDHE2048 safe prime with generator 2.intkeySize()Returns the modulus size in bits.org.bouncycastle.jce.spec.ElGamalParameterSpecReturns the underlying ElGamal parameters.
-
Constructor Details
-
ElgamalParamSpec
Creates a new ElGamal parameter spec with modulus and generator.- Parameters:
p- safe prime modulus (must not benull)g- generator of the subgroup (must not benull)- Throws:
NullPointerException- if either argument isnull
-
-
Method Details
-
parameters
public org.bouncycastle.jce.spec.ElGamalParameterSpec parameters()Returns the underlying ElGamal parameters.- Returns:
ElGamalParameterSpecwrapping(p, g)
-
keySize
public int keySize()Returns the modulus size in bits.- Returns:
- number of bits of
p
-
ffdhe2048
Returns the RFC 7919 FFDHE2048 safe prime with generator 2.This parameter set is standardized and widely supported for Diffie–Hellman and ElGamal constructions.
- Returns:
- predefined ElGamal parameter spec (2048-bit, g=2)
-
description
Human-readable description of this spec.Example:
"predefined(p=2048, g=2)".- Specified by:
descriptionin interfaceDescribable- Returns:
- descriptive string including modulus size and generator
-