Skip to content

ML-DSA x86 HOL-Light proof mldsa_caddq#398

Open
jakemas wants to merge 6 commits intoawslabs:mainfrom
jakemas:jakemas/add-x86-mldsa-caddq
Open

ML-DSA x86 HOL-Light proof mldsa_caddq#398
jakemas wants to merge 6 commits intoawslabs:mainfrom
jakemas:jakemas/add-x86-mldsa-caddq

Conversation

@jakemas
Copy link
Copy Markdown
Contributor

@jakemas jakemas commented Apr 28, 2026

Summary

  • Add x86 AVX2 implementation of mldsa_caddq (conditional add Q for ML-DSA polynomial coefficients)
  • Complete formal verification with 12 theorems: 4 functional correctness + 4 memory safety + 4 internal lemmas
  • Proves: for inputs with |ival(x)| < Q, the output satisfies ival(output) = ival(x) rem Q

Depends on: #397 (VPCMPGTD/VPCMPGTW instruction models)

Changes

  • x86/mldsa/mldsa_caddq.S: Fully unrolled AVX2 assembly (VPCMPGTD + VPAND + VPADDD)
  • x86_att/mldsa/mldsa_caddq.S: AT&T syntax version (auto-generated, binary-verified)
  • x86/proofs/mldsa_caddq.ml: Complete formal proof (815 lines)
  • x86/proofs/specifications.txt: 8 theorem entries (4 correct + 4 safe)
  • x86/proofs/subroutine_signatures.ml: Signature for safety proof
  • x86/Makefile, x86_att/Makefile: Build entries
  • include/s2n-bignum.h, include/s2n-bignum-c89.h: Function prototype
  • tests/test.c: Functional test with reference implementation
  • benchmarks/benchmark.c: Benchmark entry
  • tools/collect-signatures.py: Added to onlyInX86

Test plan

  • Proof verified in HOL Light (clean loadt from checkpoint)
  • Safety proofs verified (all 4 SAFE variants)
  • AT&T syntax binary-matches Intel syntax (make in x86_att/)
  • cd tests && make go — mldsa_caddq passes 100 test cases
  • cd benchmarks && make go — 14.3 ns/call
  • Cross-platform build (x86 + macOS)
  • CI passes

🤖 Generated with Claude Code

jakemas and others added 4 commits April 28, 2026 00:07
Add VEX-encoded packed signed integer compare-greater-than instructions
(VPCMPGTD for 32-bit lanes, VPCMPGTW for 16-bit lanes) needed for the
ML-DSA caddq conditional addition implementation.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add conditional addition of Q (8380417) to ML-DSA polynomial
coefficients. For each coefficient, if negative, adds Q to produce
a non-negative representative. Proves output equals input rem Q
when |input| < Q.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add constant-time and memory safety proofs for all 4 ABI variants,
proving all memory accesses stay within the declared input/output buffer.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
jakemas added a commit to pq-code-package/mldsa-native that referenced this pull request Apr 28, 2026
Point s2n-bignum at awslabs/s2n-bignum#398 branch which includes
the VPCMPGTD/VPCMPGTW instruction models needed for the x86
poly_caddq HOL Light proof.

Signed-off-by: Jake Massimo <jakemas@amazon.com>
@jakemas jakemas changed the title x86: Add mldsa_caddq function and formal proof ML-DSA AArch64 HOL-Light proof mldsa_caddq Apr 28, 2026
@jakemas jakemas changed the title ML-DSA AArch64 HOL-Light proof mldsa_caddq ML-DSA x86 HOL-Light proof mldsa_caddq May 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant