A Python 3 library for Partially Homomorphic Encryption using the Paillier crypto system.

The homomorphic properties of the Paillier crypto system are:

  • Encrypted numbers can be multiplied by a non encrypted scalar.
  • Encrypted numbers can be added together.
  • Encrypted numbers can be added to non encrypted scalars.


>>> from phe import paillier
>>> public_key, private_key = paillier.generate_paillier_keypair()
>>> secret_number_list = [3.141592653, 300, -4.6e-12]
>>> encrypted_number_list = [public_key.encrypt(x) for x in secret_number_list]
>>> [private_key.decrypt(x) for x in encrypted_number_list]
[3.141592653, 300, -4.6e-12]

See Usage for more extensive examples taking advantage of the homomorphic properties of the paillier cryptosystem.

Documentation generated

Apr 20, 2018