Index Mathematics Conjectures nbv lettuce Widgets

mldsa44_verify_static

stdlib/dilithium/mldsa/mldsa44_verify_static.nbv only in the dilithium field

mldsa44_verify_static(static pk, static msg, sig)

ML-DSA-44 signature verification (FIPS 204 Algorithms 3 and 8) with an empty context string, in the field Z_q itself, for a public key and message known at compile time.

pk (1312 bytes) and msg (at least one byte) are static byte values, so everything that depends on them alone (ExpandA, mu and NTT(2^13 t1)) is evaluated at compile time and the constraint system is specific to them. sig (2420 bytes) is a witness. The constraints are satisfiable exactly when the signature is valid. Returns the 512 bits of mu.

ExpandA runs without constraints, so its more-than-16-rejections check is skipped. That happens with probability below 2^-70 per polynomial and rho is a hash output.

Calls
bits/bytes_to_bits_static, bits/from_bits, mldsa/mldsa44_finish, mldsa/mldsa44_mu, mldsa/mldsa44_parse_sig, dilithium/mldsa/mldsa44_w_approx_static, mldsa/mldsa_expand_a, dilithium/mldsa/mldsa_ntt_native, mldsa/mldsa_sample_in_ball, slice
Precompiles
assert_eq!, clone!, len!, loop!, static_eval!

Source

# ML-DSA-44 signature verification (FIPS 204 Algorithms 3 and 8) with an
# empty context string, in the field Z_q itself, for a public key and message
# known at compile time.
#
# `pk` (1312 bytes) and `msg` (at least one byte) are static byte values, so
# everything that depends on them alone (ExpandA, mu and NTT(2^13 t1)) is
# evaluated at compile time and the constraint system is specific to them.
# `sig` (2420 bytes) is a witness. The constraints are satisfiable exactly
# when the signature is valid. Returns the 512 bits of mu.
#
# ExpandA runs without constraints, so its more-than-16-rejections check is
# skipped. That happens with probability below 2^-70 per polynomial and rho
# is a hash output.
(static pk, static msg, sig)

static K = 4
static L = 4
assert_eq! 1312, len! pk

static pk_bits = static_eval! {
  bytes_to_bits_static(pk)
}
# A_hat coefficients, polynomial (i, s) coefficient m at 256 (l i + s) + m
static a_hat = static_eval! {
  let limbs = mldsa_expand_a(slice((clone! pk_bits), 0, 256), K, L)
  let mut a[256 * K * L]
  loop! 256 * K * L, i {
    a[i] = limbs[3 * i] + 1024 * limbs[3 * i + 1] + 1048576 * limbs[3 * i + 2]
  }
  a
}
# NTT(2^13 t1) from the 10 bit t1 coefficients
static t_hat = static_eval! {
  let mut t1[256 * K]
  loop! 256 * K, i {
    t1[i] = from_bits(slice((clone! pk_bits), 256 + 10 * i, 10))
  }
  mldsa_ntt_native(t1, 8192)
}
static mu = static_eval! {
  mldsa44_mu((clone! pk_bits), bytes_to_bits_static(msg))
}

(let ctilde, let v_bits, let h) = mldsa44_parse_sig(sig)
let c = mldsa_sample_in_ball(clone! ctilde)
let w = mldsa44_w_approx_static(a_hat, v_bits, c, t_hat)
mldsa44_finish(mu, w, h, ctilde)