Class ElgamalKeyGenSpec

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

public final class ElgamalKeyGenSpec extends Object implements AlgorithmKeySpec, Describable

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

  • keySize must be at least 1024 bits.
  • certainty must 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 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 - if keySize < 1024 or certainty < 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

      public static ElgamalKeyGenSpec elgamal2048()
      Returns a default ElGamal spec with a 2048-bit modulus and 128 iterations for primality testing.
      Returns:
      default ElGamal key generation specification
    • description

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

      Example: "p=2048, certainty=128".

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