Repository navigation
Spec: ML-DSA prepared keys for repeated signing and verification - #4366
Merged
Merged
Conversation
reaperhulk
marked this pull request as ready for review
November 6, 2026 21:28
reaperhulk
enabled stacked auto-merge
November 6, 2026 21:33
vg_mldsa*_prepare_signing_key and vg_mldsa*_prepare_verifying_key copy an encoded key and append the NTTs of its key polynomials (NTT(s1), NTT(s2), NTT(t0) for a private key; NTT(t1 * 2^d) for a public key), stored as canonical u32 coefficients (PolyStored). vg_mldsa*_sign_message_prepared and vg_mldsa*_verify_message_prepared take such a prepared key in place of the encoded key, with the results, failures and permitted leakage of vg_mldsa*_sign_message and vg_mldsa*_verify_message_cached. A batch API prepares a key once and signs or verifies many messages with it. Adapted from the specification of #3806, with only the functions the Rust code will call. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015ajQWy42drMfWKyQXeWwK8
… messages Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015ajQWy42drMfWKyQXeWwK8
reaperhulk
force-pushed
the
claude/wonderful-planck-ihi993
branch
from
November 6, 2026 21:40
d16a214 to
5515dd9
Compare
This was referenced Nov 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Trusted specification change (
Spec/only; one new file,lean/VerifiedGarbage/Spec/MlDsa/PreparedKey.lean). This takes over the specification of #3806. The Rust API it is shaped for is an explicit prepared-key type, rather than #3819's cache hidden in the key types.ML-DSA signing (FIPS 204 Algorithm 7, lines 1–5) and verification (Algorithm 8, lines 1–9) decode the key and transform its polynomials on every call. This specifies four functions, so a key that signs or verifies a stream of messages does that work once:
vg_mldsa{44,65,87}_prepare_signing_keyandvg_mldsa{44,65,87}_prepare_verifying_keycopy the encoded key and append the key polynomials in NTT form, as canonicalu32coefficients:NTT(s₁),NTT(s₂)andNTT(t₀);NTT(t₁ · 2^d).Preparation is constant time and adds no key validation.
vg_mldsa{44,65,87}_sign_message_preparedandvg_mldsa{44,65,87}_verify_message_preparedtake a prepared key in place of the encoded key. Being prepared is a precondition (PreparedSecretKey,PreparedPublicKey). Otherwise they aresignMessageContractandverifyMessageCachedContractof the encoded prefix:signMessageLeakfor signing; the inputs for verification);tr = H(pk, 64)precondition.What changed from #3806:
*_with_cache) and theμentries with a prepared key (*_sign_prepared,*_verify_prepared) become internal functions. Their contracts move to untrustedProof/in the implementation PR.PolyIsmoved out ofSpec/in ML-DSA: no specs for its internal functions #3914, so the spec now states a prepared key's polynomials directly, asPolyStored: coefficientiis the little-endianu32atp + 4i, equal to its representative in[0, q). The implementation PR proves this equivalent toProof/'sPolyIs.SigningKey*::prepare(self) -> PreparedSigningKey*andVerifyingKey*::prepare(self) -> PreparedVerifyingKey*, with the usualsign,sign_deterministicandverify:Nothing here changes existing key formats or contracts, adds ISA semantics, or caches the expanded matrix
Â.Validation:
lake build +VerifiedGarbage.Spec.MlDsa.PreparedKeypasses on maind3d83849a. CI's static checks and Lean build pass.The implementation (AArch64 proofs, registrations, generated code, Rust API, tests, benchmarks) will be a separate PR stacked on this one.
🤖 Generated with Claude Code
https://claude.ai/code/session_015ajQWy42drMfWKyQXeWwK8