| Crates.io | dcrypt-hybrid |
| lib.rs | dcrypt-hybrid |
| version | 1.2.2 |
| created_at | 2025-07-24 21:39:33.087124+00 |
| updated_at | 2025-12-10 20:23:31.935454+00 |
| description | Hybrid cryptography schemes for the dcrypt library |
| homepage | |
| repository | https://github.com/ioi-foundation/dcrypt |
| max_upload_size | |
| id | 1766937 |
| size | 74,285 |
dcrypt-hybrid is a Rust crate that provides hybrid cryptographic schemes by combining classical and post-quantum algorithms. This approach is vital for ensuring long-term security against future threats, particularly from quantum computers, by providing resistance to "Harvest Now, Decrypt Later" attacks.
The core principle is to combine two cryptographic primitives—one classical (like ECDH) and one post-quantum (like Kyber)—such that the resulting scheme is secure as long as at least one of the underlying primitives remains secure.
This crate is part of the broader dcrypt library ecosystem.
The crate provides hybrid implementations for two primary cryptographic functions: Key Encapsulation Mechanisms (KEMs) and Digital Signatures.
A KEM is used to securely establish a shared secret between two parties. Our hybrid KEM ensures that the shared secret remains confidential even if one of the constituent algorithms is broken in the future. The design is modular, allowing for easy addition of new hybrid combinations.
EcdhP256Kyber768: Combines classical ECDH on the P-256 curve with post-quantum Kyber-768 (NIST Level 3).EcdhP384Kyber1024: A higher-security variant combining ECDH on P-384 with Kyber-1024 (NIST Level 5).How it works:
Example Usage (EcdhP256Kyber768):
use dcrypt::api::Kem;
use dcrypt::hybrid::kem::EcdhP256Kyber768;
use rand::rngs::OsRng;
// 1. Generate a hybrid key pair for the recipient.
let (pk, sk) = EcdhP256Kyber768::keypair(&mut OsRng)?;
// 2. The sender encapsulates a secret for the recipient's public key.
let (ciphertext, shared_secret_sender) = EcdhP256Kyber768::encapsulate(&mut OsRng, &pk)?;
// 3. The recipient decapsulates the ciphertext with their secret key.
let shared_secret_recipient = EcdhP256Kyber768::decapsulate(&sk, &ciphertext)?;
// 4. Both parties now have the same shared secret.
assert_eq!(
*shared_secret_sender.to_bytes_zeroizing(),
*shared_secret_recipient.to_bytes_zeroizing()
);
println!("Successfully established a hybrid shared secret!");
# Ok::<(), Box<dyn std::error::Error>>(())
A hybrid signature requires that both the classical and post-quantum signatures are valid to be accepted.
EcdsaDilithiumHybridThis scheme combines:
ECDSA with the P-384 curve.Dilithium3, a signature algorithm selected by the NIST PQC standardization process.RsaFalconHybridThis scheme combines:
RSA-PSS.Falcon-512, another signature algorithm from the NIST PQC process.How it works:
Example Usage (EcdsaDilithiumHybrid):
use dcrypt::api::Signature;
use dcrypt::hybrid::sign::EcdsaDilithiumHybrid;
use rand::rngs::OsRng;
// 1. Generate a hybrid key pair.
let (pk, sk) = EcdhDilithiumHybrid::keypair(&mut OsRng)?;
let message = b"This message needs a hybrid signature.";
// 2. Sign the message with the hybrid secret key.
let signature = EcdhDilithiumHybrid::sign(message, &sk)?;
// 3. Verify the hybrid signature with the public key.
let verification_result = EcdhDilithiumHybrid::verify(message, &signature, &pk);
assert!(verification_result.is_ok());
println!("Successfully created and verified a hybrid signature!");
# Ok::<(), Box<dyn std::error::Error>>(())
Add dcrypt-hybrid to your Cargo.toml dependencies:
[dependencies]
dcrypt-hybrid = "0.13.0-beta.2"
Or use the cargo command:
cargo add dcrypt-hybrid
This crate is designed to be flexible and supports no_std environments.
std (default): Enables functionality that requires the standard library.alloc: Enables functionality requiring a global allocator, used by std and no_std.no_std: For use in environments without the standard library. You must depend on the crate with default-features = false.serde: Enables serialization and deserialization for some public types via the Serde framework.This crate is licensed under the Apache-2.0 License.