Skip to main content

PQCrypto

Build Status Python Version PyPI Version License

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_348864
    • mceliece_348864f
    • mceliece_460896
    • mceliece_460896f
    • mceliece_6688128
    • mceliece_6688128f
    • mceliece_6960119
    • mceliece_6960119f
    • mceliece_8192128
    • mceliece_8192128f
  • SNTRUP
    • sntrup_653
    • sntrup_761
    • sntrup_857
    • sntrup_953
    • sntrup_1013
    • sntrup_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_128s
    • slh_dsa_sha2_128f
    • slh_dsa_sha2_192s
    • slh_dsa_sha2_192f
    • slh_dsa_sha2_256s
    • slh_dsa_sha2_256f
    • slh_dsa_shake_128s
    • slh_dsa_shake_128f
    • slh_dsa_shake_192s
    • slh_dsa_shake_192f
    • slh_dsa_shake_256s
    • slh_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.

Download files

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

Source Distribution

pqcrypto-1.0.0.tar.gz (19.8 kB view details)

Uploaded Source

Built Distributions

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

pqcrypto-1.0.0-cp39-abi3-win_amd64.whl (756.9 kB view details)

Uploaded CPython 3.9+Windows x86-64

pqcrypto-1.0.0-cp39-abi3-musllinux_1_2_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.9+musllinux: musl 1.2+ x86-64

pqcrypto-1.0.0-cp39-abi3-musllinux_1_2_aarch64.whl (1.0 MB view details)

Uploaded CPython 3.9+musllinux: musl 1.2+ ARM64

pqcrypto-1.0.0-cp39-abi3-manylinux_2_34_x86_64.whl (857.9 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.34+ x86-64

pqcrypto-1.0.0-cp39-abi3-manylinux_2_34_aarch64.whl (871.3 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.34+ ARM64

pqcrypto-1.0.0-cp39-abi3-macosx_11_0_arm64.whl (831.1 kB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

pqcrypto-1.0.0-cp39-abi3-macosx_10_12_x86_64.whl (797.6 kB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

Details for the file pqcrypto-1.0.0.tar.gz.

File metadata

  • Download URL: pqcrypto-1.0.0.tar.gz
  • Upload date:
  • Size: 19.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pqcrypto-1.0.0.tar.gz
Algorithm Hash digest
SHA256 b41e6cba972e010d5f3674d8a52bc75d8742e1e5d063b57ba172127cf3ef9c40
MD5 7894a4bd26f5d056a076047f98f0eb52
BLAKE2b-256 5b10e835821a6c5df73b196b27812bd5f1562df8f675acab6ad5232b8c28916d

See more details on using hashes here.

Provenance

The following attestation bundles were made for pqcrypto-1.0.0.tar.gz:

Publisher: ci.yml on backbone-hq/pqcrypto

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pqcrypto-1.0.0-cp39-abi3-win_amd64.whl.

File metadata

  • Download URL: pqcrypto-1.0.0-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 756.9 kB
  • Tags: CPython 3.9+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pqcrypto-1.0.0-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 d65d0fdbd2bfcfd80193d1d499142e63dd8ea6a072e1dc68b1b36fd49f9fdc8f
MD5 a7c6d6c1660684ada10e8d5044c08559
BLAKE2b-256 9bfef6fb3cdf26345882c408d0d9302e0a2be8084ba1cb67710318b3be0ebf76

See more details on using hashes here.

Provenance

The following attestation bundles were made for pqcrypto-1.0.0-cp39-abi3-win_amd64.whl:

Publisher: ci.yml on backbone-hq/pqcrypto

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pqcrypto-1.0.0-cp39-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for pqcrypto-1.0.0-cp39-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 9160e59a8b9a860ea960a0b2fb8b479ee2d56f3c062c4be3f86ce346807443dd
MD5 15dbe6cdb5693b278f6491a0de635d05
BLAKE2b-256 b82248c29acd771fa55b26e20b66df194a6a63166cf4b5cffba7c4d59ffc66b0

See more details on using hashes here.

Provenance

The following attestation bundles were made for pqcrypto-1.0.0-cp39-abi3-musllinux_1_2_x86_64.whl:

Publisher: ci.yml on backbone-hq/pqcrypto

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pqcrypto-1.0.0-cp39-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for pqcrypto-1.0.0-cp39-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 f8c29900937b84ce18943694acb7276af36e2c52e1673debe02ecf9494472a35
MD5 9ced0ddc6325aca47eb522571d478073
BLAKE2b-256 8dc8fd11c1e4ebbc019274843f170e23907553fd8b9a30c9c33b2cc02fcf3a60

See more details on using hashes here.

Provenance

The following attestation bundles were made for pqcrypto-1.0.0-cp39-abi3-musllinux_1_2_aarch64.whl:

Publisher: ci.yml on backbone-hq/pqcrypto

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pqcrypto-1.0.0-cp39-abi3-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for pqcrypto-1.0.0-cp39-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 7068532dbc1225a9d668d59940bd96dc13f40175a757b2e31c69aa697781f4d0
MD5 a6f274d6572352dc7078c172b52a07fa
BLAKE2b-256 c6c2965a137eef8d95f9cf25c3dbe935540cff303c272ee045dc9f110bd206d8

See more details on using hashes here.

Provenance

The following attestation bundles were made for pqcrypto-1.0.0-cp39-abi3-manylinux_2_34_x86_64.whl:

Publisher: ci.yml on backbone-hq/pqcrypto

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pqcrypto-1.0.0-cp39-abi3-manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for pqcrypto-1.0.0-cp39-abi3-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 71b199d6460a646071cdb505e6acca8c9a050c3252bba023b8065b9518dce9c9
MD5 93b92053875d321364bf01d275563eaf
BLAKE2b-256 e9920876f27be9289cdf87bcef5dbcbc42d89eacfd6ecb99f23928ef3a21a700

See more details on using hashes here.

Provenance

The following attestation bundles were made for pqcrypto-1.0.0-cp39-abi3-manylinux_2_34_aarch64.whl:

Publisher: ci.yml on backbone-hq/pqcrypto

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pqcrypto-1.0.0-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pqcrypto-1.0.0-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ccc13a4443a499d70aa9d29ce899e8782d4a5e57b79baa92fa13ea33512533c7
MD5 fc7cce160e8e9860194a14afbb564085
BLAKE2b-256 50f2790da887e9167e4bc3d41e470c7ad1cd90df90c66e2da8b3d11f284c37f0

See more details on using hashes here.

Provenance

The following attestation bundles were made for pqcrypto-1.0.0-cp39-abi3-macosx_11_0_arm64.whl:

Publisher: ci.yml on backbone-hq/pqcrypto

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pqcrypto-1.0.0-cp39-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for pqcrypto-1.0.0-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 3c0aa8346222631418e7caac040a53cc1f5245553d3275ce1d8403cfe8dd9fb4
MD5 499f810a0ab086ddc8526442f4c01ab5
BLAKE2b-256 d561bdddb98d0d19c8177c4bcb4e9a75762ee81b7518eef9f69f0b5018873101

See more details on using hashes here.

Provenance

The following attestation bundles were made for pqcrypto-1.0.0-cp39-abi3-macosx_10_12_x86_64.whl:

Publisher: ci.yml on backbone-hq/pqcrypto

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

1.0.0 This release

8 files

0.4.0

49 files

0.3.4

65 files

0.3.3

65 files

0.3.2

65 files

0.3.1

50 files

0.3.0

20 files

0.1.3

1 file

0.1.2

1 file

0.1.0

1 file

Supported by

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