# pqbox
A post-quantum crypto toolkit with a Rust core and bindings for Python and JavaScript. It covers
hybrid key encapsulation, sealed boxes, composite signatures, authenticated encryption, key
derivation, hashing and password hashing.
pqbox implements no cryptographic primitive itself. Every algorithm comes from a pinned crate,
mostly from [RustCrypto](https://github.com/RustCrypto), plus Cryspen's formally verified
[libcrux](https://github.com/cryspen/libcrux) for ML-KEM-1024 and `classic-mceliece-rust` for
Classic McEliece. pqbox only adds the hybrid combiners, the composite signature framing and a versioned
wire format.
- **Rust:** crate [`pqbox`](crates/pqbox-core) (sans-IO, `#![forbid(unsafe_code)]`) and the CLI [`pqbox-cli`](crates/pqbox-cli).
- **Python:** package `pqbox` on PyPI, built with PyO3 (abi3, Python ≥ 3.10).
- **JavaScript / TypeScript:** package `pqbox` on npm, built with WebAssembly (Node ≥ 20 and browsers, ESM, synchronous API).
Website: <https://maxgfr.github.io/pqbox/>. Applications that use pqbox follow one integration
guide, [`docs/INTEGRATION.md`](docs/INTEGRATION.md): which function for which job, labels and
format versions, key storage, and an audit checklist.
## Suites
Every key, ciphertext, sealed box and signature records its suite in its header, so objects from
different suites can never be mixed.
| `0x02` | **`pqbox-max`** (default) | ML-KEM-1024 + ECDH P-384 | ML-DSA-87 + ECDSA P-384 (SHA-384) | Everything, unless you have a reason below |
| `0x03` | `pqbox-paranoid` (experimental, not recommended for new keys) | ML-KEM-1024 + Classic McEliece 8192128 + ECDH P-384 | ML-DSA-87 + SLH-DSA-SHAKE-256s + ECDSA P-384 | Reading and using existing paranoid keys and archives. Not for new keys: see [Classic McEliece](#classic-mceliece-not-recommended-for-new-keys) |
| `0x01` | `xwing` (compat only) | X-Wing (ML-KEM-768 + X25519) | ML-DSA-65 + Ed25519 | Interop with X-Wing tooling such as hush. Never the default |
**Suite policy.** The functions that read keys, ciphertexts, signatures and sealed boxes accept
`pqbox-max` objects only. `xwing` and `pqbox-paranoid` objects are refused with
`SuiteNotAllowed` unless the caller allows their suite explicitly, so an attacker cannot steer a
caller onto a suite it did not choose (for instance by handing over an `xwing` public key):
- Rust: `from_bytes_with_policy` and `open_with_policy` with a `SuitePolicy` such as
`SuitePolicy::DEFAULT.allow(Suite::XWing)` (`from_bytes` and `open` use `SuitePolicy::DEFAULT`);
- Python: the keyword-only `allow_suites=["xwing"]` argument;
- JavaScript: the `{ allowSuites: ["xwing"] }` option;
- CLI: `--allow-suite xwing` (repeatable) on `seal`, `open`, `sign` and `verify`.
Key generation takes the suite by name and needs no policy.
**The `paranoid` feature.** `pqbox-paranoid` is **experimental**: its SLH-DSA half comes from
`slh-dsa` 0.2.0-rc.5, a release candidate. The Rust crates compile it only with the `paranoid`
cargo feature, off by default (`cargo add pqbox --features paranoid`,
`cargo install --locked pqbox-cli --features paranoid`); without it, paranoid objects are refused with
`SuiteNotEnabled`. The Python wheels and the npm package include it: it adds about 66 KB to a
wheel (542 KB to 608 KB, macOS arm64) and about 67 KB to the WebAssembly module (801 KB to 868 KB
before wasm-bindgen).
#### Classic McEliece: not recommended for new keys
BSI's [Notes on recent developments concerning Classic McEliece](https://www.bsi.bund.de/SharedDocs/Downloads/EN/BSI/Crypto/Notes_Classic_McEliece.html)
(1 October 2026) say Classic McEliece should no longer be used in new developments. Structural
attacks have improved fast in 2026, among them a quasipolynomial distinguisher with a heuristic key
recovery ([ePrint 2026/1630](https://eprint.iacr.org/2026/1630)) and an improved heuristic key
recovery ([ePrint 2026/1984](https://eprint.iacr.org/2026/1984)). None is practical against the
recommended parameter sets, and BSI expects further progress. For pqbox:
- `pqbox-paranoid` objects stay readable and usable, and the format does not change.
- Do not create new `pqbox-paranoid` KEM keys: use `pqbox-max`.
- The paranoid KEM is still a hybrid: its shared secret holds as long as ML-KEM-1024 or P-384
holds. What Classic McEliece no longer reliably adds is protection against a break of lattices.
The paranoid signatures (SLH-DSA) are not affected.
- Replacing Classic McEliece with HQC or FrodoKEM, which BSI recommends instead, would change the
bytes, so it would need a new suite id. The `0x03` suite stays as it is.
**Hybrid rationale.** A hybrid stays secure as long as one of its components holds. KEM shared
secrets go through a combiner, so recovering the session key means breaking every component.
A composite signature verifies only if every component signature verifies.
- `pqbox-max` rests on ML-KEM-1024 and ML-DSA-87 (NIST category 5). The classical half is defense
in depth: if elliptic-curve cryptography (or RSA) were broken outright, security would still rest
on ML-KEM-1024 and ML-DSA-87. The classical half is P-384 rather than X25519 or Ed25519. P-384 is a
stronger classical fallback, and it is the curve the NSA's December 2, 2026 advisory (PP-26-4956)
keeps as an interim choice. That advisory lists elliptic curves other than P-384/P-521, and
EdDSA, among the algorithms to inventory and replace. Some cryptographers read it as a sign that
256-bit curves may be weaker than believed. The advisory itself does not say they are broken.
- `pqbox-paranoid` was meant to also survive a break of lattice cryptography: Classic McEliece
(code-based) and SLH-DSA (hash-based) do not rely on lattices. Recent attacks on Classic McEliece
weaken that for its KEM (see [above](#classic-mceliece-not-recommended-for-new-keys)); its
signatures are not affected.
- `xwing` exists only for compatibility. Its classical half is a 256-bit curve, so treat its
security as resting entirely on ML-KEM-768 and ML-DSA-65.
The `pqbox-max` and `pqbox-paranoid` KEM combiners are modeled on X-Wing but are **not**
IETF-standardized:
```text
pqbox-max: ss = SHA3-256(ss_mlkem ‖ ss_p384 ‖ ct_p384 ‖ pk_p384 ‖ "pqbox/v1/kem-max")
pqbox-paranoid: ss = SHA3-256(ss_mlkem ‖ ss_mceliece ‖ ss_p384 ‖ ct_p384 ‖ pk_p384
‖ SHA3-256(ct_mlkem) ‖ SHA3-256(ct_mceliece) ‖ "pqbox/v1/kem-paranoid")
```
Signatures follow the IETF composite ML-DSA draft (draft-ietf-lamps-pq-composite-sigs-19): the
message representative is `"CompositeAlgorithmSignatures2025" ‖ Label ‖ len(ctx) ‖ ctx ‖ SHA-512(M)`,
using the draft's labels for `xwing` and `pqbox-max` and a pqbox-specific label for
`pqbox-paranoid`. The deviations are documented in [`sign.rs`](crates/pqbox-core/src/sign.rs):
pqbox's own encodings instead of ASN.1, a fixed-length low-`s` ECDSA `r‖s`, and the signer's key
fingerprint bound in `ctx`.
Composite signatures are **strongly unforgeable** (SUF-CMA): nobody can produce a second valid
signature of a message that was signed, not just a signature of a new message. Every component
has a single valid encoding per signing operation: ML-DSA and SLH-DSA are designed to be strongly
unforgeable, Ed25519 is verified strictly, and the ECDSA `s` must be in the lower half of the group
order (signing normalizes it; the malleable `n - s` twin is refused).
## Algorithms
| KEM | ML-KEM-1024 (FIPS 203), in `pqbox-max` and `pqbox-paranoid` | `libcrux-ml-kem` 0.0.12 (portable build, SIMD code not compiled) |
| KEM | ML-KEM-768 (FIPS 203), inside X-Wing | `ml-kem` 0.3.4 |
| KEM | X-Wing (draft-connolly-cfrg-xwing-kem) | `x-wing` 0.1.1 |
| KEM | Classic McEliece 8192128 | `classic-mceliece-rust` 3.1.0 |
| KEM (classical half) | ECDH P-384, X25519 | `p384` 0.14.0, `x25519-dalek` 3.0.0 (both with fiat-crypto field arithmetic) |
| Signature | ML-DSA-65 / ML-DSA-87 (FIPS 204) | `ml-dsa` 0.1.2 |
| Signature | SLH-DSA-SHAKE-256s (FIPS 205), `paranoid` feature only, experimental | `slh-dsa` 0.2.0-rc.5 (release candidate) |
| Signature (classical half) | ECDSA P-384 with SHA-384, Ed25519 | `p384` 0.14.0, `ed25519-dalek` 3.0.0 (both with fiat-crypto field arithmetic) |
| Sealed box | suite KEM + HKDF-SHA-256 + XChaCha20-Poly1305 | |
| AEAD | XChaCha20-Poly1305 (default), AES-256-GCM | `chacha20poly1305` 0.11.0, `aes-gcm` 0.11.1 |
| KDF / MAC | HKDF-SHA-256, HMAC-SHA-256 | `hkdf` 0.13.0, `hmac` 0.13.0 |
| Hash | SHA-256, SHA3-256, BLAKE3 | `sha2` 0.11.1, `sha3` 0.12.0, `blake3` 1.8.9 |
| Password | Argon2id (64 MiB, t=3, p=1 by default; verification and key derivation capped at 256 MiB, t=10, p=8): PHC strings, and keys derived from a password and a stored salt | `argon2` 0.6.0 |
Symmetric keys are always 256-bit.
## Sizes and timings
Sizes are of serialized objects and include the 6-byte header. Timings are medians from
`cargo bench -p pqbox` (criterion, release build) on an Apple M5 laptop (rustc 1.99.0); they
show orders of magnitude, not guarantees.
| `xwing` | 1,222 B | 38 B | 1,126 B | 1,166 B | 1,990 B | 70 B | 3,379 B |
| `pqbox-max` | 1,671 B | 118 B | 1,671 B | 1,711 B | 2,695 B | 86 B | 4,729 B |
| `pqbox-paranoid` | 1,359,495 B | 1,372,094 B | 1,879 B | 1,919 B | 2,759 B | 214 B | 34,521 B |
| `xwing` | 53 µs | 50 µs | 80 µs | 54 µs | 83 µs | 264 µs | 378 µs | 61 µs |
| `pqbox-max` | 311 µs | 607 µs | 642 µs | 595 µs | 601 µs | 730 µs | 775 µs | 446 µs |
| `pqbox-paranoid` | 966.99 ms | 1.13 ms | 62.03 ms | 2.37 ms | 62.98 ms | 37.48 ms | 435.01 ms | 1.06 ms |
Paranoid KEM key generation varies a lot from run to run (0.74 s to 1.20 s here), because Classic
McEliece retries until it finds a usable key. In WebAssembly under Node 24, the paranoid KEM key
generation took 6.5 to 11.6 s. Symmetric primitives on 64 KiB:
XChaCha20-Poly1305 62 µs, AES-256-GCM 14 µs, SHA-256 20 µs, SHA3-256 59 µs, BLAKE3 26 µs.
## Install
```sh
cargo add pqbox # Rust library (add `--features paranoid` for pqbox-paranoid)
cargo install --locked pqbox-cli # `pqbox` command (same feature)
pip install pqbox # Python ≥ 3.10
npm install pqbox # Node ≥ 20, browsers
```
**Build options.** The CLI binaries, the wheels and the npm package are built with the
repository's [`.cargo/config.toml`](.cargo/config.toml): P-384 and Curve25519 use the formally
verified field arithmetic synthesized by [fiat-crypto](https://github.com/mit-plv/fiat-crypto)
(the same bytes as the default backends, checked by the frozen KATs), and only the portable code
of libcrux is compiled (see [docs/BACKENDS.md](docs/BACKENDS.md)). `cargo install`, `cargo add`
and a build from the Python sdist do not read that file; to build the same way, set:
```sh
RUSTFLAGS='--cfg p384_backend="fiat" --cfg curve25519_dalek_backend="fiat"' \
LIBCRUX_DISABLE_SIMD128=1 LIBCRUX_DISABLE_SIMD256=1 \
cargo install --locked pqbox-cli
```
Each GitHub release also carries prebuilt `pqbox` binaries, `pqbox-<target>` for macOS (arm64,
x86_64) and Linux (arm64, x86_64), with a `SHA256SUMS` file. `pqbox --version` reports the release,
and `pqbox selftest` checks the installed binary offline.
Every release asset made after v1.1.0 (binaries, wheels, sdist, npm tarball and `SHA256SUMS`) also
has a signed build provenance attestation. Check a download with the GitHub CLI (see
[RELEASING.md](RELEASING.md#verify-a-release)):
```sh
gh attestation verify pqbox-aarch64-apple-darwin -R maxgfr/pqbox
```
## Examples
### Rust
```rust
use pqbox::{Suite, SuitePolicy, aead, kem, password, seal, sign};
use rand_core::UnwrapErr;
let mut rng = UnwrapErr(getrandom::SysRng); // getrandom 0.4 with the `sys_rng` feature
// Sealed box to a recipient (default suite: pqbox-max). The plaintext is wiped on drop.
let recipient = kem::SecretKey::generate(Suite::default(), &mut rng)?;
let sealed = seal::seal(recipient.public_key(), b"hello", &mut rng)?;
assert_eq!(*seal::open(&recipient, &sealed)?, b"hello");
// Composite signature: every component must verify.
let signer = sign::SecretKey::generate(Suite::Max, &mut rng)?;
let sig = signer.sign(b"release v1.2.3", &mut rng)?;
signer.public_key().verify(b"release v1.2.3", &sig)?;
// Keys serialize with a versioned header. Parsers accept pqbox-max only by default.
let bytes = recipient.public_key().to_bytes();
assert_eq!(kem::PublicKey::from_bytes(&bytes)?.to_bytes(), bytes);
// Other suites must be allowed explicitly.
let legacy = kem::SecretKey::generate(Suite::XWing, &mut rng)?;
let bytes = legacy.public_key().to_bytes();
assert!(kem::PublicKey::from_bytes(&bytes).is_err()); // SuiteNotAllowed
let policy = SuitePolicy::DEFAULT.allow(Suite::XWing);
let pk = kem::PublicKey::from_bytes_with_policy(&bytes, policy)?;
// A key derived from a password: store the salt (and the costs) with the data, and derive the
// same key again later. Argon2id, 64 MiB, 3 passes, 1 lane by default; the key is wiped on drop.
let salt = password::generate_salt(&mut rng);
let key = password::derive_key(b"correct horse battery staple", &salt, password::Params::default(), 32)?;
let ct = aead::encrypt(aead::Algorithm::XChaCha20Poly1305, key.as_bytes(), b"data", b"header", &mut rng)?;
# Ok::<(), pqbox::Error>(())
```
### Python
```python
import pqbox
pk, sk = pqbox.kem_keygen() # "pqbox-max"
box = pqbox.seal(pk, b"hello")
assert pqbox.open(sk, box) == b"hello"
spk, ssk = pqbox.sign_keygen()
sig = pqbox.sign(ssk, b"release v1.2.3")
assert pqbox.verify(spk, b"release v1.2.3", sig)
# Suites other than pqbox-max are read only when allowed explicitly.
apk, ask = pqbox.sign_keygen("pqbox-paranoid")
sig = pqbox.sign(ask, b"archive", allow_suites=["pqbox-paranoid"])
assert pqbox.verify(apk, b"archive", sig, allow_suites=["pqbox-paranoid"])
key = pqbox.generate_key()
ct = pqbox.encrypt(key, b"data", aad=b"header")
assert pqbox.decrypt(key, ct, aad=b"header") == b"data"
phc = pqbox.password_hash("correct horse battery staple")
assert pqbox.password_verify("correct horse battery staple", phc)
# A key derived from a password and a stored salt (Argon2id, same defaults as password_hash).
salt = pqbox.password_generate_salt() # 16 random bytes: store them with the data
key = pqbox.password_derive_key("correct horse battery staple", salt) # 32 bytes
assert pqbox.password_derive_key("correct horse battery staple", salt) == key
```
### JavaScript / TypeScript
```ts
import { kemKeygen, seal, open, signKeygen, sign, verify, blake3, passwordDeriveKey, passwordGenerateSalt } from "pqbox";
const { publicKey, secretKey } = kemKeygen(); // "pqbox-max"
const box = seal(publicKey, new TextEncoder().encode("hello"));
console.log(new TextDecoder().decode(open(secretKey, box)));
const signer = signKeygen("pqbox-max");
const msg = new TextEncoder().encode("release v1.2.3");
const sig = sign(signer.secretKey, msg);
console.log(verify(signer.publicKey, msg, sig)); // true
console.log(blake3(msg));
// Suites other than pqbox-max are read only when allowed explicitly.
const legacy = kemKeygen("xwing");
const box2 = seal(legacy.publicKey, msg, { allowSuites: ["xwing"] });
open(legacy.secretKey, box2, { allowSuites: ["xwing"] });
// A key derived from a password and a stored salt (Argon2id, same defaults as passwordHash).
const salt = passwordGenerateSalt(); // 16 random bytes: store them with the data
const key = passwordDeriveKey("correct horse battery staple", salt); // 32 bytes
```
Errors are thrown as `PqboxError` (in Python, raised as `pqbox.PqboxError`, a `ValueError`). They
carry a stable `code` such as `Decrypt`, `BadSignature`, `SuiteMismatch`, `SuiteNotAllowed` or
`UnsupportedVersion`.
### CLI
```sh
pqbox keygen kem -o alice # alice.pub, alice.sec (0600), suite pqbox-max
pqbox seal --to alice.pub -i secret.txt -o secret.box
pqbox open --key alice.sec -i secret.box
pqbox keygen sign -o release
pqbox sign --key release.sec -i dist.tar -o dist.tar.sig
pqbox verify --key release.pub --sig dist.tar.sig -i dist.tar # exit 0 if valid, 1 if not
# Other suites must be allowed when their objects are read (paranoid needs `--features paranoid`).
pqbox keygen kem --suite xwing -o legacy
pqbox seal --allow-suite xwing --to legacy.pub -i secret.txt -o secret.box
pqbox hash --alg blake3 -i dist.tar
pqbox info alice.pub
pqbox selftest # offline, well under a second; exit 0 if every check passes
pqbox selftest --json
```
`selftest` runs a seal/open and a sign/verify round trip for `pqbox-max` and `xwing`, checks that
a tampered box and a tampered signature are refused, and replays the frozen known answers built
into the binary (the `xwing` and `pqbox-max` entries of
[`tests/vectors/pqbox/kat.json`](crates/pqbox-core/tests/vectors/pqbox/kat.json)).
Keys, boxes and signatures are base64 text by default, or raw bytes with `--raw`. Both forms are
accepted as input.
Secret keys and decrypted plaintext written to a file get mode 0600 on Unix. Every file is written
atomically (a temporary file in the same directory, flushed, then renamed into place), so
`keygen --force` or `open -o` over an existing world-readable file never leaves the secret readable
by others.
## Wire format
Every object is `"PQB" ‖ version (0x02) ‖ type ‖ suite ‖ body`. Types: KEM public key `0x01`,
KEM secret key `0x02`, KEM ciphertext `0x03`, signing public key `0x11`, signing secret key
`0x12`, signature `0x13`, sealed box `0x21`, AEAD ciphertext `0x31` (where the suite byte is the
cipher: `0x01` XChaCha20-Poly1305, `0x02` AES-256-GCM). Parsers dispatch on the version and
reject unknown versions with `UnsupportedVersion`, so future versions can be added while older
objects stay readable. Version 2 is the first released format; the pre-release version 1 is not
read. A `pqbox-paranoid` KEM secret key ends with the fingerprint (SHA3-256) of its whole public
key, checked when it is parsed, so an embedded McEliece public key that does not belong to the key
is refused. The body layouts are documented in [`format.rs`](crates/pqbox-core/src/format.rs),
[`kem.rs`](crates/pqbox-core/src/kem.rs), [`sign.rs`](crates/pqbox-core/src/sign.rs) and
[`seal.rs`](crates/pqbox-core/src/seal.rs).
## Testing
- Official vectors only (see [`tests/vectors/README.md`](crates/pqbox-core/tests/vectors/README.md)):
- X-Wing draft vectors;
- IETF LAMPS ML-KEM/ML-DSA examples;
- NIST ACVP SLH-DSA-SHAKE-256s;
- Wycheproof for XChaCha20-Poly1305, AES-GCM, HKDF, HMAC, Ed25519, X25519, ECDH and ECDSA P-384, ML-KEM (key generation, decapsulation, and encapsulation through pqbox's own key parser) and ML-DSA (verification and signing);
- the RFC vectors.
- Frozen pqbox known answers for the combiners, sealed boxes and composite signatures of every suite, generated once and checked in Rust, Python and JavaScript.
- Negative tests for every suite: truncation, extension, bit flips in every field, wrong version, suite or type bytes, degenerate X25519 and P-384 keys, and each signature component failing on its own.
- Property tests (proptest), cargo-fuzz targets for every parser plus round trips, and criterion benches.
- Instruction-count benchmarks ([gungraun](https://github.com/gungraun/gungraun), under Callgrind) of `pqbox-max` and the AEADs: every pull request is measured against its base branch, and CI fails if any benchmark runs more than 10% more instructions.
- A cross-language interop matrix ([`scripts/interop.sh`](scripts/interop.sh)): keys from Rust, Python and JavaScript seal and sign for each other, in every suite.
## Security notes
- **The post-quantum crates are not independently audited.** `ml-kem`, `ml-dsa`, `x-wing` and
`slh-dsa` (a release candidate) come from RustCrypto, which has not had them audited, and
`classic-mceliece-rust` is a community crate. `libcrux-ml-kem` (ML-KEM-1024) is partly formally
verified (panic freedom and functional correctness of most of its code, not constant time; see
[docs/BACKENDS.md](docs/BACKENDS.md)) but has no public audit either. pqbox itself has not been
audited.
- **Why bother now: harvest now, decrypt later.** No practical break of RSA is publicly known, and
no cryptographically relevant quantum computer is known to exist. Data recorded today, however,
can be decrypted whenever one appears. Hybrids protect it against that while keeping a classical
safety net.
- **Password hash limits.** The costs in a PHC string come from whoever wrote it, so
`verify_password` (Python `password_verify`, JavaScript `passwordVerify`) refuses strings above
256 MiB, 10 passes or 8 lanes before allocating anything; `hash_password` holds itself to the
same limits. At the limits one verification takes 256 MiB and about a second of CPU. To accept
more expensive hashes from a trusted source, raise the limits explicitly:
`verify_password_with_limits` in Rust, `max_m_cost`/`max_t_cost`/`max_p_cost` in Python,
`{ maxMCost, maxTCost, maxPCost }` in JavaScript.
- **Keys derived from passwords.** `password::derive_key` (Python `password_derive_key`,
JavaScript `passwordDeriveKey`) is plain Argon2id (version 0x13, no secret, no associated
data), so it matches other Argon2 libraries given the same inputs. It needs a salt of at least
16 bytes (`generate_salt` makes one; store it, and the costs, next to the data) and derives 16
to 64 bytes, 32 by default. The costs default to 64 MiB, 3 passes and 1 lane, and are held to
the same limits as verification, with the same opt-in to raise them. Choose the highest memory
cost your slowest target can afford (RFC 9106 suggests 64 MiB with 3 passes when 2 GiB is too
much), and never lower the costs of existing data. There is no context input: keep keys for
different purposes apart with distinct salts, or derive one key and expand it with HKDF-SHA-256
using one `info` label per purpose.
- **AES-256-GCM nonce limit.** `encrypt` draws a random nonce per message. AES-256-GCM's nonce is
96 bits, so encrypt at most about 2^32 messages under one key (NIST SP 800-38D) and rotate it
after that. XChaCha20-Poly1305, the default, has a 192-bit nonce and no practical limit: prefer
it for long-lived keys. Sealed boxes use XChaCha20-Poly1305 with a fresh key each time.
- Sealed boxes are anonymous; they do not authenticate the sender. Sign the plaintext if the
recipient needs to know who sent it.
- Read [THREAT_MODEL.md](THREAT_MODEL.md) for what is and is not protected, and
[SECURITY.md](SECURITY.md) to report a vulnerability.
## Upstream
pqbox stands on these projects. The versions are pinned in the `Cargo.toml` files (exactly, with
`=`, for every cryptographic crate); Dependabot proposes updates, and a daily
[upstream watch](.github/workflows/upstream-watch.yml) reports advisories, new releases and
alternatives ([`scripts/watch/`](scripts/watch)). [`docs/BACKENDS.md`](docs/BACKENDS.md) compares
the backends with the alternatives (RustCrypto, libcrux and AWS-LC), and explains the move of
ML-KEM-1024 to libcrux.
### Cryptography (crate `pqbox`)
| `libcrux-ml-kem` | ML-KEM-1024 (`pqbox-max`, `pqbox-paranoid`), portable build; formally verified with [hax](https://github.com/cryspen/hax) and F* ([verification status](https://github.com/cryspen/libcrux/blob/libcrux-ml-kem-v0.0.12/libcrux-ml-kem/proofs/verification_status.md)) | [cryspen/libcrux](https://github.com/cryspen/libcrux/tree/main/libcrux-ml-kem) | [libcrux-ml-kem](https://crates.io/crates/libcrux-ml-kem) | [FIPS 203](https://csrc.nist.gov/pubs/fips/203/final) |
| `ml-kem` | ML-KEM-768 (inside X-Wing) | [RustCrypto/KEMs](https://github.com/RustCrypto/KEMs/tree/master/ml-kem) | [ml-kem](https://crates.io/crates/ml-kem) | [FIPS 203](https://csrc.nist.gov/pubs/fips/203/final) |
| `x-wing` | X-Wing KEM (`xwing` suite) | [RustCrypto/KEMs](https://github.com/RustCrypto/KEMs/tree/master/x-wing) | [x-wing](https://crates.io/crates/x-wing) | [draft-connolly-cfrg-xwing-kem](https://datatracker.ietf.org/doc/draft-connolly-cfrg-xwing-kem/) |
| `classic-mceliece-rust` | Classic McEliece 8192128 (`paranoid`) | [Colfenor/classic-mceliece-rust](https://github.com/Colfenor/classic-mceliece-rust) | [classic-mceliece-rust](https://crates.io/crates/classic-mceliece-rust) | [Classic McEliece NIST submission](https://classic.mceliece.org/nist.html) |
| `ml-dsa` | ML-DSA-65 / ML-DSA-87 | [RustCrypto/signatures](https://github.com/RustCrypto/signatures/tree/master/ml-dsa) | [ml-dsa](https://crates.io/crates/ml-dsa) | [FIPS 204](https://csrc.nist.gov/pubs/fips/204/final) |
| `slh-dsa` | SLH-DSA-SHAKE-256s (`paranoid`) | [RustCrypto/signatures](https://github.com/RustCrypto/signatures/tree/master/slh-dsa) | [slh-dsa](https://crates.io/crates/slh-dsa) | [FIPS 205](https://csrc.nist.gov/pubs/fips/205/final) |
| `p384` | ECDH and ECDSA P-384 (classical half of `pqbox-max`) | [RustCrypto/elliptic-curves](https://github.com/RustCrypto/elliptic-curves/tree/master/p384) | [p384](https://crates.io/crates/p384) | [FIPS 186-5](https://csrc.nist.gov/pubs/fips/186-5/final) (ECDSA), [SP 800-56A Rev. 3](https://csrc.nist.gov/pubs/sp/800/56/a/r3/final) (ECDH), [SP 800-186](https://csrc.nist.gov/pubs/sp/800/186/final) (the curve) |
| `x25519-dalek` | X25519 (inside X-Wing) | [dalek-cryptography/curve25519-dalek](https://github.com/dalek-cryptography/curve25519-dalek/tree/main/x25519-dalek) | [x25519-dalek](https://crates.io/crates/x25519-dalek) | [RFC 7748](https://www.rfc-editor.org/rfc/rfc7748) |
| `ed25519-dalek` | Ed25519 (classical half of `xwing` signatures) | [dalek-cryptography/curve25519-dalek](https://github.com/dalek-cryptography/curve25519-dalek/tree/main/ed25519-dalek) | [ed25519-dalek](https://crates.io/crates/ed25519-dalek) | [RFC 8032](https://www.rfc-editor.org/rfc/rfc8032) |
| `chacha20poly1305` | XChaCha20-Poly1305 (AEAD, sealed boxes) | [RustCrypto/AEADs](https://github.com/RustCrypto/AEADs/tree/master/chacha20poly1305) | [chacha20poly1305](https://crates.io/crates/chacha20poly1305) | [RFC 8439](https://www.rfc-editor.org/rfc/rfc8439), [draft-irtf-cfrg-xchacha](https://datatracker.ietf.org/doc/draft-irtf-cfrg-xchacha/) |
| `aes-gcm` | AES-256-GCM | [RustCrypto/AEADs](https://github.com/RustCrypto/AEADs/tree/master/aes-gcm) | [aes-gcm](https://crates.io/crates/aes-gcm) | [FIPS 197](https://csrc.nist.gov/pubs/fips/197/final), [SP 800-38D](https://csrc.nist.gov/pubs/sp/800/38/d/final) |
| `hkdf` | HKDF-SHA-256 | [RustCrypto/KDFs](https://github.com/RustCrypto/KDFs/tree/master/hkdf) | [hkdf](https://crates.io/crates/hkdf) | [RFC 5869](https://www.rfc-editor.org/rfc/rfc5869) |
| `hmac` | HMAC-SHA-256 | [RustCrypto/MACs](https://github.com/RustCrypto/MACs/tree/master/hmac) | [hmac](https://crates.io/crates/hmac) | [RFC 2104](https://www.rfc-editor.org/rfc/rfc2104), [FIPS 198-1](https://csrc.nist.gov/pubs/fips/198-1/final) |
| `sha2` | SHA-256, SHA-384, SHA-512 | [RustCrypto/hashes](https://github.com/RustCrypto/hashes/tree/master/sha2) | [sha2](https://crates.io/crates/sha2) | [FIPS 180-4](https://csrc.nist.gov/pubs/fips/180-4/upd1/final) |
| `sha3` | SHA3-256 (KEM combiners, fingerprints) | [RustCrypto/hashes](https://github.com/RustCrypto/hashes/tree/master/sha3) | [sha3](https://crates.io/crates/sha3) | [FIPS 202](https://csrc.nist.gov/pubs/fips/202/final) |
| `blake3` | BLAKE3 | [BLAKE3-team/BLAKE3](https://github.com/BLAKE3-team/BLAKE3) | [blake3](https://crates.io/crates/blake3) | [BLAKE3 specification](https://github.com/BLAKE3-team/BLAKE3-specs/blob/master/blake3.pdf) |
| `argon2` | Argon2id, PHC strings | [RustCrypto/password-hashes](https://github.com/RustCrypto/password-hashes/tree/master/argon2) | [argon2](https://crates.io/crates/argon2) | [RFC 9106](https://www.rfc-editor.org/rfc/rfc9106), [PHC string format](https://github.com/P-H-C/phc-string-format/blob/master/phc-sf-spec.md) |
| `subtle` | Constant-time comparisons | [dalek-cryptography/subtle](https://github.com/dalek-cryptography/subtle) | [subtle](https://crates.io/crates/subtle) | |
| `zeroize` | Wiping secrets from memory | [RustCrypto/utils](https://github.com/RustCrypto/utils/tree/master/zeroize) | [zeroize](https://crates.io/crates/zeroize) | |
| `rand_core` | The RNG traits every function takes | [rust-random/rand_core](https://github.com/rust-random/rand_core) | [rand_core](https://crates.io/crates/rand_core) | |
| `getrandom` | The operating system's CSPRNG (CLI, bindings, tests) | [rust-random/getrandom](https://github.com/rust-random/getrandom) | [getrandom](https://crates.io/crates/getrandom) | |
| `thiserror` | Error type | [dtolnay/thiserror](https://github.com/dtolnay/thiserror) | [thiserror](https://crates.io/crates/thiserror) | |
The composite signatures follow
[draft-ietf-lamps-pq-composite-sigs-19](https://datatracker.ietf.org/doc/draft-ietf-lamps-pq-composite-sigs/19/)
(since published as [RFC 10073](https://www.rfc-editor.org/rfc/rfc10073)); the `pqbox-max` and
`pqbox-paranoid` KEM combiners are pqbox's own (see [Suites](#suites)).
### CLI and bindings
| `clap` | CLI argument parsing | [clap-rs/clap](https://github.com/clap-rs/clap) | [crates.io](https://crates.io/crates/clap) |
| `base64ct` | Constant-time base64 for keys and boxes | [RustCrypto/formats](https://github.com/RustCrypto/formats/tree/master/base64ct) | [crates.io](https://crates.io/crates/base64ct) |
| `serde_json` | `pqbox selftest`: embedded known answers, `--json` report | [serde-rs/json](https://github.com/serde-rs/json) | [crates.io](https://crates.io/crates/serde_json) |
| `pyo3` | Python bindings | [PyO3/pyo3](https://github.com/PyO3/pyo3) | [crates.io](https://crates.io/crates/pyo3) |
| `maturin` | Builds and publishes the Python wheels | [PyO3/maturin](https://github.com/PyO3/maturin) | [crates.io](https://crates.io/crates/maturin), [PyPI](https://pypi.org/project/maturin/) |
| `wasm-bindgen` | WebAssembly bindings for the npm package | [wasm-bindgen/wasm-bindgen](https://github.com/wasm-bindgen/wasm-bindgen) | [crates.io](https://crates.io/crates/wasm-bindgen) |
| `js-sys` | JavaScript types for the WebAssembly bindings | [wasm-bindgen/wasm-bindgen](https://github.com/wasm-bindgen/wasm-bindgen/tree/main/crates/js-sys) | [crates.io](https://crates.io/crates/js-sys) |
| `criterion` | Timing benchmarks | [criterion-rs/criterion.rs](https://github.com/criterion-rs/criterion.rs) | [crates.io](https://crates.io/crates/criterion) |
| `gungraun` | Instruction-count benchmarks (the CI regression gate) | [gungraun/gungraun](https://github.com/gungraun/gungraun) | [crates.io](https://crates.io/crates/gungraun) |
| `proptest` | Property tests | [proptest-rs/proptest](https://github.com/proptest-rs/proptest) | [crates.io](https://crates.io/crates/proptest) |
| `cargo-fuzz` | Fuzzing (libFuzzer) | [rust-fuzz/cargo-fuzz](https://github.com/rust-fuzz/cargo-fuzz) | [crates.io](https://crates.io/crates/cargo-fuzz) |
### Test vectors
Listed with their exact revisions in [`tests/vectors/README.md`](crates/pqbox-core/tests/vectors/README.md):
- [NIST ACVP-Server](https://github.com/usnistgov/ACVP-Server) (SLH-DSA key generation and verification);
- [C2SP/wycheproof](https://github.com/C2SP/wycheproof) (AEADs, HKDF, HMAC, Ed25519, X25519, P-384, ML-KEM, ML-DSA);
- the X-Wing draft's [test vectors](https://github.com/dconnolly/draft-connolly-cfrg-xwing-kem/blob/main/spec/test-vectors.json);
- the IETF LAMPS examples for [ML-KEM](https://github.com/lamps-wg/kyber-certificates) and [ML-DSA](https://github.com/lamps-wg/dilithium-certificates) keys;
- the RFC vectors cited next to each test.
## License
MIT © maxgfr