Struct KeyPair

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

An ML-DSA key pair

Implementations§

Source§

impl<P: MlDsaParams> KeyPair<P>

Source

pub fn signing_key(&self) -> &SigningKey<P>

The signing key of the key pair

Source

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

The verifying key of the key pair

Trait Implementations§

Source§

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

Source§

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

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

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

Source§

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

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

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

Available on crate features alloc and pkcs8 only.
Source§

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

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

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

Source§

type VerifyingKey = VerifyingKey<P>

Verifying key type for this keypair.
Source§

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

The Signer implementation for KeyPair 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<'_>> for KeyPair<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.

Auto Trait Implementations§

§

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

§

impl<P> Sync for KeyPair<P>

§

impl<P> Unpin for KeyPair<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 KeyPair<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> 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<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<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, 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.