paillierp.zkp
Class EncryptionZKP

java.lang.Object
  extended by paillierp.zkp.ZKP
      extended by paillierp.zkp.EncryptionZKP
All Implemented Interfaces:
java.io.Serializable

public class EncryptionZKP
extends ZKP

A non-interactive Zero Knowledge Proof that the ciphertext is of a known message. This Zero Knowledge Proof correctly proves that one knows the plaintext m and random number r in the ciphertext E(m, r). This is done without revealing either the plaintext nor the random number.

The protocol is given on p. 41 in Multiparty Computation from Threshold Homomorphic Encryption by Cramer, Damgård, and Nielsen.

Author:
Murat Kantarcioglu, Sean Hall, James Garrity
See Also:
Serialized Form

Field Summary
private  java.math.BigInteger b
          gxun mod n2 for random x, u.
private  java.math.BigInteger c
          Ciphertext E(α, r).
private  java.math.BigInteger n
           
private  java.math.BigInteger nSPlusOne
           
private static long serialVersionUID
          This Serial ID
private  java.math.BigInteger w
          The value x+eα for the plaintext α and random x.
private  java.math.BigInteger z
          usegt mod n2 for hash e and g=n+1.
 
Fields inherited from class paillierp.zkp.ZKP
hashFunction
 
Constructor Summary
EncryptionZKP(byte[] b)
          Creates an instance of the Zero Knowledge Proof of decryption from a byte array which does have the key encoded.
EncryptionZKP(byte[] b, java.math.BigInteger nSPlusOne, java.math.BigInteger n)
          Creates an instance of the Zero Knowledge Proof from a byte array (which does not have the key) and the values necessary for verification.
EncryptionZKP(byte[] b, PaillierKey pubkey)
          Creates an instance of the Zero Knowledge Proof from a byte array (which does not have the key) and a public key.
EncryptionZKP(PaillierKey key, java.math.BigInteger alpha)
          Computes a random encryption of alpha.
 
Method Summary
 java.math.BigInteger getValue()
          The encrypted value of α.
 byte[] toByteArray()
          Encodes this ZKP into a byte array.
 byte[] toByteArrayNoKey()
          Encodes this ZKP into a byte array.
 boolean verify()
          Verifies if all of the above integers are indeed true, thereby showing that this encryption is exact.
 boolean verifyKey(PaillierKey origkey)
          Verifies that the values used in this Zero Knowledge Proof corresponds to the given key.
 
Methods inherited from class paillierp.zkp.ZKP
hash
 
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

nSPlusOne

private java.math.BigInteger nSPlusOne

n

private java.math.BigInteger n

z

private java.math.BigInteger z
usegt mod n2 for hash e and g=n+1.


w

private java.math.BigInteger w
The value x+eα for the plaintext α and random x.


b

private java.math.BigInteger b
gxun mod n2 for random x, u.


c

private java.math.BigInteger c
Ciphertext E(α, r).

Constructor Detail

EncryptionZKP

public EncryptionZKP(byte[] b)
Creates an instance of the Zero Knowledge Proof of decryption from a byte array which does have the key encoded.

Parameters:
b - byte array of the necessary values for a ZKP
Throws:
java.lang.IllegalArgumentException - if it detects that some corruption has occured, for example, if the "size of next BigInteger" field is a larger number than typical causing out of bounds issues.
See Also:
toByteArray()

EncryptionZKP

public EncryptionZKP(byte[] b,
                     java.math.BigInteger nSPlusOne,
                     java.math.BigInteger n)
Creates an instance of the Zero Knowledge Proof from a byte array (which does not have the key) and the values necessary for verification. If the key values were originally encoded into b, then those values are used.

Parameters:
b - byte array of the necessary values for a ZKP
nSPlusOne - the public key modulus ns+1
n - the public key modulus n
See Also:
toByteArrayNoKey()

EncryptionZKP

public EncryptionZKP(byte[] b,
                     PaillierKey pubkey)
Creates an instance of the Zero Knowledge Proof from a byte array (which does not have the key) and a public key. If the key values were originally encoded into b, then those values are used.

Parameters:
b - byte array of the necessary values for a ZKP
pubkey - public Paillier key to provide further recurring values for a ZKP
See Also:
toByteArrayNoKey()

EncryptionZKP

public EncryptionZKP(PaillierKey key,
                     java.math.BigInteger alpha)
Computes a random encryption of alpha. This additionally sets up a Zero Knowledge Proof that this multiplication was done, without revealing anything of alpha.

Parameters:
key - Public key n used to encrypt
alpha - The message α
Method Detail

getValue

public java.math.BigInteger getValue()
The encrypted value of α.

Specified by:
getValue in class ZKP

verify

public boolean verify()
Verifies if all of the above integers are indeed true, thereby showing that this encryption is exact.

Specified by:
verify in class ZKP
Returns:
True if the computed value is indeed a random encryption of a known message

verifyKey

public boolean verifyKey(PaillierKey origkey)
Verifies that the values used in this Zero Knowledge Proof corresponds to the given key.

Parameters:
origkey - A given key
Returns:
The truth of the computation of ci as being encrypted by origkey

toByteArray

public byte[] toByteArray()
Encodes this ZKP into a byte array. All of the necessary values (including the public key values) needed to verify the veracity of this encryption are encoded. Before each BigInteger (except n) is the 4-byte equivalent to the size of the BigInteger for later parsing.

Specified by:
toByteArray in class ZKP
Returns:
a byte array containing the most necessary values of this ZKP. A byte array of size 0 is returned if the byte array would be too large.
See Also:
EncryptionZKP(byte[]), BigInteger.toByteArray()

toByteArrayNoKey

public byte[] toByteArrayNoKey()
Encodes this ZKP into a byte array. All of the necessary values (besides the public key values) needed to verify the veracity of this encryption are encoded. Before each BigInteger (except n) is the 4-byte equivalent to the size of the BigInteger for later parsing.

Specified by:
toByteArrayNoKey in class ZKP
Returns:
a byte array containing the most necessary values of this ZKP. A byte array of size 0 is returned if the byte array would be too large.
See Also:
EncryptionZKP(byte[], PaillierKey), BigInteger.toByteArray()