Skip to main content

SigningKey

Struct SigningKey 

Source
pub struct SigningKey<P: MlDsaParams> { /* private fields */ }
Expand description

ML-DSA signing key (i.e. private/secret key).

This type is initialized through a Seed, and can be used to generate ML-DSA signatures.

Implementations§

Source§

impl<P: MlDsaParams> SigningKey<P>

Source

pub fn from_seed(xi: &Seed) -> Self

Deterministically generate a signing key pair from the specified Seed.

This method reflects the ML-DSA.KeyGen_internal algorithm from FIPS 204 (Algorithm 6).

Source

pub fn as_seed(&self) -> &Seed

Borrow the Seed value: 32-bytes which can be used to reconstruct the SigningKey.

Warning

This value is key material. Please treat it with care.

Source

pub fn to_seed(&self) -> Seed

Serialize the Seed value: 32-bytes which can be used to reconstruct the SigningKey.

Warning

This value is key material. Please treat it with care.

Trait Implementations§

Source§

impl<P: MlDsaParams> AsRef<VerifyingKey<P>> for SigningKey<P>

Available on crate feature alloc only.
Source§

fn as_ref(&self) -> &VerifyingKey<P>

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<P: Clone + MlDsaParams> Clone for SigningKey<P>

Source§

fn clone(&self) -> SigningKey<P>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<P: MlDsaParams> CtEq for SigningKey<P>

Source§

fn ct_eq(&self, other: &Self) -> Choice

Determine if self is equal to other in constant-time.
Source§

fn ct_ne(&self, other: &Rhs) -> Choice

Determine if self is NOT equal to other in constant-time.
Source§

impl<P: MlDsaParams> Debug for SigningKey<P>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<P: MlDsaParams> DigestSigner<Shake<136>, Signature<P>> for SigningKey<P>

The DigestSigner implementation for SigningKey uses the optional deterministic variant of ML-DSA with a pre-computed μ, and only supports signing with an empty context string.

Source§

fn try_sign_digest<F: Fn(&mut Shake256) -> Result<(), Error>>( &self, f: F, ) -> Result<Signature<P>, Error>

Attempt to sign a message by updating the received Digest with it, returning a digital signature on success, or an error if something went wrong. Read more
Source§

fn sign_digest<F>(&self, f: F) -> S
where F: Fn(&mut D),

Sign a message by updating the received Digest with it, returning a signature. Read more
Source§

impl<P: MlDsaParams> Drop for SigningKey<P>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl<P> EncodePrivateKey for SigningKey<P>
where P: MlDsaParams + AssociatedAlgorithmIdentifier<Params = AnyRef<'static>>,

Available on crate features pkcs8 and alloc only.
Source§

fn to_pkcs8_der(&self) -> Result<SecretDocument>

Serialize a SecretDocument containing a PKCS#8-encoded private key. Read more
Source§

impl<P: MlDsaParams> Generate for SigningKey<P>

Available on crate feature rand_core only.

Algorithm 1: ML-DSA.KeyGen().

Source§

fn try_generate_from_rng<R: TryCryptoRng + ?Sized>( rng: &mut R, ) -> Result<Self, R::Error>

Generate random key using the provided TryCryptoRng. Read more
Source§

fn generate_from_rng<R>(rng: &mut R) -> Self
where R: CryptoRng + ?Sized,

Generate random key using the provided CryptoRng.
Source§

fn try_generate() -> Result<Self, Error>

Available on crate feature getrandom only.
Randomly generate a value of this type using the system’s ambient cryptographically secure random number generator. Read more
Source§

fn generate() -> Self

Available on crate feature getrandom only.
Randomly generate a value of this type using the system’s ambient cryptographically secure random number generator. Read more
Source§

impl<P: MlDsaParams> KeyExport for SigningKey<P>

Source§

fn to_bytes(&self) -> Seed

Serialize this key as a byte array.
Source§

impl<P: MlDsaParams> KeyInit for SigningKey<P>

Source§

fn new(seed: &Seed) -> Self

