WIP: Dilithium Tier-1 Lean spec - #124
Conversation
Give reduce.rs a mathlib-free model with Montgomery/Barrett/caddq proofs and a CI lake-build gate, so those identities cannot silently drift from FIPS 204. Co-authored-by: Cursor <cursoragent@cursor.com>
n13
left a comment
There was a problem hiding this comment.
Reviewer model: GPT Sol
Verdict: REQUEST_CHANGES — the new required formal gate is not runnable at this head, the checked-in package does not yet contain the artifacts that gate promises to verify, and one of the new formal range claims is inaccurate.
Blocking findings:
-
[P1] Make the committed Lean target build (
dilithium/formal/MlDsaArith/Fips204.lean:69-71). Under the pinned Lean 4.30 toolchain,simp [geomSum]closes then = 0goal, so the followingomegaproducesNo goals to be solved. The exact-headFormal Spec (Lean)job fails here and skips every later assurance step. Remove the redundant tactic and requirelake buildto pass before this gate lands. -
[P1] Check in the capstone/NTT assurance surface before enabling its CI gate (
.github/workflows/ci.yml:229-250). After the build error is fixed, the job is still guaranteed to fail becausedilithium/formal/ci/AxiomsCheck.leanis absent and neithermldsa_arith_tier1normldsa_arith_tier1_safetyexists. More broadly, this head contains rounding definitions but no rounding refinement theorems, and no Rust NTT model/refinement at all, while the workflow says it verifiesreduce.rs,rounding.rs, andntt.rsagainst Algorithms 35–42. Add the promised proofs, capstones, and axiom-check file, or scope/defer the gate to what this phase actually provides. -
[P2] Correct the claimed tight
reduce32range (dilithium/formal/MlDsaArith/ReduceCorrectness.lean:287-293). The proved interval is a valid loose bound, but it is not tight and the explanation for its lower end is false. Fora = -2143289344, the implementation computest = -255andreduce32(a) = -6283009, which is the actual minimum over the stated i32 domain; ati32::MIN, the citedt = -256case returns only-2096896. Tighten the theorem/comment to[-6283009, 6283008]and update the Rust contract's current off-by-one lower bound so the formal artifact does not institutionalize a second, looser number.
Validation:
- Reviewed exact base
3b1464f751d536aba023a53df2a4f4533ab94f62through head1b34f32cf49beda70ea7128d7b56d03912e7a5be;git diff --checkpassed. cargo test --locked -p qp-rusty-crystals-dilithium --all-featurespassed: 161 unit tests, the integration targets, and 11 doctests.- Exact-head CI has passing format, Clippy/docs, no-std, stack-budget, security-audit, and CodeQL checks;
Formal Spec (Lean)fails at the line above. - The no-
sorry/admitscan passed locally; the axiom-footprint step cannot run because its checked-in input and target theorems are missing. - Cross-checked the new FIPS models against FIPS 204 Algorithms 35–43 and NIST's July 2026 potential-updates sheet.
Summary
dilithium/formal/that models Dilithium field arithmetic (same Phase 0 style as qp-poseidon).montgomery_reduce/reduce32/caddqare transcribed and proved (congruence, Montgomery half-open domain, Barrett range). FIPS 204 Algs 35–40 androunding.rsare drafted; NTT, capstones, andSPEC.mdare not in yet.formal-specjob. It will fail on this draft:Fips204.leandoes not currentlylake build, andci/AxiomsCheck.lean/ capstone theorems are still missing.Test plan
cd dilithium/formal && lake build(currently fails inFips204.lean)mldsa_arith_tier1/_safety+ci/AxiomsCheck.lean+SPEC.mdso the new CI job is green./clippy.shwas run before opening this PR)Made with Cursor