commonware_cryptography/secp256r1/mod.rs
1//! Secp256r1 implementation of the [crate::Verifier] and [crate::Signer] traits.
2//!
3//! This implementation operates over public keys in compressed form (SEC 1, Version 2.0, Section 2.3.3), generates
4//! deterministic signatures as specified in [RFC 6979](https://datatracker.ietf.org/doc/html/rfc6979), and enforces
5//! signatures are normalized according to [BIP 62](https://github.com/bitcoin/bips/blob/master/bip-0062.mediawiki#low-s-values-in-signatures).
6//!
7//! # Example
8//! ```rust
9//! use commonware_cryptography::{secp256r1, PrivateKey, PublicKey, Signature, PrivateKeyExt as _, Verifier as _, Signer as _};
10//! use rand::rngs::OsRng;
11//!
12//! // Generate a new private key
13//! let mut signer = secp256r1::PrivateKey::from_rng(&mut OsRng);
14//!
15//! // Create a message to sign
16//! let namespace = Some(&b"demo"[..]);
17//! let msg = b"hello, world!";
18//!
19//! // Sign the message
20//! let signature = signer.sign(namespace, msg);
21//!
22//! // Verify the signature
23//! assert!(signer.public_key().verify(namespace, msg, &signature));
24//! ```
25
26mod scheme;
27
28pub use scheme::{PrivateKey, PublicKey, Signature};