Skip to content

Commit 67e9a34

Browse files
authored
ml-dsa: add VerifyingKey::compute_mu() (#1074)
1 parent fe23a8c commit 67e9a34

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
@@ -773,6 +773,21 @@ impl<P: MlDsaParams> VerifyingKey<P> {
773773
}
774774
}
775775

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

0 commit comments

Comments
 (0)