SigningKey

Struct SigningKey 

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

An ML-DSA signing key

Implementations§

Source§

impl<P: MlDsaParams> SigningKey<P>

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: RngCore + CryptoRng + ?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_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 encode(&self) -> EncodedSigningKey<P>
where P: MlDsaParams,

Encode the key in a fixed-size byte array.

Source

pub fn decode(enc: &EncodedSigningKey<P>) -> Self
where P: MlDsaParams,

Decode the key from an appropriately sized byte array.

Trait Implementations§

Source§

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

Source§

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

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
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: PartialEq + MlDsaParams> PartialEq for SigningKey<P>
where P::L: PartialEq, P::K: PartialEq,

Source§

fn eq(&self, other: &SigningKey<P>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · 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> RandomizedSigner<Signature<P>> for SigningKey<P>

Available on crate feature rand_core only.

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

Source§

fn try_sign_with_rng( &self, rng: &mut impl CryptoRngCore, 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(&self, rng: &mut impl CryptoRngCore, msg: &[u8]) -> S

Sign the given message and return a digital signature
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 singature 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. If you would like to include a context string, use the SigningKey::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<'_>> 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: PrivateKeyInfo<'_>) -> Result<Self>

Performs the conversion.
Source§

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

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> 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<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<'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).
Source§

impl<T> DynSignatureAlgorithmIdentifier for T

Source§

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

AlgorithmIdentifier for the corresponding singature system.
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<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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

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(&mut self, msg: &[u8]) -> S

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