Skip to main content

MuBuilder

Struct MuBuilder 

Source
pub struct MuBuilder { /* private fields */ }
Expand description

Implements parts of Algorithm 2 and Line 6 of Algorithm 7 of FIPS 204. Provides a stateful version of MLDSATrait::compute_mu_from_pk and MLDSATrait::compute_mu_from_tr that supports streaming large to-be-signed messages.

Note: this struct is only exposed for “pure” ML-DSA and not for HashML-DSA because HashML-DSA does not benefit from allowing external construction of the message representative mu. You can get the same behaviour by computing the pre-hash ph with the appropriate hash function and providing that to HashMLDSA via PHSignature::sign_ph.

Implementations§

Source§

impl MuBuilder

Source

pub fn compute_mu( msg: &[u8], ctx: Option<&[u8]>, tr: &[u8; 64], ) -> Result<[u8; 64], SignatureError>

Algorithm 7 6: 𝜇 ← H(BytesToBits(𝑡𝑟)||𝑀′, 64)

Source

pub fn do_init( tr: &[u8; 64], ctx: Option<&[u8]>, ) -> Result<Self, SignatureError>

This function requires the public key hash tr, which can be computed from the public key using MLDSAPublicKeyTrait::compute_tr.

Source

pub fn do_update(&mut self, msg_chunk: &[u8])

Stream a chunk of the message.

Source

pub fn do_final(self) -> [u8; 64]

Finalize and return the mu value.

Auto Trait Implementations§

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> 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, 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.