Module p256::ecdsa [−][src]
This is supported on crate feature
ecdsa-core
only.Expand description
Elliptic Curve Digital Signature Algorithm (ECDSA)
This module contains support for computing and verifying ECDSA signatures. To use it, you will need to enable one of the two following Cargo features:
ecdsa-core
: provides only theSignature
type (which represents an ECDSA/P-256 signature). Does not require thearithmetic
feature. This is useful for 3rd-party crates which wish to use theSignature
type for interoperability purposes (particularly in conjunction with thesignature::Signer
trait. Example use cases for this include other software implementations of ECDSA/P-256 and wrappers for cloud KMS services or hardware devices (HSM or crypto hardware wallet).ecdsa
: providesecdsa-core
features plus theSigningKey
andVerifyingKey
types which natively implement ECDSA/P-256 signing and verification.
Signing/Verification Example
This example requires the ecdsa
Cargo feature is enabled:
use p256::{ ecdsa::{SigningKey, Signature, signature::Signer}, }; use rand_core::OsRng; // requires 'getrandom' feature // Signing let signing_key = SigningKey::random(&mut OsRng); // Serialize with `::to_bytes()` let message = b"ECDSA proves knowledge of a secret number in the context of a single message"; let signature = signing_key.sign(message); // Verification use p256::ecdsa::{VerifyingKey, signature::Verifier}; let verify_key = VerifyingKey::from(&signing_key); // Serialize with `::to_encoded_point()` assert!(verify_key.verify(message, &signature).is_ok());
Re-exports
pub use ecdsa_core::signature; |
Structs
Error | Signature errors. |
Type Definitions
DerSignature | ECDSA/P-256 signature (ASN.1 DER encoded) |
Signature | ECDSA/P-256 signature (fixed-size) |
SigningKey | ecdsa ECDSA/P-256 signing key |
VerifyingKey | ecdsa ECDSA/P-256 verification key (i.e. public key) |