Class PaillierPublicKey
java.lang.Object
edu.fiu.adwise.homomorphic_encryption.paillier.PaillierPublicKey
- All Implemented Interfaces:
PaillierKey,Serializable,Key,PublicKey
Represents the public key for the Paillier cryptosystem.
This class implements the Serializable, Paillier_Key, PublicKey, Runnable, and CipherConstants interfaces.
It provides methods for key generation and serialization for encryption operations.
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionPaillierPublicKey(int key_size, BigInteger n, BigInteger modulus, BigInteger g) Constructs a Paillier public key with the specified parameters. -
Method Summary
Modifier and TypeMethodDescriptionbooleanCompares this public key with another object for equality.Returns the algorithm name for this key.byte[]Returns the encoded form of the key.Returns the format of the key encoding.Retrieves the modulus used in the Paillier cryptosystem.getN()Retrieves the value of n, which is part of the Paillier key.static PaillierPublicKeyReads a public key from a file.toString()Returns a string representation of the public key.voidWrites the public key to a file.ZERO()Retrieves the encryption of zero using this public key.
-
Field Details
-
key_size
public final int key_sizeThe size of the key in bits.
-
-
Constructor Details
-
PaillierPublicKey
Constructs a Paillier public key with the specified parameters.- Parameters:
key_size- The size of the key in bits.n- The value of n (product of two primes p and q).modulus- The modulus (n^2).g- The generator g.
-
-
Method Details
-
ZERO
Retrieves the encryption of zero using this public key.- Returns:
- The encryption of zero as a
BigInteger. - Throws:
HomomorphicException- If an error occurs during encryption.
-
toString
Returns a string representation of the public key. -
writeKey
Writes the public key to a file.- Parameters:
paillier_public_key_file- The file path to save the public key.- Throws:
IOException- If an I/O error occurs.
-
readKey
public static PaillierPublicKey readKey(String paillier_public_key) throws IOException, ClassNotFoundException Reads a public key from a file.- Parameters:
paillier_public_key- The file path to read the public key from.- Returns:
- The
PaillierPublicKeyobject. - Throws:
IOException- If an I/O error occurs.ClassNotFoundException- If the class of the serialized object cannot be found.
-
getN
Retrieves the value of n, which is part of the Paillier key.- Specified by:
getNin interfacePaillierKey- Returns:
- The value of n as a
BigInteger.
-
getModulus
Retrieves the modulus used in the Paillier cryptosystem.- Specified by:
getModulusin interfacePaillierKey- Returns:
- The modulus as a
BigInteger.
-
getAlgorithm
Returns the algorithm name for this key.- Specified by:
getAlgorithmin interfaceKey- Returns:
- The algorithm name ("Paillier").
-
getFormat
Returns the format of the key encoding. -
getEncoded
public byte[] getEncoded()Returns the encoded form of the key.- Specified by:
getEncodedin interfaceKey- Returns:
- The encoded key as a byte array, or null if not supported.
-
equals
Compares this public key with another object for equality.
-