hpqc (Python)
A Python port of selected primitives from
katzenpost/hpqc, the hybrid
post-quantum cryptography library used by the Katzenpost mix
network. The Go implementation is the reference; this Python
package covers BACAP, MKEM, and the NIKE primitives those depend
on, so Python applications and tooling can perform these
operations directly. The shared JSON test vectors under
testvectors/ keep the Python and Go ports byte-identical.
For the rationale behind BACAP and a short overview of the construction, see the BACAP section of the main README. For a fuller treatment, see §4 of the Echomix paper. For the full catalogue of NIKE, KEM, and signature schemes that hpqc implements in Go, see the main repository README.
What is ported
- BACAP (
hpqc.bacap): blinding-and-capability scheme. Stateless API (immutableMessageBoxIndex,WriteCap,ReadCap) plus stateful reader/writer wrappers. Encrypt, decrypt, sign, verify, and tombstones are all covered. - MKEM (
hpqc.kem.mkem): multi-recipient KEM construction over any NIKE. - NIKE abstractions (
hpqc.nike.scheme):Scheme,PublicKey,PrivateKeybase classes mirroring the Go interfaces. - NIKE primitives: X25519 (
hpqc.nike.x25519), CTIDH at field sizes 511, 512, 1024, and 2048 (hpqc.nike.ctidh{511,512,1024,2048}, via the upstreamhighctidhpackage), and a genericHybridNIKEcombiner (hpqc.nike.hybrid). - Ed25519 signature verification (
hpqc.sign.ed25519): the blinded Ed25519 variant on which BACAP relies, plus anEd25519Schemeverify-only wrapper for plain Ed25519. - Falcon-padded-512 signature verification
(
hpqc.sign.falcon.FalconPadded512Scheme), backed by thepqcryptoruntime dependency, which vendors the same PQClean reference C used by the Go side. - Hybrid signature verification (
hpqc.sign.hybrid): generic two-component combiner plus a pre-registeredFalconPadded512Ed25519instance.
The Python and Go test suites read the same JSON vector files via
per-file symlinks under tests/.../vectors/, so any byte-level
divergence between the two ports trips a failing assertion on
whichever side runs first.
Installation
pip install hpqc
Runtime dependencies (pynacl, cryptography, cbor2,
highctidh, pqcrypto) are pulled in automatically.
To install from a source checkout instead (for example to test an unreleased change):
pip install -e /path/to/hpqc/py
Quick start
A BACAP round-trip:
from hpqc.bacap import WriteCap
writer = WriteCap.generate()
reader = writer.read_cap()
ctx = b"my-application/v1"
mbi = writer.first_message_box_index
box_id, ciphertext, signature = mbi.encrypt_for_context(
writer, ctx, b"hello, pigeonhole"
)
# Anyone holding the read cap can verify and decrypt:
plaintext = mbi.decrypt_for_context(box_id, ctx, ciphertext, signature)
assert plaintext == b"hello, pigeonhole"
Encapsulating a payload to multiple recipients with MKEM:
from hpqc.kem.mkem import MKEMScheme
from hpqc.nike.x25519 import X25519
mkem = MKEMScheme(X25519())
alice_pk, alice_sk = mkem.generate_keypair()
bob_pk, bob_sk = mkem.generate_keypair()
eph_priv, ct = mkem.encapsulate([alice_pk, bob_pk], b"secret payload")
assert mkem.decapsulate(alice_sk, ct) == b"secret payload"
assert mkem.decapsulate(bob_sk, ct) == b"secret payload"
Running the tests
cd hpqc/py
python3 -m venv .venv
source .venv/bin/activate
pip install -e ".[test]"
pytest
Cross-language vector tests live under tests/bacap/, tests/kem/,
and tests/sign/. They symlink into the canonical JSON vectors under
../testvectors/, which the Go test suite also consumes.
License
AGPL-3.0-only. See LICENSE.
See also
- Main repository README — full Go reference, design notes, and tables of every NIKE, KEM, and signature scheme that hpqc implements.
- Echomix paper — the design of BACAP (§4) and Pigeonhole (§5).
- Katzenpost mix network — the system this library serves.
Release files for hpqc 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 | |
|---|---|---|---|
| hpqc-0.0.2.tar.gz | 41.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| hpqc-0.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 83.9 kB
Release files / hpqc-0.0.2.tar.gz
| Download URL | hpqc-0.0.2.tar.gz |
|---|---|
| Size | 41.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
65df1d76dd9f742fa4603c1d64e0b23e25bea7daaf191284151b6daa4c6d00f4
|
|
BLAKE2b-256 checksum How to use checksums |
4e86ef1d332e08e2bf3f652941dd766e41db39f467312d25733f819620f8176d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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 May 15, 2026.
Transparency logRelease files / hpqc-0.0.2-py3-none-any.whl
| Download URL | hpqc-0.0.2-py3-none-any.whl |
|---|---|
| Size | 42.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8855707c653d495713ec84597de949ec6e437166c0e621f05125f3ed52563a5e
|
|
BLAKE2b-256 checksum How to use checksums |
ff99a3044fab904031bc2bb64f70725eea2b7d1c19fff063a98302445b84de32
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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 May 15, 2026.
Transparency log