Rivide: Post-Quantum Cryptography Rust Crate
Rivide for Rust (rivide) provides high-performance, zero-allocation, idiomatic Rust bindings for the Rivide Post-Quantum Cryptography (PQC) C99 library. It implements finalized NIST FIPS 203 (ML-KEM) and NIST FIPS 204 (ML-DSA) standards with automated RAII memory zeroization, constant-time arithmetic, and native AVX2 / ARM NEON hardware acceleration.
Key Features
- Official NIST Post-Quantum Standards:
- ML-KEM (FIPS 203): Module-Lattice-Based Key Encapsulation Mechanism (ML-KEM-768 and ML-KEM-1024).
- ML-DSA (FIPS 204): Module-Lattice-Based Digital Signature Algorithm (ML-DSA-65 and ML-DSA-87).
- Zero-Setup C99 Compilation:
build.rscompiles the underlying C99 engine directly using theccbuild dependency. No external pre-installed C libraries or system packages are required. - Zero Heap Allocations (0 Malloc): Pure stack-allocated byte arrays (
[u8; N]) for core cryptographic keys, ciphertexts, and signatures. - Automated RAII Memory Safety: Secret keys (
MlKem768SecretKey,MlDsa65SecretKey, etc.) implement theDroptrait and automatically invokerivide_cleanseupon exiting scope. - Hardware SIMD Vector Acceleration: Executes native AVX2 (256-bit) and ARM NEON (128-bit) vectorized polynomial arithmetic directly in C.
- Constant-Time Side-Channel Protection: Built-in constant-time byte comparisons (
utils::ct_memcmp) and rejection sampling. - Integrated Symmetric Primitives: Native implementations of SHA3-256/512, SHAKE-128/256, and AES-128/256-GCM AEAD.
Table of Contents
- Installation & Quick Start
- Code Tutorials & Usage Examples
- Parameter & Specification Summary
- Cargo Automation & Testing
- API Reference & Namespaces
- Documentation Map
- License & Maintainers
Installation & Quick Start
1. Installation
Add rivide to your project using cargo add:
Or add it directly to your Cargo.toml:
[]
= "1.1.1"
2. Building from Source
Clone the repository and compile using Cargo:
# Clone the repository
# Build optimized release artifact
# Run automated integration test suite
# Run executable demonstration examples
Code Tutorials & Usage Examples
Tutorial 1: ML-KEM-768 Quantum-Safe Key Exchange
Exchange a 256-bit symmetric session key between Alice and Bob using NIST FIPS 203 ML-KEM-768 (Security Category 3):
use MlKem768;
Tutorial 2: ML-DSA-65 Digital Signature & Verification
Sign and verify arbitrary documents and tokens using NIST FIPS 204 ML-DSA-65 (Security Category 3):
use MlDsa65;
Tutorial 3: Hybrid PQC + AES-256-GCM Secure Channel
Combine ML-KEM-768 with AES-256-GCM AEAD to build a post-quantum confidential authenticated transport channel:
use AesGcm;
use MlKem768;
use randombytes;
Parameter & Specification Summary
| Primitive | Standard | Public Key | Secret Key | Ciphertext / Signature | Shared Key / Security |
|---|---|---|---|---|---|
| ML-KEM-768 | NIST FIPS 203 | 1184 bytes |
2400 bytes |
1088 bytes |
32 bytes (Category 3 / AES-192) |
| ML-KEM-1024 | NIST FIPS 203 | 1568 bytes |
3168 bytes |
1568 bytes |
32 bytes (Category 5 / AES-256) |
| ML-DSA-65 | NIST FIPS 204 | 1952 bytes |
4032 bytes |
3309 bytes |
Category 3 / AES-192 equivalent |
| ML-DSA-87 | NIST FIPS 204 | 2592 bytes |
4896 bytes |
4627 bytes |
Category 5 / AES-256 equivalent |
Cargo Automation & Testing
| Command | Purpose |
|---|---|
cargo build --release |
Compile optimized release static archive and binaries |
cargo test |
Run entire integration test suite and doc-tests |
cargo bench |
Execute high-precision performance benchmark harness |
cargo run --example kem_exchange |
Execute ML-KEM-768 key encapsulation tutorial |
cargo run --example dsa_sign |
Execute ML-DSA-65 digital signature tutorial |
cargo run --example hybrid_channel |
Execute hybrid PQC + AES-256-GCM secure channel tutorial |
API Reference & Namespaces
rivide::kem: ML-KEM-768 and ML-KEM-1024 types and routines.rivide::dsa: ML-DSA-65 and ML-DSA-87 types and routines.rivide::crypto: SHA-3, SHAKE, and AES-GCM AEAD functions.rivide::utils: Memory cleansing, CSPRNG, and constant-time helpers.rivide::error: Strongly typed error handling.
For complete documentation, see the Rivide Rust API Reference.
Documentation Map
- Rust API Reference: Complete types, methods, and traits.
- Rust Performance Benchmark Guide: Benchmark methodology, parameters, and profiling metrics.
- Rust Bindings Architecture Spec: Technical subsystem architecture.
- Core Library Documentation: Master documentation portal.
- Main C99 Repository: Root C source code and NIST KAT test vectors.
License & Maintainers
This project is licensed under the MIT License - see the LICENSE file for details.
- Author & Maintainer: Moh. Ananda Firmansyah Putra (@mrvlous)
- Maintainers Roster: MAINTAINERS
- Contributors & Credits: CREDITS