Skip to main content

dcrypt_sign/eddsa/
mod.rs

1//! EdDSA (Edwards-curve Digital Signature Algorithm) implementations
2//!
3//! This module provides an Ed25519 adapter backed by `ed25519-dalek`, with
4//! strict verification and additional canonical/subgroup input validation.
5//! This description is not an independent audit or production-safety claim.
6//!
7//! # Security Features
8//!
9//! - **Immutable secret keys**: Prevents accidental key corruption
10//! - **Automatic zeroization**: Clears sensitive data from memory
11//! - **Secure API design**: Minimal surface area, maximum safety
12//! - **Maintained arithmetic backend**: Secret scalar operations are delegated
13//!   to `ed25519-dalek`/`curve25519-dalek`
14//! - **Type safety**: Strong typing prevents key confusion
15//!
16//! # Features
17//!
18//! - RFC 8032 Ed25519 signing and strict verification
19//! - Deterministic signature generation
20//! - Secure key generation and handling
21//! - Comprehensive input validation
22//! - Key derivation and persistence support
23//!
24//! # Security Guidelines
25//!
26//! 1. **Always use a CSPRNG**: Use `rand::rngs::OsRng` for key generation
27//! 2. **Protect seeds**: Encrypt before storage, decrypt only when needed
28//! 3. **Verify public keys**: Confirm authenticity through secure channels
29//! 4. **Clear sensitive data**: Automatic for secret keys, manual for seeds
30//!
31//! # Example
32//!
33//! ```
34//! use dcrypt_sign::eddsa::{Ed25519, Ed25519SecretKey};
35//! use dcrypt_api::Signature;
36//! use rand::rngs::OsRng;
37//!
38//! # fn main() -> dcrypt_api::Result<()> {
39//! let mut rng = OsRng;
40//!
41//! // Generate a new keypair
42//! let (public_key, secret_key) = Ed25519::keypair(&mut rng)?;
43//!
44//! // Sign a message
45//! let message = b"Hello, Ed25519!";
46//! let signature = Ed25519::sign(message, &secret_key)?;
47//!
48//! // Verify the signature
49//! assert!(Ed25519::verify(message, &signature, &public_key).is_ok());
50//!
51//! // Save the secret key seed (encrypt in production!)
52//! let seed = secret_key.seed();
53//!
54//! // Later, reconstruct the secret key
55//! let reconstructed_secret = Ed25519SecretKey::from_seed(seed)?;
56//! let reconstructed_public = reconstructed_secret.public_key()?;
57//!
58//! // The reconstructed keys work identically
59//! assert_eq!(public_key.0, reconstructed_public.0);
60//! # Ok(())
61//! # }
62//! ```
63
64mod constants;
65mod ed25519;
66
67// Re-export Ed25519 types
68pub use ed25519::{Ed25519, Ed25519PublicKey, Ed25519SecretKey, Ed25519Signature};