commonware_cryptography/ed25519/mod.rs
1//! Ed25519 implementation of the [crate::Verifier] and [crate::Signer] traits.
2//!
3//! This implementation uses the `ed25519-consensus` crate to adhere to a strict
4//! set of validation rules for Ed25519 signatures (which is necessary for
5//! stability in a consensus context). You can read more about this
6//! [here](https://hdevalence.ca/blog/2020-10-04-its-25519am).
7//!
8//! # Example
9//! ```rust
10//! use commonware_cryptography::{ed25519, PrivateKey, PublicKey, Signature, PrivateKeyExt as _, Verifier as _, Signer as _};
11//! use rand::rngs::OsRng;
12//!
13//! // Generate a new private key
14//! let mut signer = ed25519::PrivateKey::from_rng(&mut OsRng);
15//!
16//! // Create a message to sign
17//! let namespace = Some(&b"demo"[..]);
18//! let msg = b"hello, world!";
19//!
20//! // Sign the message
21//! let signature = signer.sign(namespace, msg);
22//!
23//! // Verify the signature
24//! assert!(signer.public_key().verify(namespace, msg, &signature));
25//! ```
26
27mod scheme;
28
29#[cfg(feature = "std")]
30pub use scheme::Batch;
31pub use scheme::{PrivateKey, PublicKey, Signature};