Skip to main content

sign

Function sign 

Source
pub fn sign<P: Params>(
    sk: &[u8],
    msg: &[u8],
    ctx: &[u8],
    rng: &mut dyn CryptoRng,
) -> Result<Vec<u8>, MlDsaError>
Expand description

Sign a message with an optional context string (hedged mode).

Implements Algorithm 2 of FIPS 204 (ML-DSA.Sign). Constructs the pre-formatted message M' = 0x00 || len(ctx) || ctx || msg, draws 32 random bytes for hedged signing, and calls sign_internal.

  • sk: secret key (must be P::SK_LEN bytes).
  • msg: message to sign.
  • ctx: optional context string (at most 255 bytes).
  • rng: source of randomness for the hedged nonce.

ยงErrors