Skip to content

Commit 8155e4b

Browse files
committed
Add VerifyingKey::compute_mu()
1 parent 8aa41de commit 8155e4b

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

ml-dsa/src/lib.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,21 @@ impl<P: MlDsaParams> VerifyingKey<P> {
772772
}
773773
}
774774

775+
/// Computes µ according to FIPS 204 for use in ML-DSA.Sign and ML-DSA.Verify.
776+
///
777+
/// # Errors
778+
///
779+
/// Returns [`Error`] if the given `Mp` returns one.
780+
pub fn compute_mu<F: FnOnce(&mut Shake256) -> Result<(), Error>>(
781+
&self,
782+
Mp: F,
783+
ctx: &[u8],
784+
) -> Result<B64, Error> {
785+
let mut mu = MuBuilder::new(&self.tr, ctx);
786+
Mp(mu.as_mut())?;
787+
Ok(mu.finish())
788+
}
789+
775790
/// This algorithm reflects the ML-DSA.Verify_internal algorithm from FIPS 204. It does not
776791
/// include the domain separator that distinguishes between the normal and pre-hashed cases,
777792
/// and it does not separate the context string from the rest of the message.

0 commit comments

Comments
 (0)