Create new value from fixed size key.
Source§

fn new_from_slice(key: &[u8]) -> Result<Self, InvalidLength>

Create new value from variable size key. Read more
Source§

fn generate_key<R>(rng: &mut R) -> Array<u8, Self::KeySize>
where R: CryptoRng,

👎Deprecated since 0.2.0:

use the Generate trait impl on Key instead

Available on crate feature rand_core only.
DEPRECATED: generate random key using the provided CryptoRng. Read more
Source§

impl<P: MlDsaParams> KeySizeUser for SigningKey<P>

Source§

type KeySize = UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>

Key size in bytes.
Source§

fn key_size() -> usize

Return key size in bytes.
Source§

impl<P: MlDsaParams> KeypairRef for SigningKey<P>

Available on crate feature alloc only.
Source§

type VerifyingKey = VerifyingKey<P>

Verifying key type for this keypair.
Source§

impl<P: MlDsaParams> MultipartSigner<Signature<P>> for SigningKey<P>

The Signer implementation for SigningKey uses the optional deterministic variant of ML-DSA, and only supports signing with an empty context string.

Source§

fn try_multipart_sign(&self, msg: &[&[u8]]) -> Result<Signature<P>, Error>

Equivalent of Signer::try_sign() but the message is provided in non-contiguous byte slices. Read more
Source§

fn multipart_sign(&self, msg: &[&[u8]]) -> S

Equivalent of Signer::sign() but the message is provided in non-contiguous byte slices.
Source§

impl<P: MlDsaParams> PartialEq for SigningKey<P>

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<P> SignatureAlgorithmIdentifier for SigningKey<P>
where P: MlDsaParams + AssociatedAlgorithmIdentifier<Params = AnyRef<'static>>,

Available on crate feature pkcs8 only.
Source§

const SIGNATURE_ALGORITHM_IDENTIFIER: AlgorithmIdentifier<Self::Params> = Signature<P>::ALGORITHM_IDENTIFIER

AlgorithmIdentifier for the corresponding signature system.
Source§

type Params = AnyRef<'static>

Algorithm parameters.
Source§

impl<P: MlDsaParams> Signer<Signature<P>> for SigningKey<P>

The Signer implementation for SigningKey uses the optional deterministic variant of ML-DSA, and only supports signing with an empty context string.

Source§

fn try_sign(&self, msg: &[u8]) -> Result<Signature<P>, Error>

Attempt to sign the given message, returning a digital signature on success, or an error if something went wrong. Read more
Source§

fn sign(&self, msg: &[u8]) -> S

Sign the given message and return a digital signature.
Source§

impl<P> TryFrom<PrivateKeyInfo<AnyRef<'_>, &OctetStringRef, BitStringRef<'_>>> for SigningKey<P>
where P: MlDsaParams + AssociatedAlgorithmIdentifier<Params = AnyRef<'static>>,

