pub struct SigningKey { /* private fields */ }Expand description
Private signing key for
ML-DSA-87 (automatically zeroized on drop, redacted in Debug).
Implementations§
Source§impl SigningKey
impl SigningKey
Sourcepub fn from_bytes(bytes: &[u8]) -> Result<Self>
pub fn from_bytes(bytes: &[u8]) -> Result<Self>
Parses and validates an expanded FIPS 204 signing key.
Validates that secret polynomial vectors s1 and s2 decode within [−η, η].
Sourcepub fn expose_bytes(&self) -> &[u8; 4896]
pub fn expose_bytes(&self) -> &[u8; 4896]
Exposes the raw expanded signing key bytes (handle with extreme care!).
Sourcepub const fn zeroed() -> Self
pub const fn zeroed() -> Self
Returns an all-zero placeholder signing key for in-place heap initialization without stack-to-heap secret moves.
Sourcepub fn tr(&self) -> [u8; 64]
pub fn tr(&self) -> [u8; 64]
Returns the 64-byte public key hash tr stored inside this signing key.
Sourcepub fn mu_hasher(&self, ctx: &[u8]) -> Result<MuHasher>
pub fn mu_hasher(&self, ctx: &[u8]) -> Result<MuHasher>
Creates a streaming MuHasher bound to this signing key’s public key hash tr and ctx.
Sourcepub fn sign_mu<R: CryptoRng + ?Sized>(
&self,
mu: &[u8; 64],
rng: &mut R,
) -> Result<Signature>
pub fn sign_mu<R: CryptoRng + ?Sized>( &self, mu: &[u8; 64], rng: &mut R, ) -> Result<Signature>
Signs a precomputed 64-byte External-mu mu in hedged mode (fresh randomness).
Sourcepub fn sign_mu_deterministic(&self, mu: &[u8; 64]) -> Result<Signature>
pub fn sign_mu_deterministic(&self, mu: &[u8; 64]) -> Result<Signature>
Signs a precomputed 64-byte External-mu mu in deterministic mode (rnd = [0; 32]).
Sourcepub fn sign_into<R: CryptoRng + ?Sized>(
&self,
msg: &[u8],
ctx: &[u8],
rng: &mut R,
sig_out: &mut [u8],
) -> Result<()>
pub fn sign_into<R: CryptoRng + ?Sized>( &self, msg: &[u8], ctx: &[u8], rng: &mut R, sig_out: &mut [u8], ) -> Result<()>
Signs msg with context ctx using fresh OS/CSPRNG randomness, writing the
signature directly into sig_out (sig_out.len() == SIG_LEN, FIPS 204
Algorithm 2) without allocating a SIG_LEN-byte signature copy on the stack.
Sourcepub fn sign<R: CryptoRng + ?Sized>(
&self,
msg: &[u8],
ctx: &[u8],
rng: &mut R,
) -> Result<Signature>
pub fn sign<R: CryptoRng + ?Sized>( &self, msg: &[u8], ctx: &[u8], rng: &mut R, ) -> Result<Signature>
Signs msg with context ctx using fresh OS/CSPRNG randomness (hedged mode,
FIPS 204 Algorithm 2).
Sourcepub fn sign_deterministic(&self, msg: &[u8], ctx: &[u8]) -> Result<Signature>
pub fn sign_deterministic(&self, msg: &[u8], ctx: &[u8]) -> Result<Signature>
Signs msg with context ctx in deterministic mode (rnd = [0; 32], FIPS 204).