Skip to main content

dcrypt_sign/eddsa/
mod.rs

1//! EdDSA (Edwards-curve Digital Signature Algorithm) implementations
2//!
3//! This module provides a dcrypt-owned, safe-Rust Ed25519 implementation with
4//! strict canonical and prime-subgroup validation. This description is not an
5//! 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//! - **Fixed-schedule secret arithmetic**: Secret scalar multiplication uses
13//!   constant-time selection rather than secret-dependent branches
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. **Supply a CSPRNG**: Key generation uses only the caller-provided RNG;
27//!    this crate does not obtain entropy from the operating system
28//! 2. **Protect seeds**: Encrypt before storage, decrypt only when needed
29//! 3. **Verify public keys**: Confirm authenticity through secure channels
30//! 4. **Clear sensitive data**: Automatic for secret keys, manual for seeds
31//!
32//! # Example
33//!
34//! ```
35//! use dcrypt_sign::eddsa::{Ed25519, Ed25519SecretKey};
36//! use dcrypt_api::Signature;
37//!
38//! # fn main() -> dcrypt_api::Result<()> {
39//! // Load a seed supplied by the application's key-management boundary.
40//! let seed = [42u8; 32];
41//! let secret_key = Ed25519SecretKey::from_seed(&seed)?;
42//! let public_key = secret_key.public_key()?;
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;
66mod field;
67mod point;
68mod scalar;
69
70// Re-export Ed25519 types
71pub use ed25519::{Ed25519, Ed25519PublicKey, Ed25519SecretKey, Ed25519Signature};