Repository navigation
ML-DSA x86-64: prepared keys - #4382
Conversation
|
Benchmark run 42308361531 (x86-64,
(44 / 65 / 87.) The ordinary Generated by Claude Code |
Verified x86-64 prepare_signing_key / prepare_verifying_key for every arithmetic variant, the sign and verify kernels taking a cache flag (sign_message_prepared, verify_message_prepared), their registrations, and the Rust wiring. The generated crate is not yet regenerated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015ajQWv8vyagFtvNRScZ3FE
The AVX-512 prepare functions call only the AVX2 arithmetic (NTT and unpacking), so they declare its features (`ArithImpl.prepareFeatures`). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015ajQWv8vyagFtvNRScZ3FE
|
This pull request has conflicts with Posted by |
7a7bb52 to
bb698bf
Compare
Follows #4375 (the AArch64 implementation, merged). Implements the prepared-key spec of #4366 on x86-64 for every arithmetic variant (baseline,
_avx2,_avx512).What changes
vg_mldsa*_sign_with_cache{sfx}andvg_mldsa*_verify_with_cache{sfx}, taking a flag (r9/r8, saved in scratch across the calls of ExpandA). With the flag set the key is a prepared key: signing copiesŝ₁ ‖ ŝ₂ ‖ t̂₀from it instead of decoding and transforming (decodeOrCopy), and verification copies eachNTT(t₁[r]·2ᵈ)instead of unpacking and transforming it (keyRow). The ordinaryvg_mldsa*_sign/vg_mldsa*_verifyare nowmov r9/r8, 0; call kernel(stack 40);sign_message/verify_message_cachedpass flag 0, and the newsign_message_prepared/verify_message_preparedthe same code with flag 1. Their proofs are generalized over the flag (a cumulative memory frame in the kernels' invariants shows the cached polynomials are unchanged when copied).vg_mldsa{44,65,87}_prepare_signing_key/_prepare_verifying_key(Impl/MlDsa/X86_64/PreparedKey.lean): for each key polynomial, the existingbit_unpack/unpack_t1into its slot, thenvg_mldsa_nttin place with the first KiB ofpreparedas working space; the encoded key is copied last, over that space. One generic proof (Proof/MlDsa/X86_64/PreparedKey/Prepare.lean) covers both, correctness and constant time (only the pointers leak), againstpreparePublicKeyContract/prepareSecretKeyContractat stack 32.PreparedKey/Sat.lean) is shown with a key that the verified preparation itself writes, so no assumption is added.Generic/MlDsaArith/X86_64/MlDsaPreparedKey.lean; the prepared message functions are added to the existing generic sign-message / verify-message files. The AVX-512 arithmetic variant differs from AVX2 only in two samplers the preparation never calls, so its prepare functions declare the AVX2 features (ArithImpl.prepareFeatures, defaulting tofeatures), as the emitter requires the exact set.src/mldsa_common.rs):PreparedSigningKey/PreparedVerifyingKeyhold and use the prepared key on x86-64 as on AArch64, matching exhaustively onBackend; the new functions' features are inbackend()'s required lists. AArch64 is unchanged.Trusted code
No changes to
TCB/orSpec/.Testing
lake buildandEmit.lean(all audits pass;--checkclean after restacking ontomain); only the x86-64 crate changes.tests/acvp/mldsa.rsprepared,tests/wycheproof/mldsa.rssign_seed_prepared/verify_prepared) and the rest of the ML-DSA tests pass locally withVG_CPU_FEATURES=none,avx,avx2,avx,avx2,avx512f,avx512vland unrestricted (on an AVX-512 CPU). Fullcargo testpasses in none /avx,avx2/ unrestricted; ML-DSA's Rust lines are fully covered.check_lean_public_imports.pyon the edited modules, fmt, clippy,algorithms_table.py --check.Benchmarks
Scoped run (x86-64,
mldsa44 mldsa65 mldsa87, against the base): https://github.com/pyca/verified-garbage/actions/runs/42308361531 (code identical to this head; it was measured before the restack ontomain). Its jobs exit 1 only on the gate's alarm forprepare/verifying, which did nothing on x86-64 before; the prepared groups are 4–13% faster and the ordinary ones within noise: details in the comment below.🤖 Generated with Claude Code
https://claude.ai/code/session_015ajQWv8vyagFtvNRScZ3FE