Class DGKPrivateKey

java.lang.Object
edu.fiu.adwise.homomorphic_encryption.dgk.DGKPrivateKey
All Implemented Interfaces:
DGK_Key, Serializable, Key, PrivateKey, Destroyable

public final class DGKPrivateKey extends Object implements Serializable, DGK_Key, PrivateKey
Represents a DGK (Damgård-Geisler-Krøigaard) private key used for homomorphic encryption. This class implements the Serializable, DGK_Key, and PrivateKey interfaces. It contains both private and public key parameters, as well as methods for key serialization, deserialization, and lookup table generation.
See Also:
  • Field Details

    • v

      public final BigInteger v
      The product of \( vp \) and \( vq \), used for decryption.
  • Constructor Details

    • DGKPrivateKey

      public DGKPrivateKey(BigInteger p, BigInteger q, BigInteger vp, BigInteger vq, DGKPublicKey pubKey)
      Constructs a DGKPrivateKey using the provided private key parameters and public key.
      Parameters:
      p - First prime factor of n
      q - Second prime factor of n
      vp - Precomputed value for decryption
      vq - Precomputed value for decryption
      pubKey - Corresponding DGK public key
  • Method Details

    • writeKey

      public void writeKey(String dgk_private_key_file) throws IOException
      Serializes the private key to a file.
      Parameters:
      dgk_private_key_file - Path to the file where the private key will be saved
      Throws:
      IOException - If an I/O error occurs during serialization
    • readKey

      public static DGKPrivateKey readKey(String dgk_private_key) throws IOException, ClassNotFoundException
      Deserializes a DGK private key from a file.
      Parameters:
      dgk_private_key - Path to the file containing the serialized private key
      Returns:
      The deserialized DGKPrivateKey object
      Throws:
      IOException - If an I/O error occurs during deserialization
      ClassNotFoundException - If the class of the serialized object cannot be found
    • toString

      public String toString()
      Returns a string representation of the public key parameters. Private key parameters are excluded for security reasons.
      Overrides:
      toString in class Object
      Returns:
      A string representation of the public key parameters
    • getU

      public BigInteger getU()
      Returns the upper bound for plaintext values.
      Specified by:
      getU in interface DGK_Key
      Returns:
      The upper bound for plaintext values
    • getN

      public BigInteger getN()
      Returns the modulus of the key.
      Specified by:
      getN in interface DGK_Key
      Returns:
      The modulus of the key
    • getL

      public int getL()
      Returns the bit length of plaintext values.
      Specified by:
      getL in interface DGK_Key
      Returns:
      The bit length of plaintext values
    • getAlgorithm

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

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

      public byte[] getEncoded()
      Returns the encoded form of the key. This implementation returns null as encoding is not supported.
      Specified by:
      getEncoded in interface Key
      Returns:
      null
    • equals

      public boolean equals(Object o)
      Compares this DGKPrivateKey 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