pub struct EcdsaP521;Expand description
ECDSA signature scheme using NIST P-521 curve (secp521r1)
Implements ECDSA as specified in FIPS 186-4, Section 6, with SHA-512 as specified in FIPS 186-5 for P-521.
Trait Implementations§
Source§impl Signature for EcdsaP521
impl Signature for EcdsaP521
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-512
- z = the leftmost min(N, bitlen(e)) bits of e, where N = 521
- 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-512
- z = the leftmost min(N, bitlen(e)) bits of e, where N = 521
- 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 = EcdsaP521PublicKey
type PublicKey = EcdsaP521PublicKey
Public key type for this algorithm
Source§type SecretKey = EcdsaP521SecretKey
type SecretKey = EcdsaP521SecretKey
Secret key type - must be zeroizable but not byte-accessible Read more
Source§type SignatureData = EcdsaP521Signature
type SignatureData = EcdsaP521Signature
Signature data type
Source§type KeyPair = (<EcdsaP521 as Signature>::PublicKey, <EcdsaP521 as Signature>::SecretKey)
type KeyPair = (<EcdsaP521 as Signature>::PublicKey, <EcdsaP521 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 EcdsaP521
impl RefUnwindSafe for EcdsaP521
impl Send for EcdsaP521
impl Sync for EcdsaP521
impl Unpin for EcdsaP521
impl UnwindSafe for EcdsaP521
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