pub struct EcdsaP256SecretKey(/* private fields */);argon2 or ecdsa-p256 or ecdsa-p384 or ed25519 or hkdf or hmac or kmac or ml-kem or phc-strings or rsa or scrypt or x25519) and (crate features ecdsa-p256 or ecdsa-p384) only.Expand description
P-256 ECDSA secret scalar.
Implementations§
Source§impl EcdsaP256SecretKey
impl EcdsaP256SecretKey
Sourcepub fn from_bytes(bytes: [u8; 32]) -> Result<Self, EcdsaError>
pub fn from_bytes(bytes: [u8; 32]) -> Result<Self, EcdsaError>
Parse a P-256 secret scalar.
Sourcepub fn generate(fill: impl FnOnce(&mut [u8; 32])) -> Result<Self, EcdsaError>
pub fn generate(fill: impl FnOnce(&mut [u8; 32])) -> Result<Self, EcdsaError>
Construct a P-256 secret key by filling bytes from the provided closure.
Sourcepub fn expose_secret(&self) -> SecretBytes<{ Self::LENGTH }>
pub fn expose_secret(&self) -> SecretBytes<{ Self::LENGTH }>
Explicitly extract the secret key bytes into a zeroizing wrapper.
Sourcepub fn public_key(&self) -> EcdsaP256PublicKey
pub fn public_key(&self) -> EcdsaP256PublicKey
Derive the matching P-256 public key.
Sourcepub fn public_key_blinded(
&self,
fill: impl FnOnce(&mut [u8; 64]),
) -> EcdsaP256PublicKey
pub fn public_key_blinded( &self, fill: impl FnOnce(&mut [u8; 64]), ) -> EcdsaP256PublicKey
Derive the matching P-256 public key with caller-supplied blinding.
The closure should fill the buffer from a CSPRNG. Blinding does not change the public key; it randomizes the internal projective representation used during derivation.
Sourcepub fn try_sign(&self, message: &[u8]) -> Result<EcdsaP256Signature, EcdsaError>
pub fn try_sign(&self, message: &[u8]) -> Result<EcdsaP256Signature, EcdsaError>
Sign a message with P-256/SHA-256.
§Errors
Returns EcdsaError::SigningFailure if deterministic nonce derivation
produces an invalid ECDSA scalar. This is cryptographically negligible,
but the API reports it instead of panicking.
Sourcepub fn try_sign_blinded(
&self,
message: &[u8],
fill: impl FnOnce(&mut [u8; 64]),
) -> Result<EcdsaP256Signature, EcdsaError>
pub fn try_sign_blinded( &self, message: &[u8], fill: impl FnOnce(&mut [u8; 64]), ) -> Result<EcdsaP256Signature, EcdsaError>
Sign a message with P-256/SHA-256 and caller-supplied blinding.
The closure should fill the buffer from a CSPRNG. The ECDSA nonce remains
deterministic; the random bytes blind the internal projective kG point.
§Errors
Returns EcdsaError::SigningFailure if deterministic nonce derivation
reaches an invalid ECDSA scalar.
Sourcepub fn display_secret(&self) -> DisplaySecret<'_>
pub fn display_secret(&self) -> DisplaySecret<'_>
Returns a wrapper that displays the secret key bytes as lowercase hex.
Trait Implementations§
Source§impl Clone for EcdsaP256SecretKey
impl Clone for EcdsaP256SecretKey
Source§fn clone(&self) -> EcdsaP256SecretKey
fn clone(&self) -> EcdsaP256SecretKey
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl ConstantTimeEq for EcdsaP256SecretKey
impl ConstantTimeEq for EcdsaP256SecretKey
Source§impl Debug for EcdsaP256SecretKey
impl Debug for EcdsaP256SecretKey
Source§impl Drop for EcdsaP256SecretKey
impl Drop for EcdsaP256SecretKey
impl Eq for EcdsaP256SecretKey
Source§impl PartialEq for EcdsaP256SecretKey
impl PartialEq for EcdsaP256SecretKey
Auto Trait Implementations§
impl Freeze for EcdsaP256SecretKey
impl RefUnwindSafe for EcdsaP256SecretKey
impl Send for EcdsaP256SecretKey
impl Sync for EcdsaP256SecretKey
impl Unpin for EcdsaP256SecretKey
impl UnsafeUnpin for EcdsaP256SecretKey
impl UnwindSafe for EcdsaP256SecretKey
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more