Class PaillierPrivateKey
java.lang.Object
edu.fiu.adwise.homomorphic_encryption.paillier.PaillierPrivateKey
- All Implemented Interfaces:
PaillierKey,Serializable,Key,PrivateKey,Destroyable
public final class PaillierPrivateKey
extends Object
implements Serializable, PaillierKey, PrivateKey
This class represents a private key in the Paillier cryptosystem.
It implements the
PaillierKey and PrivateKey interfaces
and is also serializable.- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionPaillierPrivateKey(int key_size, BigInteger n, BigInteger mod, BigInteger lambda, BigInteger mu, BigInteger g, BigInteger alpha) Constructs a Paillier private key with the specified parameters. -
Method Summary
Modifier and TypeMethodDescriptionbooleanCompares this private 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 PaillierPrivateKeyReads a private key from a file.toString()Returns a string representation of the private key, omitting secret parameters.voidWrites the private key to a file.Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface javax.security.auth.Destroyable
destroy, isDestroyed
-
Constructor Details
-
PaillierPrivateKey
public PaillierPrivateKey(int key_size, BigInteger n, BigInteger mod, BigInteger lambda, BigInteger mu, BigInteger g, BigInteger alpha) Constructs a Paillier private 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).mod- The modulus (n^2).lambda- The Carmichael's function value.mu- The modular inverse of lambda mod n.g- The generator g.alpha- The smallest divisor of lcm(p-1, q-1).
-
-
Method Details
-
writeKey
Writes the private key to a file.- Parameters:
paillier_private_key_file- The file path to save the private key.- Throws:
IOException- If an I/O error occurs.
-
readKey
public static PaillierPrivateKey readKey(String paillier_private_key) throws IOException, ClassNotFoundException Reads a private key from a file.- Parameters:
paillier_private_key- The file path to read the private key from.- Returns:
- The
PaillierPrivateKeyobject. - Throws:
IOException- If an I/O error occurs.ClassNotFoundException- If the class of the serialized object cannot be found.
-
toString
Returns a string representation of the private key, omitting secret parameters. -
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 private key with another object for equality.
-