paillierp.key
Class PaillierPrivateKey

java.lang.Object
  extended by paillierp.key.PaillierKey
      extended by paillierp.key.PaillierPrivateKey
All Implemented Interfaces:
java.io.Serializable

public class PaillierPrivateKey
extends PaillierKey

A simple private key for the generalized Paillier cryptosystem CS1.

The private key for the generalized Paillier cryptosystem CSs constructed in Damgård et al. requires the public key values of n and g (as provided for in PaillierKey), and the secret value d as defined as follows:

Version:
1.0 03/25/10
Author:
James Garrity, Sean Hall
See Also:
PaillierKey, Serialized Form

Field Summary
protected  java.math.BigInteger d
          Secret key; d mod nZ*n and d = 0 mod λ, where λ is least common multiple of p-1 and q-1.
protected  java.math.BigInteger dInvs
          The inverse of d mod ns.
private static long serialVersionUID
          This Serial ID
 
Fields inherited from class paillierp.key.PaillierKey
k, MAX_KEY_SIZE, n, nPlusOne, ns, nSPlusOne, rnd
 
Constructor Summary
PaillierPrivateKey(java.math.BigInteger p, java.math.BigInteger q, java.math.BigInteger d, long seed)
          Creates a new private key when given the primes p and q and the secret value d.
PaillierPrivateKey(java.math.BigInteger n, java.math.BigInteger d, long seed)
          Creates a new private key when given the modulus n and the secret value d.
PaillierPrivateKey(byte[] b, long seed)
          Creates a new private key using a byte encoding of a key.
 
Method Summary
 boolean canEncrypt()
          Describes if this key can be used to encrypt
 java.math.BigInteger getD()
          Accesses the secret integer d chosen at the creation of this secret key.
 java.math.BigInteger getDInvs()
          Access the precomputed inverse of d in Z*ns+1.
 byte[] toByteArray()
          Encodes this key into a byte array.
 java.math.BigInteger[] toIntArray()
          Returns a BigInt array corresponding to this Paillier pubilc key.
 
Methods inherited from class paillierp.key.PaillierKey
getK, getN, getNPlusOne, getNS, getNSPlusOne, getPublicKey, getRandomModN, getRandomModNSPlusOneStar, getRandomModNStar, getRnd, inModN, inModN, inModNS, inModNSPlusOne, inModNSPlusOneStar, inModNStar, inModNStar, isCiphertext, isPlaintext, setRnd, setRnd, updateRnd
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
This Serial ID

See Also:
Constant Field Values

d

protected java.math.BigInteger d
Secret key; d mod nZ*n and d = 0 mod λ, where λ is least common multiple of p-1 and q-1.


dInvs

protected java.math.BigInteger dInvs
The inverse of d mod ns. Used in the final step of decryption.

Constructor Detail

PaillierPrivateKey

public PaillierPrivateKey(java.math.BigInteger n,
                          java.math.BigInteger d,
                          long seed)
Creates a new private key when given the modulus n and the secret value d. This constructor will use the seed to create the public key with a SecureRandom random number generator.

Parameters:
n - a RSA modulus. That is, the product of two different odd primes p, q.
d - an integer that should be a multiple of the least common multiple of p-1 and q-1, and relatively prime to n
seed - a long integer needed to start a random number generator

PaillierPrivateKey

public PaillierPrivateKey(java.math.BigInteger p,
                          java.math.BigInteger q,
                          java.math.BigInteger d,
                          long seed)
Creates a new private key when given the primes p and q and the secret value d. This constructor will use the seed to create the public key with a SecureRandom random number generator.

Parameters:
p - one allowable prime for our modulus
q - another prime for our modulus, different from
d - an integer that should be a multiple of the least common multiple of p-1 and q-1, and relatively prime to p*q
seed - a long integer needed to start a random number generator

PaillierPrivateKey

public PaillierPrivateKey(byte[] b,
                          long seed)
Creates a new private key using a byte encoding of a key.

Parameters:
b - Byte array of the necessary values of this private key
seed - a long integer needed to start a random number generator
See Also:
toByteArray()
Method Detail

canEncrypt

public boolean canEncrypt()
Describes if this key can be used to encrypt

Overrides:
canEncrypt in class PaillierKey
Returns:
'true' if it can encrypt.

getD

public java.math.BigInteger getD()
Accesses the secret integer d chosen at the creation of this secret key. In the generalized Paillier cryptosystem, ciphertext E(i,r) raised to the d power will result in (1+n)jid mod ns. Applying a method, one can easily find jid and jd, allowing one to find i mod ns. Note that in our simplified version, both s and j are 1.

Returns:
the secret integer that allows decryption

getDInvs

public java.math.BigInteger getDInvs()
Access the precomputed inverse of d in Z*ns+1. This allows one to decrypt a little more expediently.

Returns:
the inverse of d in mod n2
See Also:
getD()

toIntArray

public java.math.BigInteger[] toIntArray()
Returns a BigInt array corresponding to this Paillier pubilc key.


toByteArray

public byte[] toByteArray()
Encodes this key into a byte array. As this is a public key, the public modulo n, d will be encoded in that order. Further, before d is the 4-byte equivalent to the size of the BigInteger for later parsing.

Overrides:
toByteArray in class PaillierKey
Returns:
a byte array containing the most necessary values of this key. A byte array of size 0 is returned if the key would be too large.
See Also:
PaillierPrivateKey(byte[], long), BigInteger.toByteArray()