Skip to main content

ExpandedSigningKey

Struct ExpandedSigningKey 

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

An ML-DSA signing key

Implementations§

Source§

impl<P: MlDsaParams> ExpandedSigningKey<P>

Source

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

Deterministically generate an expanded signing key from the specified seed.

This method reflects the ML-DSA.KeyGen_internal algorithm from FIPS 204, but only returns a signing key.

Source

pub fn sign_internal(&self, Mp: &[&[u8]], rnd: &B32) -> Signature<P>
where P: MlDsaParams,

This method reflects the ML-DSA.Sign_internal algorithm from FIPS 204. It does not include the domain separator that distinguishes between the normal and pre-hashed cases, and it does not separate the context string from the rest of the message.

Source

pub fn sign_randomized<R: TryCryptoRng + ?Sized>( &self, M: &[u8], ctx: &[u8], rng: &mut R, ) -> Result<Signature<P>, Error>

Available on crate feature rand_core only.

This method reflects the randomized ML-DSA.Sign algorithm.

§Errors

This method will return an opaque error if the context string is more than 255 bytes long, or if it fails to get enough randomness.

Source

pub fn sign_mu_randomized<R: TryCryptoRng + ?Sized>( &self, mu: &Array<u8, U64>, rng: &mut R, ) -> Result<Signature<P>, Error>

Available on crate feature rand_core only.

This method reflects the randomized ML-DSA.Sign algorithm with a pre-computed μ.

§Errors

This method can return an opaque error if it fails to get enough randomness.

Source

pub fn sign_deterministic( &self, M: &[u8], ctx: &[u8], ) -> Result<Signature<P>, Error>

This method reflects the optional deterministic variant of the ML-DSA.Sign algorithm.

§Errors

This method will return an opaque error if the context string is more than 255 bytes long.

Source

pub fn sign_mu_deterministic(&self, mu: &Array<u8, U64>) -> Signature<P>

This method reflects the optional deterministic variant of the ML-DSA.Sign algorithm with a pre-computed μ.

Source

pub fn verifying_key(&self) -> VerifyingKey<P>

This auxiliary function derives a VerifyingKey from a bare ExpandedSigningKey (even in the absence of the original seed).

This is a utility function that is useful when importing the private key from an external source which does not export the seed and does not provide the precomputed public key associated with the private key itself.

ExpandedSigningKey implements signature::Keypair: this inherent method is retained for convenience, so it is available for callers even when the signature::Keypair trait is out-of-scope.

Source

pub fn from_expanded(enc: &ExpandedSigningKeyBytes<P>) -> Self
where P: MlDsaParams,

👎Deprecated since 0.1.0:

use ExpandedSigningKey::from_seed instead

DEPRECATED: decode the key from an appropriately sized byte array.

Note that this form is deprecated in practice; prefer to use ExpandedSigningKey::from_seed.

Panics

This API does not validate expanded signing keys and can potentially panic if keys are malformed or maliciously generated.

To avoid panics, use ExpandedSigningKey::from_seed instead.

Source

pub fn to_expanded(&self) -> ExpandedSigningKeyBytes<P>
where P: MlDsaParams,

👎Deprecated since 0.1.0:

use SigningKey::to_seed instead

DEPRECATED: encode the key in a fixed-size byte array.

Note that this form is deprecated in practice; prefer to use SigningKey::to_seed.

Trait Implementations§

Source§

impl<P: Clone + MlDsaParams> Clone for ExpandedSigningKey<P>
where P::L: Clone, P::K: Clone,

Source§

fn clone(&self) -> ExpandedSigningKey<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 ExpandedSigningKey<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 ExpandedSigningKey<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 ExpandedSigningKey<P>

The Signer implementation for ExpandedSigningKey uses the optional deterministic variant of ML-DSA with a pre-computed µ, and only supports signing with an empty context string. If you would like to include a context string, use the ExpandedSigningKey::sign_mu_deterministic method.

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 ExpandedSigningKey<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: MlDsaParams> Keypair for ExpandedSigningKey<P>

The signature::Keypair implementation for ExpandedSigningKey allows to derive a VerifyingKey from a bare ExpandedSigningKey (even in the absence of the original seed).

Source§

