Skip to main content

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.

📖 Documentation

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.

Metadata

Release files for pypaillier 0.7.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pypaillier 0.7.1
File Size Uploaded Provenance
pypaillier-0.7.1.tar.gz 133.4 kB With provenance Details

Built distributions (wheels)

Table of built distributions (wheels) for pypaillier 0.7.1
File
pypaillier-0.7.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.17+ x86-64 Details
pypaillier-0.7.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ x86-64 Details
pypaillier-0.7.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.17+ x86-64 Details
pypaillier-0.7.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.17+ x86-64 Details

Total release size: 2.3 MB

Release files / pypaillier-0.7.1.tar.gz

Download URL pypaillier-0.7.1.tar.gz
Size 133.4 kB
Tags Source
SHA-256 checksum
How to use checksums
94f3c40ae4b47e3d36c5e48f9fb0448acf775e57c66fa17db27b7b4a57f56c6c
BLAKE2b-256 checksum
How to use checksums
1541c80abf8e303a1fefba99c57b7f1a74c95e2c5d6019859489e077ae7fb86c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 7, 2026.

Transparency log

Release files / pypaillier-0.7.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL pypaillier-0.7.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 550.5 kB
Tags CPython 3.13 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
d13e46769a7abf29104a9c629914266eebb06455e43be1019ce808921fcc7c66
BLAKE2b-256 checksum
How to use checksums
90c197f9c9bd502a83dbc4235995c45766925db9cc0e83ff4e18a4b42d25df14
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 7, 2026.

Transparency log

Release files / pypaillier-0.7.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL pypaillier-0.7.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 550.7 kB
Tags CPython 3.12 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
6663ccf736ac8ed7ba265551a498447ddd0a5700995b27a53b97c7557b2812f6
BLAKE2b-256 checksum
How to use checksums
33ff7ece9d126c832106e3b4aadceb4d642a2593a617241a3d52db91e9f5cb50
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 7, 2026.

Transparency log

Release files / pypaillier-0.7.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL pypaillier-0.7.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 551.1 kB
Tags CPython 3.11 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
bd80c2245aff3cb1303095c35aa3685dd52f84c5f8df20c8bd2b32e094e1892a
BLAKE2b-256 checksum
How to use checksums
cf86e3bcc05038ac5f76e8911c473be07929639127869a8708445fd81dbbbc7b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 7, 2026.

Transparency log

Release files / pypaillier-0.7.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL pypaillier-0.7.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 551.1 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
0b9130d7e17afa536fe7eda93b1fae65f91ee1b133f42399d6088ec6c047a73f
BLAKE2b-256 checksum
How to use checksums
58775f2c24d0130ac9fb97c869169ac17c6b2ec058859c6865f6f8f040128283
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 7, 2026.

Transparency log

Security for pypaillier 0.7.1

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.

Full provenance

All 5 files in this release have been uploaded with provenance metadata.

Select from 5 files

Attestation for pypaillier-0.7.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 7, 2026.

Transparency log

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page