pypaillier
Additively homomorphic Paillier encryption: a Rust implementation on top of GMP, bound to Python through pyo3.
Add encrypted numbers without decrypting them:
import paillier
pub, sec = paillier.generate_keypair(2048)
blobs = [bytes(b) for b in paillier.encrypt_many(pub, [1.5, 2.25, -0.75])]
total = paillier.add_many(pub, blobs) # adding CIPHERTEXTS
paillier.decrypt(sec, total) # 3.0
Whoever does the adding never sees the terms. Whoever holds the private key sees only the sum.
pip install pypaillier
Wheels for CPython 3.10–3.13, manylinux_2_17. No compiler and no
system GMP required. The distribution is pypaillier; the import name
is paillier.
Before you use it
This is not textbook Paillier. The scheme is the Damgård–Jurik
variant with a short exponent, c = (1 + m·n) · hs^r mod n². Ciphertext
indistinguishability therefore rests on an additional short-exponent
assumption, not on DCRA alone.
Constant time is not claimed as a whole-library property. The three timing channels found in encryption are closed: two are guarded by tests that measure a slope against the secret, and the third — the cache address — cannot be, because it changes neither the answer nor the time measurably; it is guarded by a check on the shape of the code. Key generation is a prime search and is not constant time at all.
Both are explained in full, with the measurements, in the documentation.
Numbers
2048-bit key, medians:
| operation | cost |
|---|---|
| encryption, all cores | 6800+ ops/s |
| encryption, one core | 1066 ops/s |
| addition | 7.1 µs per term |
| decryption | 3.9 ms |
| key generation | 2.2–3.3 s |
| ciphertext | 512–513 B |
Reproduce with python benches/measure.py.
Accuracy
Fixed point, rounding to nearest. The scale is configurable and travels inside the ciphertext, so decryption reads it from there and addition refuses a batch that mixes scales:
blobs = paillier.encrypt_many(pub, values, scale_pow10=12)
The default is 10^8. See
Encoding and scale.
Building from source
pip install maturin
maturin build --release
Needs stable Rust. GMP is built and linked statically.
Licences
The sources are MIT OR Apache-2.0, at your option.
The built wheels additionally contain GMP, statically linked through
rug, and therefore fall under
LGPL-3.0+ as a whole. For a binary with no LGPL code inside, build
from the source distribution against your own GMP:
pip install --no-binary pypaillier pypaillier.
Full breakdown, including how the LGPL §4 conditions are met:
NOTICE.md.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pypaillier-0.4.0.tar.gz.
File metadata
- Download URL: pypaillier-0.4.0.tar.gz
- Upload date:
- Size: 102.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f15e2725c53a1dc33a4bb0d4e20c4c64ed7cd29cf33eb533db1ea17307016ab2
|
|
| MD5 |
06fd710e4c0c4ae4b13a13cd359901c3
|
|
| BLAKE2b-256 |
ce6ed504b53f7f3dea5efaac7dc11d3bf2d254853b9f3463ae9f195ef801c96f
|
Provenance
The following attestation bundles were made for pypaillier-0.4.0.tar.gz:
Publisher:
publish.yml on veryviolet/paillier
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pypaillier-0.4.0.tar.gz -
Subject digest:
f15e2725c53a1dc33a4bb0d4e20c4c64ed7cd29cf33eb533db1ea17307016ab2 - Sigstore transparency entry: 2616096126
- Sigstore integration time:
-
Permalink:
veryviolet/paillier@af620a895fa95329695021b66f6893b86bafc171 -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/veryviolet
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@af620a895fa95329695021b66f6893b86bafc171 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pypaillier-0.4.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: pypaillier-0.4.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 512.9 kB
- Tags: CPython 3.13, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0e5d5f8f1ff5822a09d8aa45142f424ffb03a52bd5ffb1c1f868ff47e0386471
|
|
| MD5 |
eb21b67037173694b5f2cf05b280b8ea
|
|
| BLAKE2b-256 |
f70e698bacbc9922be21ed1605d107a74f5df12b013cf6a18c8ad8421c43ad6c
|
Provenance
The following attestation bundles were made for pypaillier-0.4.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
publish.yml on veryviolet/paillier
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pypaillier-0.4.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
0e5d5f8f1ff5822a09d8aa45142f424ffb03a52bd5ffb1c1f868ff47e0386471 - Sigstore transparency entry: 2616096370
- Sigstore integration time:
-
Permalink:
veryviolet/paillier@af620a895fa95329695021b66f6893b86bafc171 -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/veryviolet
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@af620a895fa95329695021b66f6893b86bafc171 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pypaillier-0.4.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: pypaillier-0.4.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 513.0 kB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a83957cf270b1eea2bb17469f7cd1e370e1a850477314f0e9c933b8f328cd8bd
|
|
| MD5 |
060043069d404511da9dfa66de697de7
|
|
| BLAKE2b-256 |
1188345bcea9e065e03910e9636e2f9600e17c00a4b53a4cd96beae6c63bbbc1
|
Provenance
The following attestation bundles were made for pypaillier-0.4.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
publish.yml on veryviolet/paillier
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pypaillier-0.4.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
a83957cf270b1eea2bb17469f7cd1e370e1a850477314f0e9c933b8f328cd8bd - Sigstore transparency entry: 2616096620
- Sigstore integration time:
-
Permalink:
veryviolet/paillier@af620a895fa95329695021b66f6893b86bafc171 -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/veryviolet
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@af620a895fa95329695021b66f6893b86bafc171 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pypaillier-0.4.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: pypaillier-0.4.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 512.4 kB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d4fe3a12af2519c0e6a28b94f55dc96f1a56d614fb717fb74ec538e9d6ec787f
|
|
| MD5 |
7775ef5e8c09223cf9ac5e17d189a5c9
|
|
| BLAKE2b-256 |
5b60a5052b28ca91045ff7c46009e36af41580162f83bdf1bd54e6a32d0b8981
|
Provenance
The following attestation bundles were made for pypaillier-0.4.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
publish.yml on veryviolet/paillier
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pypaillier-0.4.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
d4fe3a12af2519c0e6a28b94f55dc96f1a56d614fb717fb74ec538e9d6ec787f - Sigstore transparency entry: 2616096253
- Sigstore integration time:
-
Permalink:
veryviolet/paillier@af620a895fa95329695021b66f6893b86bafc171 -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/veryviolet
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@af620a895fa95329695021b66f6893b86bafc171 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pypaillier-0.4.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: pypaillier-0.4.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 512.4 kB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3aa1f824a1b6cc3e86dfa563cfcb0a0864cf697bc268e9654a4599dbc298ae9b
|
|
| MD5 |
35eb440fdbae1450750cbbc4e3ecef32
|
|
| BLAKE2b-256 |
1d1c4b910cf987d649aa5eb38733233ba18bdb5deee4801ee3711c0bb1a35785
|
Provenance
The following attestation bundles were made for pypaillier-0.4.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
publish.yml on veryviolet/paillier
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pypaillier-0.4.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
3aa1f824a1b6cc3e86dfa563cfcb0a0864cf697bc268e9654a4599dbc298ae9b - Sigstore transparency entry: 2616096469
- Sigstore integration time:
-
Permalink:
veryviolet/paillier@af620a895fa95329695021b66f6893b86bafc171 -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/veryviolet
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@af620a895fa95329695021b66f6893b86bafc171 -
Trigger Event:
push
-
Statement type: