paillier-lib
This package provides a simple implementation of the Paillier cryptosystem using gmpy2.
Usage
from paillierlib import paillier
from gmpy2 import mpz
key_pair = paillier.keygen() # Optional param.: bit size (default = 2048)
m1 = mpz(10)
m2 = mpz(1)
c1 = paillier.encrypt(m1, key_pair.public_key)
c2 = paillier.encrypt(m2, key_pair.public_key)
# Example homomorphic operations
# Addition
paillier.decrypt(c1 + c2, key_pair.private_key) # => 11
paillier.decrypt(c1 - c2, key_pair.private_key) # => 9
paillier.decrypt(c1 + c1 + c2, key_pair.private_key) # => 21
# Multiplication (ciphertext with plaintext)
m3 = mpz(2)
paillier.decrypt(c1 * m3, key_pair.private_key) # => 20
Requirements
gmpy2 (tested v2.0.8)
Planned Work
- Encode inputs, rather than requiring GMP MPZ objects.
Metadata
Release files for paillierlib 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| paillierlib-0.0.2.tar.gz | 2.7 kB | Without provenance | Details for paillierlib-0.0.2.tar.gz |
Release files / paillierlib-0.0.2.tar.gz
| Download URL | paillierlib-0.0.2.tar.gz |
|---|---|
| Size | 2.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
80c2db03dc136c82a59039b3e7a4dcc0ed3cec14b8732efb996d027999ed03f6
|
|
BLAKE2b-256 checksum How to use checksums |
22b7b1731249cafc33326e66e350588244ecbcae8810f615226283937c34a415
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/39.1.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.5
|
Security for paillierlib 0.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.