Code Monkey home page Code Monkey logo

jpaillier's Introduction

jPaillier

Build Status

A Java implementation of the Paillier cryptosystem.

This library was developed as part of the research project CoPPDA (Corporate Privacy Preserving Data Analysis, http://www.enterprise-application-development.org/projects/coppda.html). To see it in action have a look at ppid3 where it is used to implement a privacy preserving ID3 decision tree generation algorithm.

WARNING: This library was developed for research only and is by no means implemented in a cryptographically secure way.

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

jpaillier's People

Contributors

kunerd avatar manishkk avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.