|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectpaillierp.AbstractPaillier
paillierp.Paillier
public class Paillier
A simple implementation of the generalized Paillier encryption scheme CS1. This is based on the gernarlization given in Generalization of Paillier's Public-Key System with Applications to Electronic Voting by Damgård et al. with the parameter s fixed at 1.
With most of the methods already defined in AbstractPaillier
, this
class provides the essential methods of encryption and decryption in the
simplified Paillier encryption scheme, as well as a few test/diagnostic
methods.
The Math: The simplified Paillier encryption scheme takes a
PaillierKey
n to encrypt a plaintext
i in Zns by choosing a random
r∈Zn* by simply computing
(n+1)irn mod ns+1.
If given a PaillierPrivateKey
d, raising a ciphertext c to the power d gives a value
(1+n)id, and by using a method in the paper, can
give the original message i mod ns.
Note that the random number
generator is included in the key object. (The default is
SecureRandom
.)
Future expansions will include support for encrypting arbitrary length strings/byte arrays to avoid padding issues, and support for padding.
AbstractPaillier
Field Summary | |
---|---|
protected PaillierPrivateKey |
deckey
Private Key allowing decryption; should be same as public key. |
Fields inherited from class paillierp.AbstractPaillier |
---|
decryptMode, encryptMode, key, notReadyForDecryption, notReadyForEncryption |
Constructor Summary | |
---|---|
Paillier()
Default constructor. |
|
Paillier(PaillierKey key)
Constructs a new encryption object which uses the specified key for encryption. |
|
Paillier(PaillierPrivateKey key)
Constructs a new encryption/decryption object which uses the specified key for both encryption and decryption. |
Method Summary | |
---|---|
java.math.BigInteger |
decrypt(java.math.BigInteger c)
Decrypts the given ciphertext. |
PaillierPrivateKey |
getPrivateKey()
Returns the current private key in use by this encryption object. |
void |
setDecryptEncrypt(PaillierPrivateKey key)
Sets the mode for this object to decrypt and encrypt using the provided key. |
void |
setDecryption(PaillierPrivateKey key)
Sets the mode for this object to decrypt and will use the provided key to decrypt only. |
void |
setEncryption(PaillierKey key)
Sets the mode for this object to encrypt and will use the provided key to encrypt messages. |
static void |
test()
This main method basically tests the different features of the Paillier encryption |
static void |
testICDE()
|
Methods inherited from class paillierp.AbstractPaillier |
---|
add, add, encrypt, encrypt, encrypt, encrypt, encrypt, encryptone, encryptProof, encryptzero, getPublicKey, multiply, multiply, multiply, multiplyProof, randomize, randomize |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected PaillierPrivateKey deckey
Constructor Detail |
---|
public Paillier()
public Paillier(PaillierKey key)
key
- Public key used for encryptionpublic Paillier(PaillierPrivateKey key)
key
- Private key used for decryption and encryptionMethod Detail |
---|
public void setEncryption(PaillierKey key)
key
- Public key which this class will use to encryptpublic void setDecryption(PaillierPrivateKey key)
setEncryption(PaillierKey)
.)
key
- Private key which this class will use to decryptpublic void setDecryptEncrypt(PaillierPrivateKey key)
key
- Private key which this class will use to encrypt and decryptpublic PaillierPrivateKey getPrivateKey()
null
if this is not
in decryption mode.public java.math.BigInteger decrypt(java.math.BigInteger c)
c
- Ciphertext as BigInteger c
public static void test()
public static void testICDE()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |