Class ElGamalPrivateKey

java.lang.Object
edu.fiu.adwise.homomorphic_encryption.elgamal.ElGamalPrivateKey
All Implemented Interfaces:
ElGamal_Key, CipherConstants, Serializable, Runnable, Key, PrivateKey, Destroyable

public final class ElGamalPrivateKey extends Object implements ElGamal_Key, Serializable, PrivateKey, Runnable, CipherConstants
Represents the private key for the ElGamal encryption scheme. This class implements multiple interfaces to provide functionality for cryptographic operations, serialization, and multithreading.

The ElGamalPrivateKey class includes parameters for the private key, as well as the public key components (p, g, h). It also supports additive homomorphic encryption by generating a lookup table for decryption.

See Also:
  • Constructor Details

    • ElGamalPrivateKey

      public ElGamalPrivateKey(BigInteger p, BigInteger x, BigInteger g, BigInteger h, boolean additive)
      Constructs an ElGamalPrivateKey with the specified parameters.
      Parameters:
      p - The prime modulus.
      x - The private key parameter.
      g - The generator.
      h - The public key component.
      additive - Whether additive homomorphic encryption is enabled.
  • Method Details

    • set_additive

      public void set_additive(boolean additive)
      Sets whether additive homomorphic encryption is enabled.
      Specified by:
      set_additive in interface ElGamal_Key
      Parameters:
      additive - True to enable additive homomorphic encryption, false otherwise.
    • getAlgorithm

      public String getAlgorithm()
      Returns the algorithm name.
      Specified by:
      getAlgorithm in interface Key
      Returns:
      The algorithm name, "ElGamal".
    • getFormat

      public String getFormat()
      Returns the format of the key.
      Specified by:
      getFormat in interface Key
      Returns:
      The format, "PKCS#8".
    • getEncoded

      public byte[] getEncoded()
      Returns the encoded form of the key.
      Specified by:
      getEncoded in interface Key
      Returns:
      The encoded key, or null if not supported.
    • run

      public void run()
      Runs the decryption table generation in a separate thread.
      Specified by:
      run in interface Runnable
    • toString

      public String toString()
      Returns a string representation of the private key.
      Overrides:
      toString in class Object
      Returns:
      A string containing the key parameters.
    • getP

      public BigInteger getP()
      Returns the prime modulus p.
      Specified by:
      getP in interface ElGamal_Key
      Returns:
      The prime modulus p.