Available on crate feature pkcs8 only.
Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(private_key_info: PrivateKeyInfoRef<'_>) -> Result<Self>

Performs the conversion.
Source§

impl<P: MlDsaParams> ZeroizeOnDrop for SigningKey<P>

Available on crate feature zeroize only.

Auto Trait Implementations§

§

impl<P> Freeze for SigningKey<P>
where <<P as ParameterSet>::L as ArraySize>::ArrayType<Polynomial<BaseField>>: Freeze, <<P as ParameterSet>::K as ArraySize>::ArrayType<Polynomial<BaseField>>: Freeze, <<P as ParameterSet>::L as ArraySize>::ArrayType<NttPolynomial<BaseField>>: Freeze, <<P as ParameterSet>::K as ArraySize>::ArrayType<NttPolynomial<BaseField>>: Freeze, <<P as ParameterSet>::K as ArraySize>::ArrayType<NttVector<BaseField, <P as ParameterSet>::L>>: Freeze,

§

impl<P> RefUnwindSafe for SigningKey<P>
where <<P as ParameterSet>::L as ArraySize>::ArrayType<Polynomial<BaseField>>: RefUnwindSafe, <<P as ParameterSet>::K as ArraySize>::ArrayType<Polynomial<BaseField>>: RefUnwindSafe, <<P as ParameterSet>::L as ArraySize>::ArrayType<NttPolynomial<BaseField>>: RefUnwindSafe, <<P as ParameterSet>::K as ArraySize>::ArrayType<NttPolynomial<BaseField>>: RefUnwindSafe, <<P as ParameterSet>::K as ArraySize>::ArrayType<NttVector<BaseField, <P as ParameterSet>::L>>: RefUnwindSafe,

§

impl<P> Send for SigningKey<P>

§

impl<P> Sync for SigningKey<P>

§

impl<P> Unpin for SigningKey<P>
where <<P as ParameterSet>::L as ArraySize>::ArrayType<Polynomial<BaseField>>: Unpin, <<P as ParameterSet>::K as ArraySize>::ArrayType<Polynomial<BaseField>>: Unpin, <<P as ParameterSet>::L as ArraySize>::ArrayType<NttPolynomial<BaseField>>: Unpin, <<P as ParameterSet>::K as ArraySize>::ArrayType<NttPolynomial<BaseField>>: Unpin, <<P as ParameterSet>::K as ArraySize>::ArrayType<NttVector<BaseField, <P as ParameterSet>::L>>: Unpin,

§

impl<P> UnsafeUnpin for SigningKey<P>
where <<P as ParameterSet>::L as ArraySize>::ArrayType<Polynomial<BaseField>>: UnsafeUnpin, <<P as ParameterSet>::K as ArraySize>::ArrayType<Polynomial<BaseField>>: UnsafeUnpin, <<P as ParameterSet>::L as ArraySize>::ArrayType<NttPolynomial<BaseField>>: UnsafeUnpin, <<P as ParameterSet>::K as ArraySize>::ArrayType<NttPolynomial<BaseField>>: UnsafeUnpin, <<P as ParameterSet>::K as ArraySize>::ArrayType<NttVector<BaseField, <P as ParameterSet>::L>>: UnsafeUnpin,

§

impl<P> UnwindSafe for SigningKey<P>
where <<P as ParameterSet>::L as ArraySize>::ArrayType<Polynomial<BaseField>>: UnwindSafe, <<P as ParameterSet>::K as ArraySize>::ArrayType<Polynomial<BaseField>>: UnwindSafe, <<P as ParameterSet>::L as ArraySize>::ArrayType<NttPolynomial<BaseField>>: UnwindSafe, <<P as ParameterSet>::K as ArraySize>::ArrayType<NttPolynomial<BaseField>>: UnwindSafe, <<P as ParameterSet>::K as ArraySize>::ArrayType<NttVector<BaseField, <P as ParameterSet>::L>>: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<S, T> AsyncSigner<S> for T
where T: Signer<S>,

Source§

async fn sign_async(&self, msg: &[u8]) -> Result<S, Error>

Attempt to sign the given message, returning a digital signature on success, or an error if something went wrong. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DecodePrivateKey for T
where T: for<'a> TryFrom<PrivateKeyInfo<AnyRef<'a>, &'a OctetStringRef, BitStringRef<'a>>, Error = Error>,

Source§

fn from_pkcs8_der(bytes: &[u8]) -> Result<T, Error>

Deserialize PKCS#8 private key from ASN.1 DER-encoded data (binary format). Read more
Source§

impl<T> DynSignatureAlgorithmIdentifier for T

Source§

fn signature_algorithm_identifier( &self, ) -> Result<AlgorithmIdentifier<Any>, Error>

AlgorithmIdentifier for the corresponding signature system. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<K> Keypair for K
where K: KeypairRef,

Source§

type VerifyingKey = <K as KeypairRef>::VerifyingKey

Verifying key type for this keypair.
Source§

fn verifying_key(&self) -> <K as Keypair>::VerifyingKey

Get the verifying key which can verify signatures produced by the signing key portion of this keypair.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.