Class ElgamalParamSpec

java.lang.Object
zeroecho.core.alg.elgamal.ElgamalParamSpec
All Implemented Interfaces:
Describable, AlgorithmKeySpec

public final class ElgamalParamSpec extends Object implements AlgorithmKeySpec, Describable

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 BouncyCastle ElGamalParameterSpec object.
  • keySize() reports the bit length of the modulus p.

Predefined parameters

  • ffdhe2048() returns the 2048-bit safe prime from RFC 7919 (FFDHE2048), with generator g = 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 Details

    • ElgamalParamSpec

      public ElgamalParamSpec(BigInteger p, BigInteger g)
      Creates a new ElGamal parameter spec with modulus and generator.
      Parameters:
      p - safe prime modulus (must not be null)
      g - generator of the subgroup (must not be null)
      Throws:
      NullPointerException - if either argument is null
  • Method Details

    • parameters

      public org.bouncycastle.jce.spec.ElGamalParameterSpec parameters()
      Returns the underlying ElGamal parameters.
      Returns:
      ElGamalParameterSpec wrapping (p, g)
    • keySize

      public int keySize()
      Returns the modulus size in bits.
      Returns:
      number of bits of p
    • ffdhe2048

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

      public String description()
      Human-readable description of this spec.

      Example: "predefined(p=2048, g=2)".

      Specified by:
      description in interface Describable
      Returns:
      descriptive string including modulus size and generator