RustPQ
A pure Rust post-quantum cryptography suite by Sanct.
Algorithms
| Algorithm | Standard | Status |
|---|---|---|
| ML-KEM (Kyber) | FIPS 203: Module-Lattice-Based Key-Encapsulation Mechanism | Implemented |
| ML-DSA (Dilithium) | FIPS 204: Module-Lattice-Based Digital Signature Standard | Implemented |
| SLH-DSA (SPHINCS+) | FIPS 205: Stateless Hash-Based Digital Signature Standard | Planned |
Features
- Pure Rust - No unsafe code, memory-safe by design
no_stdCompatible - Works on embedded devices and bare-metal- Constant-time - Resistant to timing attacks via the
subtlecrate - Lightweight - Minimal dependencies
Installation
[]
= "0.1"
Usage
ML-KEM Key Encapsulation
use ;
use OsRng;
// Generate a keypair
let = generate;
// Encapsulate: creates shared secret + ciphertext
let = encapsulate;
// Decapsulate: recovers shared secret from ciphertext
let shared_secret_receiver = decapsulate;
assert_eq!;
ML-DSA Digital Signatures
use ;
use OsRng;
// Generate a keypair
let = generate;
// Sign a message
let message = b"Hello World";
let context = b""; // Optional context string
let signature = sign.unwrap;
// Verify the signature
assert!;
Examples
Run the included examples:
# ML-KEM key encapsulation
# ML-DSA digital signatures
Development
# Run all tests
# Check for issues
Feature Flags
| Feature | Description |
|---|---|
ml-kem |
Enable ML-KEM (default) |
mlkem512 |
ML-KEM-512 parameter set |
mlkem768 |
ML-KEM-768 parameter set (default) |
mlkem1024 |
ML-KEM-1024 parameter set |
ml-dsa |
Enable ML-DSA |
mldsa44 |
ML-DSA-44 parameter set (NIST Level 2) |
mldsa65 |
ML-DSA-65 parameter set (NIST Level 3) |
mldsa87 |
ML-DSA-87 parameter set (NIST Level 5) |
std |
Enable standard library support |
Security
This implementation prioritizes correctness and security:
- Constant-time operations to prevent timing side-channels
- Zeroization of sensitive data on drop
- No unsafe code
[!WARNING] This library has not yet been audited. Use at your own risk in production systems.
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE)
- MIT license (LICENSE-MIT)
at your option.