dcrypt: A Modern, High-Assurance Cryptographic Library in Rust
dcrypt (Decentralized Cryptography) is a comprehensive cryptographic library implemented entirely in safe Rust. It bridges the gap between traditional security and the post-quantum future by providing NIST-standardized Post-Quantum Cryptography (PQC) algorithms alongside novel, production-ready hybrid constructions.
Spearheaded by the IOI Foundation as the security cornerstone for next-generation decentralized infrastructure, dcrypt eliminates foreign function interfaces (FFI) and unsafe code blocks in cryptographic logic, ensuring memory safety and cross-platform compatibility from embedded devices to enterprise servers.
🚀 Novel Capabilities
dcrypt introduces capabilities critical for the transition to quantum-safe and decentralized computing:
- Pure-Rust FIPS 204 (ML-DSA): A production-ready implementation of the complete CRYSTALS-Dilithium signature scheme with zero
unsafecode and full constant-time execution. - Pure-Rust FIPS 203 (ML-KEM): A complete implementation of CRYSTALS-Kyber with protections against timing side-channels.
- Native Hybrid Cryptography: First-class support for hybrid Key Encapsulation Mechanisms (e.g.,
ECDH P-256 + Kyber-768) and hybrid Digital Signatures, ensuring security even if one underlying primitive is compromised. - BLS12-381 Pairing Engine: A fully featured implementation of the pairing-friendly curve, including optimal Ate pairings and IETF-compliant Hash-to-Curve, essential for Zero-Knowledge Proofs and Signature Aggregation.
🛡️ Key Design Principles
- Pure Rust & Memory Safety: Implemented with zero FFI dependencies to eliminate memory vulnerabilities like buffer overflows and use-after-free errors common in C/C++ wrapped libraries.
- Post-Quantum Ready: Full support for NIST-selected algorithms, protecting data against "Harvest Now, Decrypt Later" attacks.
- Defense-in-Depth: Hybrid schemes combine battle-tested classical algorithms (ECDH/ECDSA) with modern PQC primitives.
- Constant-Time Execution: All primitives handling secret data are engineered to be branch-free and memory-access-pattern-free. This is enforced by a built-in Constant-Time Verification Suite that statistically detects timing leaks during CI.
- Type Safety: High-level APIs prevent misuse through strong typing (e.g., distinct types for
Nonce,Key, andTagprevents byte-array confusion). no_std& Cross-Platform: Fully functional inno_stdenvironments (requiringalloc), making it suitable for IoT, embedded systems, and WASM targets.
📦 Quick Start
Add dcrypt to your project's Cargo.toml.
[]
= { = "1.0" }
Example 1: Hybrid Post-Quantum Key Exchange
Securely exchange keys using a hybrid scheme (EcdhP256 + Kyber768). This ensures security remains intact even if quantum computers break elliptic curve cryptography.
use EcdhP256Kyber768;
use Kem;
use OsRng;
Example 2: Authenticated Encryption (AES-256-GCM)
Standard symmetric encryption remains a core part of the library, featuring ergonomic key management.
use ;
use ;
Example 3: BLS12-381 Bilinear Pairings
Perform bilinear pairings and hash-to-curve operations standard in decentralized identity and ZK systems.
use ;
📚 Supported Algorithms
dcrypt provides a unified API for classical, post-quantum, and hybrid operations:
| Category | Algorithms |
|---|---|
| Symmetric Encryption (AEAD) | AES-128/256-GCM, ChaCha20-Poly1305, XChaCha20-Poly1305 |
| Public Key Encryption (PKE) | ECIES (P-192, P-224, P-256, P-384, P-521) |
| Hash Functions | SHA-2 (224, 256, 384, 512), SHA-3, BLAKE2b/s |
| XOFs | SHAKE-128/256, BLAKE3 |
| Password Hashing | Argon2id (default), Argon2i, Argon2d, PBKDF2 |
| Key Derivation | HKDF, PBKDF2 |
| Digital Signatures | ECDSA (P-192 to P-521), Ed25519 |
| Post-Quantum Signatures | Dilithium / ML-DSA (Levels 2, 3, 5) |
| Key Exchange / KEM | ECDH (P-Curves, K-256, B-283) |
| Pairing-Friendly Curves | BLS12-381 (G1, G2, Gt, Pairings, Hash-to-Curve) |
| Post-Quantum KEMs | Kyber / ML-KEM (Levels 512, 768, 1024) |
| Hybrid Schemes | EcdhP256Kyber768, EcdhP384Kyber1024, EcdsaDilithiumHybrid |
🏗️ Architecture
The library is organized as a workspace of specialized crates to align type-safety boundaries with security boundaries:
dcrypt-api: Defines core traits (SymmetricCipher,Kem,Signature), error types, and fundamental data structures.dcrypt-algorithms: Low-level, constant-time implementations of cryptographic kernels (hashing, curve arithmetic, lattice math).dcrypt-common: Shared security primitives, includingSecretBuffer(automatic zeroization) andSecureCompare.dcrypt-symmetric: High-level AEADs, stream ciphers, and secure key management wrappers.dcrypt-pke: Public Key Encryption schemes, specifically ECIES (Elliptic Curve Integrated Encryption Scheme) over standard NIST curves.dcrypt-kem: Implementations of Key Encapsulation Mechanisms (Kyber, ECDH, McEliece placeholders).dcrypt-sign: Implementations of Digital Signatures (Dilithium, ECDSA, Ed25519, SPHINCS+ placeholders).dcrypt-hybrid: Ready-to-use combiners for KEMs and Signatures ensuring crypto-agility.dcrypt-tests: Contains the ACVP test harness and Constant-Time Verification Suite.
đź”’ Security & Verification
Security is the primary driver for dcrypt. The library employs a rigorous testing methodology:
Constant-Time Verification
We utilize a custom statistical analysis engine (dcrypt-tests/src/suites/constant_time) that integrates into our CI.
- Methodology: Uses Welch’s t-test, Kolmogorov–Smirnov tests, and Bootstrap resampling on high-resolution timing measurements.
- Dynamic Threshold Scaling: Adapts to environmental noise (OS jitter) to prevent false positives in CI environments.
- Coverage: Verifies critical paths in Kyber, Dilithium, ECDH, and AES-GCM against timing side-channels.
FIPS/NIST Compliance
- ACVP Test Harness: Includes a full test harness compatible with NIST's Automated Cryptographic Validation Program (ACVP) JSON vectors to ensure implementation correctness against official standards.
- Parameters: All PQC parameters strictly adhere to FIPS 203 (ML-KEM) and FIPS 204 (ML-DSA).
đź“„ License
This project is licensed under the Apache License, Version 2.0.