fn verifying_key(&self) -> Self::VerifyingKey

This is a utility function that is useful when importing the private key from an external source which does not export the seed and does not provide the precomputed public key associated with the private key itself.

Source§

type VerifyingKey = VerifyingKey<P>

Verifying key type for this keypair.
Source§

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

The Signer implementation for ExpandedSigningKey uses the optional deterministic variant of ML-DSA, and only supports signing with an empty context string. If you would like to include a context string, use the ExpandedSigningKey::sign_deterministic method.

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 ExpandedSigningKey<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: MlDsaParams> RandomizedDigestSigner<Shake<136>, Signature<P>> for ExpandedSigningKey<P>

Available on crate feature rand_core only.

The RandomizedSigner implementation for ExpandedSigningKey only supports signing with an empty context string. If you would like to include a context string, use the ExpandedSigningKey::sign_mu_randomized method.

Source§

fn try_sign_digest_with_rng<R: TryCryptoRng + ?Sized, F: Fn(&mut Shake256) -> Result<(), Error>>( &self, rng: &mut R, 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_with_rng<R, F>(&self, rng: &mut R, f: F) -> S
where R: CryptoRng + ?Sized, F: Fn(&mut D),

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

impl<P: MlDsaParams> RandomizedMultipartSigner<Signature<P>> for ExpandedSigningKey<P>

Available on crate feature rand_core only.

The RandomizedSigner implementation for ExpandedSigningKey only supports signing with an empty context string. If you would like to include a context string, use the ExpandedSigningKey::sign_randomized method.

Source§

fn try_multipart_sign_with_rng<R: TryCryptoRng + ?Sized>( &self, rng: &mut R, msg: &[&[u8]], ) -> Result<Signature<P>, Error>

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

fn multipart_sign_with_rng<R>(&self, rng: &mut R, msg: &[&[u8]]) -> S
where R: CryptoRng + ?Sized,

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

impl<P: MlDsaParams> RandomizedSigner<Signature<P>> for ExpandedSigningKey<P>

Available on crate feature rand_core only.

The RandomizedSigner implementation for ExpandedSigningKey only supports signing with an empty context string. If you would like to include a context string, use the ExpandedSigningKey::sign_randomized method.

Source§

fn try_sign_with_rng<R: TryCryptoRng + ?Sized>( &self, rng: &mut R, 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_with_rng<R>(&self, rng: &mut R, msg: &[u8]) -> S
where R: CryptoRng + ?Sized,

Sign the given message and return a digital signature
Source§

impl<P> SignatureAlgorithmIdentifier for ExpandedSigningKey<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 ExpandedSigningKey<P>

The Signer implementation for ExpandedSigningKey uses the optional deterministic variant of ML-DSA, and only supports signing with an empty context string. If you would like to include a context string, use the ExpandedSigningKey::sign_deterministic method.

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 ExpandedSigningKey<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 ExpandedSigningKey<P>

Available on crate feature zeroize only.

Auto Trait Implementations§

§

impl<P> Freeze for ExpandedSigningKey<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 ExpandedSigningKey<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 ExpandedSigningKey<P>

§

impl<P> Sync for ExpandedSigningKey<P>

§

impl<P> Unpin for ExpandedSigningKey<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 ExpandedSigningKey<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 ExpandedSigningKey<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> AsyncRandomizedSigner<S> for T
where T: RandomizedSigner<S>,

Source§

async fn try_sign_with_rng_async<R>( &self, rng: &mut R, msg: &[u8], ) -> Result<S, Error>
where R: TryCryptoRng + ?Sized,

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

async fn sign_with_rng_async<R>(&self, rng: &mut R, msg: &[u8]) -> S
where R: CryptoRng + ?Sized,

Sign the given message and return a digital signature. 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<S, T> RandomizedSignerMut<S> for T
where T: RandomizedSigner<S>,

Source§

fn try_sign_with_rng<R>(&mut self, rng: &mut R, msg: &[u8]) -> Result<S, Error>
where R: TryCryptoRng + ?Sized,

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

fn sign_with_rng<R>(&mut self, rng: &mut R, msg: &[u8]) -> S
where R: CryptoRng + ?Sized,

Sign the given message, update the state, and return a digital signature. Read more
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.