Python bindings for post-quantum cryptography. Wraps well-tested Rust implementations of NIST-standardized and candidate KEM and signature schemes via PyO3/maturin. All variants live in a single compiled wheel.
Installation
pip install pqcrypto
Or build from source:
pip install maturin pytest
maturin develop
Quick Start
The Python API mirrors the Rust crate design: keygen, encaps, decaps
(KEM) and keygen, sign, verify (signatures).
KEM — Key Encapsulation
from pqcrypto.kem.ml_kem_512 import keygen, encaps, decaps
from pqcrypto.kem.ml_kem_512 import PublicKey, SecretKey
pk, sk = keygen()
ct, ss = encaps(pk)
assert decaps(sk, ct) == ss
pk_obj = PublicKey(pk)
sk_obj = SecretKey(sk)
ct2, ss2 = pk_obj.encaps()
assert ss2 == sk_obj.decaps(ct2)
Signatures
from pqcrypto.sign.ml_dsa_44 import keygen, sign, verify
from pqcrypto.sign.ml_dsa_44 import PublicKey, SecretKey
pk, sk = keygen()
sig = sign(sk, b"message")
verify(pk, b"message", sig) # returns None; raises InvalidSignatureError if invalid
# FIPS 204/205 context string:
sig = sign(sk, b"message", b"my-context")
verify(pk, b"message", sig, b"my-context")
# HashML-DSA / HashSLH-DSA pre-hash mode:
from pqcrypto import HashAlgorithm
sig = sign(sk, b"message", hash_algorithm=HashAlgorithm.Sha256)
verify(pk, b"message", sig, hash_algorithm=HashAlgorithm.Sha256)
pk_obj = PublicKey(pk)
sk_obj = SecretKey(sk)
sig_obj = sk_obj.sign(b"message")
pk_obj.verify(b"message", sig_obj)
Size constants
from pqcrypto.kem.ml_kem_512 import PUBLIC_KEY_SIZE, SECRET_KEY_SIZE, CIPHERTEXT_SIZE, SHARED_SECRET_SIZE
from pqcrypto.sign.ml_dsa_44 import PUBLIC_KEY_SIZE, SECRET_KEY_SIZE, SIGNATURE_SIZE
Algorithms
Modules live in pqcrypto.kem (KEM) and pqcrypto.sign (signatures).
Key Encapsulation
- ML-KEM (FIPS 203)
ml_kem_512,ml_kem_768,ml_kem_1024
- Classic McEliece
mceliece_348864mceliece_348864fmceliece_460896mceliece_460896fmceliece_6688128mceliece_6688128fmceliece_6960119mceliece_6960119fmceliece_8192128mceliece_8192128f
- SNTRUP
sntrup_653sntrup_761sntrup_857sntrup_953sntrup_1013sntrup_1277
- HQC (FIPS 207)
hqc_128,hqc_192,hqc_256
Signatures
- ML-DSA (FIPS 204)
ml_dsa_44,ml_dsa_65,ml_dsa_87
- SLH-DSA (FIPS 205)
slh_dsa_sha2_128sslh_dsa_sha2_128fslh_dsa_sha2_192sslh_dsa_sha2_192fslh_dsa_sha2_256sslh_dsa_sha2_256fslh_dsa_shake_128sslh_dsa_shake_128fslh_dsa_shake_192sslh_dsa_shake_192fslh_dsa_shake_256sslh_dsa_shake_256f
Security
The cryptographic implementations are provided by the backbone crates. These crates have not undergone a formal security audit; third-party review is recommended before production use. This Python wrapper is a thin shim — it validates key lengths, maps errors to Python exceptions, and provides idiomatic key objects.
License
Apache-2.0. See LICENSE.
Metadata
Release files for pqcrypto 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pqcrypto-1.0.0.tar.gz | 19.8 kB | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| pqcrypto-1.0.0-cp39-abi3-win_amd64.whl | CPython 3.9 | abi3 | Windows x86-64 | Details |
| pqcrypto-1.0.0-cp39-abi3-musllinux_1_2_x86_64.whl | CPython 3.9 | abi3 | Linux musl 1.2+ x86-64 | Details |
| pqcrypto-1.0.0-cp39-abi3-musllinux_1_2_aarch64.whl | CPython 3.9 | abi3 | Linux musl 1.2+ ARM64 | Details |
| pqcrypto-1.0.0-cp39-abi3-manylinux_2_34_x86_64.whl | CPython 3.9 | abi3 | Linux glibc 2.34+ x86-64 | Details |
| pqcrypto-1.0.0-cp39-abi3-manylinux_2_34_aarch64.whl | CPython 3.9 | abi3 | Linux glibc 2.34+ ARM64 | Details |
| pqcrypto-1.0.0-cp39-abi3-macosx_11_0_arm64.whl | CPython 3.9 | abi3 | macOS 11.0+ ARM64 | Details |
| pqcrypto-1.0.0-cp39-abi3-macosx_10_12_x86_64.whl | CPython 3.9 | abi3 | macOS 10.12+ x86-64 | Details |
Total release size: 6.2 MB
Release files / pqcrypto-1.0.0.tar.gz
| Download URL | pqcrypto-1.0.0.tar.gz |
|---|---|
| Size | 19.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b41e6cba972e010d5f3674d8a52bc75d8742e1e5d063b57ba172127cf3ef9c40
|
|
BLAKE2b-256 checksum How to use checksums |
5b10e835821a6c5df73b196b27812bd5f1562df8f675acab6ad5232b8c28916d
|
| 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 Aug 15, 2026.
Transparency logRelease files / pqcrypto-1.0.0-cp39-abi3-win_amd64.whl
| Download URL | pqcrypto-1.0.0-cp39-abi3-win_amd64.whl |
|---|---|
| Size | 756.9 kB |
| Tags | CPython 3.9 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
d65d0fdbd2bfcfd80193d1d499142e63dd8ea6a072e1dc68b1b36fd49f9fdc8f
|
|
BLAKE2b-256 checksum How to use checksums |
9bfef6fb3cdf26345882c408d0d9302e0a2be8084ba1cb67710318b3be0ebf76
|
| 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 Aug 15, 2026.
Transparency logRelease files / pqcrypto-1.0.0-cp39-abi3-musllinux_1_2_x86_64.whl
| Download URL | pqcrypto-1.0.0-cp39-abi3-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.9 Linux musl 1.2+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
9160e59a8b9a860ea960a0b2fb8b479ee2d56f3c062c4be3f86ce346807443dd
|
|
BLAKE2b-256 checksum How to use checksums |
b82248c29acd771fa55b26e20b66df194a6a63166cf4b5cffba7c4d59ffc66b0
|
| 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 Aug 15, 2026.
Transparency logRelease files / pqcrypto-1.0.0-cp39-abi3-musllinux_1_2_aarch64.whl
| Download URL | pqcrypto-1.0.0-cp39-abi3-musllinux_1_2_aarch64.whl |
|---|---|
| Size | 1.0 MB |
| Tags | CPython 3.9 Linux musl 1.2+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
f8c29900937b84ce18943694acb7276af36e2c52e1673debe02ecf9494472a35
|
|
BLAKE2b-256 checksum How to use checksums |
8dc8fd11c1e4ebbc019274843f170e23907553fd8b9a30c9c33b2cc02fcf3a60
|
| 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 Aug 15, 2026.
Transparency logRelease files / pqcrypto-1.0.0-cp39-abi3-manylinux_2_34_x86_64.whl
| Download URL | pqcrypto-1.0.0-cp39-abi3-manylinux_2_34_x86_64.whl |
|---|---|
| Size | 857.9 kB |
| Tags | CPython 3.9 Linux glibc 2.34+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
7068532dbc1225a9d668d59940bd96dc13f40175a757b2e31c69aa697781f4d0
|
|
BLAKE2b-256 checksum How to use checksums |
c6c2965a137eef8d95f9cf25c3dbe935540cff303c272ee045dc9f110bd206d8
|
| 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 Aug 15, 2026.
Transparency logRelease files / pqcrypto-1.0.0-cp39-abi3-manylinux_2_34_aarch64.whl
| Download URL | pqcrypto-1.0.0-cp39-abi3-manylinux_2_34_aarch64.whl |
|---|---|
| Size | 871.3 kB |
| Tags | CPython 3.9 Linux glibc 2.34+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
71b199d6460a646071cdb505e6acca8c9a050c3252bba023b8065b9518dce9c9
|
|
BLAKE2b-256 checksum How to use checksums |
e9920876f27be9289cdf87bcef5dbcbc42d89eacfd6ecb99f23928ef3a21a700
|
| 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 Aug 15, 2026.
Transparency logRelease files / pqcrypto-1.0.0-cp39-abi3-macosx_11_0_arm64.whl
| Download URL | pqcrypto-1.0.0-cp39-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 831.1 kB |
| Tags | CPython 3.9 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
ccc13a4443a499d70aa9d29ce899e8782d4a5e57b79baa92fa13ea33512533c7
|
|
BLAKE2b-256 checksum How to use checksums |
50f2790da887e9167e4bc3d41e470c7ad1cd90df90c66e2da8b3d11f284c37f0
|
| 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 Aug 15, 2026.
Transparency logRelease files / pqcrypto-1.0.0-cp39-abi3-macosx_10_12_x86_64.whl
| Download URL | pqcrypto-1.0.0-cp39-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 797.6 kB |
| Tags | CPython 3.9 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
3c0aa8346222631418e7caac040a53cc1f5245553d3275ce1d8403cfe8dd9fb4
|
|
BLAKE2b-256 checksum How to use checksums |
d561bdddb98d0d19c8177c4bcb4e9a75762ee81b7518eef9f69f0b5018873101
|
| 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 Aug 15, 2026.
Transparency log