| Crates.io | dcrypt-sign |
| lib.rs | dcrypt-sign |
| version | 1.2.2 |
| created_at | 2025-07-24 21:37:38.162779+00 |
| updated_at | 2025-12-10 20:22:44.160708+00 |
| description | Digital Signature Schemes for the dcrypt library |
| homepage | |
| repository | https://github.com/ioi-foundation/dcrypt |
| max_upload_size | |
| id | 1766935 |
| size | 477,995 |
Digital Signature Schemes for the dcrypt library.
dcrypt-sign is a crate that provides a comprehensive suite of digital signature algorithms. It features a unified API for both traditional, widely-used schemes and next-generation, post-quantum cryptographic standards. The implementations are designed with security, correctness, and performance in mind, conforming to official standards such as FIPS and RFCs.
The primary goal of this crate is to offer robust, production-ready signature algorithms that adhere to the dcrypt-api traits, ensuring seamless integration within the dcrypt ecosystem.
dcrypt-api::Signature trait for consistent usage.traditional, post-quantum) to include only the necessary algorithm families, reducing binary size.| Algorithm | Variants Implemented | Standard |
|---|---|---|
| CRYSTALS-Dilithium | Dilithium2, Dilithium3, Dilithium5 |
FIPS 204 |
| Falcon | Falcon512, Falcon1024 |
(Placeholder) |
| Rainbow | RainbowI, RainbowIII, RainbowV |
(Placeholder) |
| SPHINCS+ | SphincsSha2, SphincsShake |
(Placeholder) |
| Algorithm | Variants Implemented | Standard |
|---|---|---|
| ECDSA | EcdsaP192, EcdsaP224, EcdsaP256, EcdsaP384, EcdsaP521 |
FIPS 186-4 |
| EdDSA | Ed25519 |
RFC 8032 |
Add dcrypt-sign to your Cargo.toml. To enable specific algorithm suites, use the features attribute.
[dependencies]
# By default, both traditional and post-quantum schemes are available
dcrypt-sign = "0.12.0-beta.1"
# To include only post-quantum schemes:
# dcrypt-sign = { version = "0.12.0-beta.1", default-features = false, features = ["post-quantum"] }
# To include only traditional schemes:
# dcrypt-sign = { version = "0.12.0-beta.1", default-features = false, features = ["traditional"] }
You will also need a cryptographically secure random number generator, like rand.
[dependencies]
rand = "0.8"
All signature schemes in this crate implement the dcrypt::api::Signature trait, providing a consistent and easy-to-use interface.
use dcrypt::api::Signature;
use dcrypt::sign::Dilithium2;
use rand::rngs::OsRng;
fn main() -> dcrypt::api::Result<()> {
let mut rng = OsRng;
let message = b"This is a test message for the Dilithium signature algorithm.";
// 1. Generate a keypair
let (pk, sk) = Dilithium2::keypair(&mut rng)?;
// 2. Sign the message with the secret key
println!("Signing message...");
let signature = Dilithium2::sign(message, &sk)?;
println!("Signature generated successfully.");
// 3. Verify the signature with the public key
println!("Verifying signature...");
Dilithium2::verify(message, &signature, &pk)?;
println!("Signature is valid!");
// Verification will fail for a tampered message
let tampered_message = b"This is a tampered message.";
assert!(Dilithium2::verify(tampered_message, &signature, &pk).is_err());
println!("Signature verification failed for tampered message, as expected.");
Ok(())
}
The API remains the same, just switch the type.
use dcrypt::api::Signature;
use dcrypt::sign::Ed25519;
use rand::rngs::OsRng;
fn main() -> dcrypt::api::Result<()> {
let mut rng = OsRng;
let message = b"A message signed with Ed25519.";
// 1. Generate a keypair
let (pk, sk) = Ed25519::keypair(&mut rng)?;
// 2. Sign the message
let signature = Ed25519::sign(message, &sk)?;
// 3. Verify the signature
assert!(Ed25519::verify(message, &signature, &pk).is_ok());
println!("Ed25519 signature is valid!");
Ok(())
}
This crate uses feature flags to control which code is included, allowing you to optimize binary size by excluding unused algorithm families.
std: (Enabled by default) Enables functionality that requires the standard library.serde: Enables serialization and deserialization of keys and signatures via the serde framework.traditional: Enables ECDSA and EdDSA signature schemes.post-quantum: Enables Dilithium, Falcon, Rainbow, and SPHINCS+ signature schemes.By default, std, traditional, and post-quantum are enabled.
This library has been developed with a focus on security. Secret key types implement the Zeroize trait, which securely erases their contents from memory when they go out of scope. However, security is a shared responsibility. Users of this crate should follow best practices for handling cryptographic keys, such as:
rand::rngs::OsRng.This crate is licensed under the terms of the license specified in Cargo.toml.
Contributions are welcome! Please feel free to submit pull requests or open issues on the project repository.