Skip to main content

Implementation of the Paillier cryptosystem

Project description

TNO MPC Lab - Encryption Schemes - Paillier

The TNO MPC lab consists of generic software components, procedures, and functionalities developed and maintained on a regular basis to facilitate and aid in the development of MPC solutions. The lab is a cross-project initiative allowing us to integrate and reuse previously developed MPC functionalities to boost the development of new protocols and solutions.

The package tno.mpc.encryption_schemes.paillier is part of the TNO Python Toolbox.

Remark: This cryptography software may not be used in applications that violate international export control legislations.

Documentation

Documentation of the tno.mpc.encryption_schemes.paillier package can be found here.

Install

Easily install the tno.mpc.encryption_schemes.paillier package using pip:

$ python -m pip install tno.mpc.encryption_schemes.paillier

Note:

A significant performance improvement can be achieved by installing the GMPY2 library.

$ python -m pip install 'tno.mpc.encryption_schemes.paillier[gmpy]'

If you wish to use the tno.mpc.communication module you can use:

$ python -m pip install 'tno.mpc.encryption_schemes.paillier[communication]'

If you wish to run the tests you can use:

$ python -m pip install 'tno.mpc.encryption_schemes.paillier[tests]'

Usage

Implementation of the Paillier encryption scheme with support with precomputation of randomness. The encryption scheme supports positive and negative numbers, as well as fixed point encoding of numbers. Homomorphic addition of ciphertexts, negation of ciphertexts, and multiplication of ciphertexts with integral scalars has been included too.

from tno.mpc.encryption_schemes.paillier import Paillier

if __name__ == "__main__":
    # initialize Paillier with key_length of 2048 bits and fixed point precision of 3 decimals
    paillier_scheme = Paillier.from_security_parameter(key_length=2048, precision=3)
    # encrypt the number 8.1
    ciphertext_1 = paillier_scheme.encrypt(8.1)
    # add 0.9 to the original plaintext
    ciphertext_1 += 0.9
    # multiply the original plaintext by 10
    ciphertext_1 *= 10
    # encrypt the number 10
    ciphertext_2 = paillier_scheme.encrypt(10)
    # add both encrypted numbers together
    encrypted_sum = ciphertext_1 + ciphertext_2
    # decrypt the encrypted sum to 100
    decrypted_sum = paillier_scheme.decrypt(encrypted_sum)
    assert decrypted_sum == 100

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file tno.mpc.encryption_schemes.paillier-0.4.3-py3-none-any.whl.

File metadata

  • Download URL: tno.mpc.encryption_schemes.paillier-0.4.3-py3-none-any.whl
  • Upload date:
  • Size: 18.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.0

File hashes

Hashes for tno.mpc.encryption_schemes.paillier-0.4.3-py3-none-any.whl
Algorithm Hash digest
SHA256 cdb34b24948fa4cbbfd854eb4d3285457fdf009a69196db64fd409ca7baa3eba
MD5 0e15945c606c62b9df5bd7fecb762f9c
BLAKE2b-256 6b74f08d25b100d0f259ef8d84fe85b9e6a4e3edcd156267a8ef24845a3e4338

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page