Repository navigation
DSA parameter search over a refillable tape on ARMv7 - #4296
Merged
Merged
Conversation
Replace ARMv7's three-tape vg_dsa_generate_parameters (and its _umaal variant) in place with vg_dsa_parameter_search, proven against parameterSearchContract, and add vg_dsa_parameter_search_init, proven against parameterInitContract. - Impl/Dsa/Arm/Generation.lean: the seeds, their witnesses and the generator's h window all come from rand at the cursor fC; the controller counts rejected seeds from state[0] and stops with parameters (1), no seeds left (3) or a tape that ran out (2); finish writes out, used, state[0] and state[3] (high halves zero) and asks for min(2 max(avail, 256 L), 32769 L) unless avail reached the budget. Unsigned comparisons are a subtraction's carry (less); init reuses the RSA prime search's clear block for unsupported widths. - Proof/Dsa/Arm/Gen: the seed against refillAttempt, the controller with RefillSearch's search_* lemmas and requested_requests, the window search for g, the write-back of the u64 halves, and Init.lean. - Registrations: parameterSearchApi in the generic MillerRabin caller (the baseline and _umaal rounds), parameterInitApi in Artifacts/Dsa/Arm. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015ajQWxFgLnhRDJS1FKU7Ub
lake env lean --run Emit.lean: vg_dsa_parameter_search, vg_dsa_parameter_search_umaal (VG_DSA_PARAMETER_SEARCH_UMAAL_FEATURES) and vg_dsa_parameter_search_init replace vg_dsa_generate_parameters and its _umaal variant. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015ajQWxFgLnhRDJS1FKU7Ub
ARMv7 joins x86-64 on the shared entropy::serve path, choosing vg_dsa_parameter_search_umaal by the same rule as before. The three-tape path's ARMv7 select and its tests are gone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015ajQWxFgLnhRDJS1FKU7Ub
This was referenced Nov 6, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015ajQWxFgLnhRDJS1FKU7Ub
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015ajQWxFgLnhRDJS1FKU7Ub
github-merge-queue
Bot
removed this pull request from the merge queue due to a conflict with the base branch
Nov 6, 2026
With ARMv7, every target runs the refillable-tape search, so the Rust three-tape path (tapes, Generate, its known-answer fills and empty-tape tests) can no longer build anywhere: remove it, and gate the search module on the parent's architectures. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015ajQWxFgLnhRDJS1FKU7Ub
reaperhulk
enabled auto-merge
November 6, 2026 08:32
reaperhulk
deleted the
claude/unify-random-bytes-crypto-xqmg0z-dsa-arm
branch
November 6, 2026 08:52
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.
Moves ARMv7's DSA parameter generation onto the refill protocol (
Spec/Dsa/ParameterSearch.lean,Spec/Entropy.lean), as #4234, #4293, #4295 and #4297 did for x86-64, PPC64LE, i686 and AArch64. ARMv7's old three-tape function and its_umaalvariant are deleted.ARMv7 is the last target, so this PR also deletes the Rust three-tape path, which no target builds any more. It is an implementation PR: there is no change to
TCB/orSpec/. RemovinggenerateParametersApifromSpec/is a separate PR.Lean
The code and proofs are changed in place, following PPC64LE's design.
Impl/Dsa/Arm/Generation.leanvg_dsa_parameter_search(out, out_len, used, rand, rand_len, scratch, scratch_len, state)follows AAPCS: the first four arguments in r0–r3, the rest on the stack. It keeps the 304-byte stack (a 128-byte frame plus 176 for callees) and takes the width fromstate[1].vg_dsa_parameter_search_umaal, fromGeneric/MillerRabin/Arm/DsaParameters.lean, needsVG_DSA_PARAMETER_SEARCH_UMAAL_FEATURES.rand. The generator search reads a window of at most128·p_len, and a short window with no g asks for more entropy. The statuses and the requestmin(2·max(avail, 256·L), 32769·L)are x86-64's.used,state[0]andstate[3]are written with their high halves zero.eq/nehere, so unsigned comparisons go through a newlessblock (the carry of a subtraction), and 32-bit constants throughcst(movw/movt).fOutLenbecomesfUsedP;fStP,fC,fHs,fHsLen;vg_dsa_parameter_search_init(state, p_len)writes[4096, L, 32769·L, 512·L]and returns 1, or writes zeros and returns 0. It is registered inArtifacts/Dsa/Arm.lean.Proofs (
Proof/Dsa/Arm/Gen)refillAttempt. The controller steps withsearch_zero/short/attemptNone/rejected/acceptedand bounds its request withrequested_requests, all fromProof/Dsa/Generation/.Slotslemmas.Init.leanreuses RsaKeyGen'sSpace,clear_ok,zeros_wordsandwordsAt_slots.Rust
src/dsa/parameters/search.rsnow covers ARMv7, with aSearchtype for the C ABI. It picks_umaalby the same rule as before: on operating systems that run only on A-profile cores, when the CPU has the features; everywhere else, the baseline. The module is now gated on all five of the parent's architectures.search/tests.rschecks the dispatch table andselectagainst the emitted feature sets, and runs each variant the CPU supports.search::generate, soparameters.rsandtests.rslose the three-tape path:tapes,Generate, ARMv7'sselect, the three-tape known-answer fills, and the empty-tape and exhausted-tape tests.Size
Checks
lake buildpasses, as doesEmit.lean --checkwith the standard axiom audit. Nosorry,native_decide,bv_decideormaxHeartbeats.check_variants, as doescheck_lean_public_imports --base origin/main.cargo fmtpasses, andclippy -D warningspasses on x86-64, i686, PPC64LE, AArch64,armv7-unknown-linux-gnueabihfandthumbv7neon-unknown-linux-gnueabihf.VG_CPU_FEATURES=none.Benchmark
Run: https://github.com/pyca/verified-garbage/actions/runs/42132371014 (
arches: arm,modules: dsa, basemain).dsa_generate_parameters/1024dsa_generate_parameters/2048dsa_generate_parameters/3072These differences are not noise. The benchmark feeds a fixed tape (
fixed_tapeinbench/benches/primitives/main.rs). The base splits it into three tapes: seeds, h values, then witnesses. The refill search instead reads seeds, witnesses and h windows from one tape in order. So the same stream yields different seeds and witnesses, and the search does a different amount of work. The same shift appears on every architecture (#4293, #4295, #4297): about 1% less at 1024 bits, 2–3% less at 2048, and 4–6% more at 3072. It measures which candidates this one tape yields, not how fast the code runs.The other DSA benchmarks run code this PR does not change and move by noise in both directions. The extremes are
dsa_generate_key_q256/3072at 24.5% faster anddsa_private_key_q160/2048at 21.9% slower, the latter on sub-microsecond timings.🤖 Generated with Claude Code
https://claude.ai/code/session_015ajQWxFgLnhRDJS1FKU7Ub