Class DGKPublicKey

java.lang.Object
edu.fiu.adwise.homomorphic_encryption.dgk.DGKPublicKey
All Implemented Interfaces:
DGK_Key, CipherConstants, Serializable, Runnable, Key, PublicKey

public final class DGKPublicKey extends Object implements Serializable, DGK_Key, PublicKey, Runnable, CipherConstants
Represents the public key for the DGK (Damgård-Geisler-Krøigaard) cryptosystem. This class implements the Serializable, DGK_Key, PublicKey, Runnable, and CipherConstants interfaces. It provides methods for key generation, serialization, and lookup table generation for encryption operations.
See Also:
  • Field Details

    • ONE

      public BigInteger ONE
      The encrypted representation of the value 1.
    • ZERO

      public BigInteger ZERO
      The encrypted representation of the value 0.
  • Constructor Details

    • DGKPublicKey

      public DGKPublicKey(BigInteger n, BigInteger g, BigInteger h, BigInteger u, int l, int t, int k)
      Constructs a DGKPublicKey with all required parameters.
      Parameters:
      n - The modulus.
      g - The generator.
      h - The secondary generator.
      u - The order of the subgroup.
      l - The bit length of plaintext.
      t - The security parameter.
      k - The key size.
  • Method Details

    • writeKey

      public void writeKey(String dgk_public_key_file) throws IOException
      Serializes the public key to a file.
      Parameters:
      dgk_public_key_file - The file path to save the public key.
      Throws:
      IOException - If an I/O error occurs.
    • readKey

      public static DGKPublicKey readKey(String dgk_public_key) throws IOException, ClassNotFoundException
      Deserializes a DGKPublicKey from a file.
      Parameters:
      dgk_public_key - The file path to read the public key from.
      Returns:
      The deserialized DGKPublicKey.
      Throws:
      IOException - If an I/O error occurs.
      ClassNotFoundException - If the class cannot be found.
    • ZERO

      public BigInteger ZERO() throws HomomorphicException
      Returns:
      The encrypted representation of 0.
      Throws:
      HomomorphicException - - If an invalid input was found, this should be impossible in this case
    • getAlgorithm

      public String getAlgorithm()
      Specified by:
      getAlgorithm in interface Key
      Returns:
      The algorithm name ("DGK").
    • toString

      public String toString()
      Overrides:
      toString in class Object
      Returns:
      A string representation of the DGK public key.
    • getFormat

      public String getFormat()
      Specified by:
      getFormat in interface Key
      Returns:
      The format of the key ("X.509").
    • getEncoded

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

      public void run()
      Generates the lookup tables for g and h.
      Specified by:
      run in interface Runnable
    • getu

      public long getu()
      Returns:
      The order of the subgroup as a long.
    • getU

      public BigInteger getU()
      Description copied from interface: DGK_Key
      Retrieves the value of \( u \), a parameter associated with the DGK key.
      Specified by:
      getU in interface DGK_Key
      Returns:
      The order of the subgroup as a BigInteger.
    • getN

      public BigInteger getN()
      Description copied from interface: DGK_Key
      Retrieves the modulus \( n \) associated with the DGK key.
      Specified by:
      getN in interface DGK_Key
      Returns:
      The modulus n.
    • getL

      public int getL()
      Description copied from interface: DGK_Key
      Retrieves the bit length \( l \) of the DGK key.
      Specified by:
      getL in interface DGK_Key
      Returns:
      The bit length of plaintext.
    • getT

      public int getT()
      Returns:
      The security parameter.
    • equals

      public boolean equals(Object o)
      Compares this DGKPublicKey with another object for equality.
      Overrides:
      equals in class Object
      Parameters:
      o - The object to compare with.
      Returns:
      True if the objects are equal, false otherwise.