pub struct EcdsaP256;Expand description
ECDSA signature scheme using NIST P-256 curve (secp256r1)
Implements ECDSA as specified in FIPS 186-4, Section 6
Trait Implementations§
Source§impl Signature for EcdsaP256
impl Signature for EcdsaP256
Source§fn keypair<R: CryptoRng + RngCore>(rng: &mut R) -> ApiResult<Self::KeyPair>
fn keypair<R: CryptoRng + RngCore>(rng: &mut R) -> ApiResult<Self::KeyPair>
Generate an ECDSA key pair
Generates a random private key d ∈ [1, n-1] and computes the corresponding public key Q = d·G where G is the base point.
Reference: FIPS 186-4, Appendix B.4.1
Source§fn sign(
message: &[u8],
secret_key: &Self::SecretKey,
) -> ApiResult<Self::SignatureData>
fn sign( message: &[u8], secret_key: &Self::SecretKey, ) -> ApiResult<Self::SignatureData>
Sign a message using ECDSA
Implements the ECDSA signature generation algorithm as specified in FIPS 186-4, Section 6.3, with deterministic nonce generation per RFC 6979 hedged with additional entropy (FIPS 186-5, Section 6.4).
Algorithm:
- e = HASH(M), where HASH is SHA-256
- z = the leftmost min(N, bitlen(e)) bits of e, where N = 256
- Generate k deterministically per RFC 6979 with extra entropy
- (x₁, y₁) = k·G
- r = x₁ mod n; if r = 0, go back to step 3
- s = k⁻¹(z + rd) mod n; if s = 0, go back to step 3
- Return signature (r, s)
Source§fn verify(
message: &[u8],
signature: &Self::SignatureData,
public_key: &Self::PublicKey,
) -> ApiResult<()>
fn verify( message: &[u8], signature: &Self::SignatureData, public_key: &Self::PublicKey, ) -> ApiResult<()>
Verify an ECDSA signature
Implements the ECDSA signature verification algorithm as specified in FIPS 186-4, Section 6.4.
Algorithm:
- Verify that r and s are integers in [1, n-1]
- e = HASH(M), where HASH is SHA-256
- z = the leftmost min(N, bitlen(e)) bits of e, where N = 256
- w = s⁻¹ mod n
- u₁ = zw mod n and u₂ = rw mod n
- (x₁, y₁) = u₁·G + u₂·Q
- If (x₁, y₁) = O, reject the signature
- v = x₁ mod n
- Accept the signature if and only if v = r
Source§type PublicKey = EcdsaP256PublicKey
type PublicKey = EcdsaP256PublicKey
Public key type for this algorithm
Source§type SecretKey = EcdsaP256SecretKey
type SecretKey = EcdsaP256SecretKey
Secret key type - must be zeroizable but not byte-accessible Read more
Source§type SignatureData = EcdsaP256Signature
type SignatureData = EcdsaP256Signature
Signature data type
Source§type KeyPair = (<EcdsaP256 as Signature>::PublicKey, <EcdsaP256 as Signature>::SecretKey)
type KeyPair = (<EcdsaP256 as Signature>::PublicKey, <EcdsaP256 as Signature>::SecretKey)
Key pair type (typically a tuple of public and secret keys)
Source§fn public_key(keypair: &Self::KeyPair) -> Self::PublicKey
fn public_key(keypair: &Self::KeyPair) -> Self::PublicKey
Extract the public key from a key pair
Source§fn secret_key(keypair: &Self::KeyPair) -> Self::SecretKey
fn secret_key(keypair: &Self::KeyPair) -> Self::SecretKey
Extract the secret key from a key pair
Auto Trait Implementations§
impl Freeze for EcdsaP256
impl RefUnwindSafe for EcdsaP256
impl Send for EcdsaP256
impl Sync for EcdsaP256
impl Unpin for EcdsaP256
impl UnwindSafe for EcdsaP256
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more