Repository navigation
Automatically prepare reused ML-DSA keys on AArch64 - #3819
Closed
reaperhulk wants to merge 13 commits into
Closed
reaperhulk wants to merge 13 commits into
reaperhulk wants to merge 13 commits into
Conversation
reaperhulk
force-pushed
the
codex/arm64-mldsa-auto-cache
branch
from
November 1, 2026 05:12
76bfbb8 to
abd2a00
Compare
reaperhulk
marked this pull request as ready for review
November 1, 2026 05:21
reaperhulk
force-pushed
the
codex/arm64-mldsa-auto-cache
branch
from
November 1, 2026 14:06
88abce7 to
421c0a3
Compare
|
This pull request has conflicts with Posted by |
This was referenced Nov 6, 2026
reaperhulk
pushed a commit
that referenced
this pull request
Nov 6, 2026
SigningKey{44,65,87}::prepare and VerifyingKey{44,65,87}::prepare give a
PreparedSigningKey / PreparedVerifyingKey: the key, with its polynomials
decoded and transformed once (vg_mldsa*_prepare_signing_key,
vg_mldsa*_prepare_verifying_key), for a key that signs or verifies a
stream of messages. Its sign, sign_deterministic and verify call
vg_mldsa*_sign_message_prepared and vg_mldsa*_verify_message_prepared on
AArch64, and the ordinary functions elsewhere. The prepared bytes are
inline (no allocation), immutable, and wiped on drop for a private key.
The implementation and proofs are those of #3819,
rebased onto main:
* The ordinary and prepared entries share one signing and one
verification kernel per parameter set and Keccak backend
(vg_mldsa*_sign_with_cache, vg_mldsa*_verify_with_cache), which take an
optional slice of the key's polynomials. They and the entries on mu with
a prepared key (vg_mldsa*_sign_prepared, vg_mldsa*_verify_prepared) are
internal functions now, their contracts untrusted in
Proof/MlDsa/PreparedKeyContract.lean, with polyStored_iff relating the
spec's PolyStored to PolyIs.
* Lemmas main deleted as dead code (PostB.refl, PPostB.mono,
selectedPairedSignLoop_ok/_tr, finish_rootPair) are restated in the
modules that use them, and the uses of removed names (KeyGen.prims,
Sig.u64Bufs, the verify_message call lemmas) follow main.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015ajQWy42drMfWKyQXeWwK8
reaperhulk
pushed a commit
that referenced
this pull request
Nov 6, 2026
SigningKey{44,65,87}::prepare and VerifyingKey{44,65,87}::prepare give a
PreparedSigningKey / PreparedVerifyingKey: the key, with its polynomials
decoded and transformed once (vg_mldsa*_prepare_signing_key,
vg_mldsa*_prepare_verifying_key), for a key that signs or verifies a
stream of messages. Its sign, sign_deterministic and verify call
vg_mldsa*_sign_message_prepared and vg_mldsa*_verify_message_prepared on
AArch64, and the ordinary functions elsewhere. The prepared bytes are
inline (no allocation), immutable, and wiped on drop for a private key.
The implementation and proofs are those of #3819,
rebased onto main:
* The ordinary and prepared entries share one signing and one
verification kernel per parameter set and Keccak backend
(vg_mldsa*_sign_with_cache, vg_mldsa*_verify_with_cache), which take an
optional slice of the key's polynomials. They and the entries on mu with
a prepared key (vg_mldsa*_sign_prepared, vg_mldsa*_verify_prepared) are
internal functions now, their contracts untrusted in
Proof/MlDsa/PreparedKeyContract.lean, with polyStored_iff relating the
spec's PolyStored to PolyIs.
* Lemmas main deleted as dead code (PostB.refl, PPostB.mono,
selectedPairedSignLoop_ok/_tr, finish_rootPair) are restated in the
modules that use them, and the uses of removed names (KeyGen.prims,
Sig.u64Bufs, the verify_message call lemmas) follow main.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015ajQWy42drMfWKyQXeWwK8
reaperhulk
pushed a commit
that referenced
this pull request
Nov 6, 2026
SigningKey{44,65,87}::prepare and VerifyingKey{44,65,87}::prepare give a
PreparedSigningKey / PreparedVerifyingKey: the key, with its polynomials
decoded and transformed once (vg_mldsa*_prepare_signing_key,
vg_mldsa*_prepare_verifying_key), for a key that signs or verifies a
stream of messages. Its sign, sign_deterministic and verify call
vg_mldsa*_sign_message_prepared and vg_mldsa*_verify_message_prepared on
AArch64, and the ordinary functions elsewhere. The prepared bytes are
inline (no allocation), immutable, and wiped on drop for a private key.
The implementation and proofs are those of #3819,
rebased onto main:
* The ordinary and prepared entries share one signing and one
verification kernel per parameter set and Keccak backend
(vg_mldsa*_sign_with_cache, vg_mldsa*_verify_with_cache), which take an
optional slice of the key's polynomials. They and the entries on mu with
a prepared key (vg_mldsa*_sign_prepared, vg_mldsa*_verify_prepared) are
internal functions now, their contracts untrusted in
Proof/MlDsa/PreparedKeyContract.lean, with polyStored_iff relating the
spec's PolyStored to PolyIs.
* Lemmas main deleted as dead code (PostB.refl, PPostB.mono,
selectedPairedSignLoop_ok/_tr, finish_rootPair) are restated in the
modules that use them, and the uses of removed names (KeyGen.prims,
Sig.u64Bufs, the verify_message call lemmas) follow main.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015ajQWy42drMfWKyQXeWwK8
reaperhulk
pushed a commit
that referenced
this pull request
Nov 6, 2026
SigningKey{44,65,87}::prepare and VerifyingKey{44,65,87}::prepare give a
PreparedSigningKey / PreparedVerifyingKey: the key, with its polynomials
decoded and transformed once (vg_mldsa*_prepare_signing_key,
vg_mldsa*_prepare_verifying_key), for a key that signs or verifies a
stream of messages. Its sign, sign_deterministic and verify call
vg_mldsa*_sign_message_prepared and vg_mldsa*_verify_message_prepared on
AArch64, and the ordinary functions elsewhere. The prepared bytes are
inline (no allocation), immutable, and wiped on drop for a private key.
The implementation and proofs are those of #3819,
rebased onto main:
* The ordinary and prepared entries share one signing and one
verification kernel per parameter set and Keccak backend
(vg_mldsa*_sign_with_cache, vg_mldsa*_verify_with_cache), which take an
optional slice of the key's polynomials. They and the entries on mu with
a prepared key (vg_mldsa*_sign_prepared, vg_mldsa*_verify_prepared) are
internal functions now, their contracts untrusted in
Proof/MlDsa/PreparedKeyContract.lean, with polyStored_iff relating the
spec's PolyStored to PolyIs.
* Lemmas main deleted as dead code (PostB.refl, PPostB.mono,
selectedPairedSignLoop_ok/_tr, finish_rootPair) are restated in the
modules that use them, and the uses of removed names (KeyGen.prims,
Sig.u64Bufs, the verify_message call lemmas) follow main.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015ajQWy42drMfWKyQXeWwK8
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.
Repeated ML-DSA operations currently unpack and transform the same key polynomials on every call. On AArch64 with
alloc, this change keeps the existing API and attempts to prepare an immutable polynomial cache on the second valid-context operation. Signing and verification each have their own cache; message and external-μ methods share their key's counter. No allocation is attempted on the first operation. Withoutalloc, the existing compact path remains available.Stacked on #3806, which defines the prepared-key and shared-kernel contracts. This implementation adds no TCB instructions, axioms, or weakened contracts. Every new assembly entry is generated from Lean and has correctness, constant-time, ABI, and satisfiability proofs, including the preparers and the complete message/context wrappers. Ordinary and prepared entries call a shared arithmetic kernel for each parameter set and Keccak backend. The Rust publication protocol is tested separately.
One caller claims preparation. Concurrent callers continue on the compact path while it runs; allocation failure or an unwinding initializer is not retried. Published storage is immutable and freed only under exclusive ownership. Verifying-key clones start cold, equality ignores cache state, and cached secret bytes are wiped before deallocation. The encoded key bytes and existing cached public-key digest retain their meanings.
M1 Max production measurements
Three interleaved baseline/candidate comparisons against main
d1dad5ab69c1ffba88b1ec720d3d601ffa1cd367, using Rust 1.99.0 / LLVM 23.1.1 and detected CPU features. Each reported lifetime includes construction, all operations, and destruction; each run uses 16 timed samples and a fixed 32-key workload. Values below are medians of the three run medians, in microseconds per 100-operation key lifetime.At eight operations per lifetime, reductions are 2.97–3.98%. Four operations are near break-even (0.82–1.20% lower medians). One operation stays within ±0.23%; two operations cost 3.28–4.14% more because they pay for preparation. These are repeated workload measurements, not confidence intervals or a promise of a universal break-even count.
Four shared-key workers doing 32 operations each also have lower M1 median times in all 12 cold/warm cases (1.85–10.83%). This short concurrency workload is reported separately from single-thread lifetimes.
The measurement binary's
__textincreases by 24,000 bytes; its page-rounded__TEXTsegment increases by 32 KiB (671,744 → 704,512 bytes). Each cache adds 16 bytes of object metadata. Successful preparation allocates, including alignment: public keys 5,440 / 8,128 / 10,816 bytes; secret keys 14,848 / 21,440 / 28,480 bytes for 44 / 65 / 87. Storage is allocated independently for signing and verification, and includes an encoded-key prefix.Validation
a97cae098, whose Lean tree matches the rebased main).mldsa44,mldsa65, andmldsa87, alongsidemldsa_common. CI’s selected 20 unit tests pass locally in detected/scalar modes. Merging their coverage with the original CI artifacts gives 100% for every architecture (AArch64: 22,441/22,441 lines). This corrects the initial coverage failure caused by omitting the parameterized test modules from the group. The fresh CI Rust coverage job now passes, including 100% coverage for every architecture.Neoverse N2 production measurements
Native comparison run, head
abd2a0050c6a36079dff03a3d3a13fcb21b1eb78, based1dad5ab69c1ffba88b1ec720d3d601ffa1cd367. CPU implementer0x41, part0xd49(Neoverse N2), detected features including SHA3 and SVE2; Rust 1.99.1. This table uses the median of three interleaved Criterion median estimates per side, rather than the workflow summary's fastest run. Measurements are short: 25 samples and approximately 0.3 seconds per run, after 0.1 seconds warm-up. AWS-LC runs once for reference. Times are microseconds per operation on reused keys.Deterministic message signing improves by 5.42–6.65%; external-μ signing by 3.95–12.47%, and external-μ verification by 4.11–5.73%. Key-generation medians stay within 0.08%. OpenSSL ML-DSA was not enabled in this runner's benchmark configuration, so this run supplies no OpenSSL ML-DSA comparison. These reused-key measurements do not replace the cold-lifetime measurements above.
The pushed head's native AArch64 CI job and static checks pass. The remaining CI runner queue is tracked by GitHub. No measurement artifacts are included in this PR.