Skip to content

A Java implementation of Paillier cryptosystem.

License

Notifications You must be signed in to change notification settings

fastluca/jpaillier

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jPaillier

Build Status

A Java implementation of Paillier cryptosystem.

This library is developed as part of the research project CoPPDA (Corporate Privacy Preserving Data Analysis, http://www.enterprise-application-development.org/projects/coppda.html). There it is used for the implementation of different privacy preserving data minin methods.

WARNING: This library is developed for research, also it is in an early state and therefor NOT production ready.

Usage

create a key pair:

    KeyPairBuilder keygen = new KeyPairBuilder();
    keyPair = keygen.generateKeyPair();

encryption:

	PublicKey publicKey = keyPair.getPublicKey();
    BigInteger ciphertext = publicKey.encrypt(plainData);

decrypt a ciphertext:

    BigInteger decryptedData = keyPair.decrypt(ciphertext);

Homomorphic Addition

An interesting feature of the Paillier cryptosystem is its homomophic properties. The following example demonstrates how this library can be used to compute the homomorphic addition of two plaintext input values.

	BigInteger plainA = BigInteger.valueOf(102);
	BigInteger plainB = BigInteger.valueOf(203);

	BigInteger encryptedA = publicKey.encrypt(plainA);
	BigInteger encryptedB = publicKey.encrypt(plainB);
	
	BigInteger encryptedProduct = encryptedA.multiply(encryptedB).mod(publicKey.getnSquared());

	BigInteger additionResult = keypair.decrypt(encryptedProduct);
		
	// additionResult = 102 + 203 = 305

See the references for details. More examples can be found in the file: HomomorphicPropertiesTest.

##References

About

A Java implementation of Paillier cryptosystem.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 100.0%