Repository navigation
DSA parameter search over a refillable tape on i686 - #4295
Merged
Merged
Conversation
Convert i686 DSA parameter generation in place from the three-tape `vg_dsa_generate_parameters` to the refillable-tape search of `Spec/Dsa/ParameterSearch.lean`: `vg_dsa_parameter_search` (one per SHA-1, SHA-256 and Miller-Rabin backend, against `parameterSearchContract`) and `vg_dsa_parameter_search_init` (against `parameterInitContract`). The seeds, their witnesses and the generator's `h` candidates are all read from `rand`: each seed at the cursor `fC`, its window of at most 128 candidates after p's witnesses (a short window without a g ran out); the controller counts rejected seeds from `state[0]` and stops on parameters, no seeds left, or a tape that ran out, and the result writes `out`, `used` and `state` (the next tape's length `min(2 max(avail, 256 L), 32769 L)`, or exhausted once the octets left reach the budget). The environment's seeds and `h` candidates become views of `rand` (`Env.atSeed`, `Env.window`), so the per-seed proofs (q, p, g and their constant time) are kept, and the old controller, result, entry and ABI proofs are replaced. The seed proofs use the shared `refillAttempt` and `search_*` lemmas (`Proof/Dsa/Generation/RefillSeed.lean`, `RefillSearch.lean`). No TCB or Spec change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015ajQWxFgLnhRDJS1FKU7Ub
i686 joins x86-64 on the shared entropy::serve path, matching the SHA-1 and SHA-256 backends exhaustively over the four emitted variants. The three-tape path and its i686 select are gone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015ajQWxFgLnhRDJS1FKU7Ub
reaperhulk
enabled auto-merge
November 5, 2026 23:17
This was referenced Nov 5, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015ajQWxFgLnhRDJS1FKU7Ub
reaperhulk
deleted the
claude/unify-random-bytes-crypto-xqmg0z-dsa-x86
branch
November 6, 2026 04:35
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 i686's DSA parameter generation to the refill protocol (
Spec/Dsa/ParameterSearch.lean,Spec/Entropy.lean), as #4234 did for x86-64 and #4293 for PPC64LE. i686's old three-tape function is deleted. This is an implementation PR: nothing inTCB/orSpec/changes.Lean
The generation code and proofs under
Proof/Dsa/X86/Generation/are changed in place, following PPC64LE's design.Impl/Dsa/X86/Generation.leanvg_dsa_parameter_search(out, out_len, used, rand, rand_len, scratch, scratch_len, state)takes cdecl arguments and keeps the 216-byte stack. It dispatches onstate[1], the width. There are four variants: baseline,_sha1_shani,_sha256_shaniand_sha1_shani_sha256_shani, registered inGeneric/Sha1/Sha256/MillerRabin/X86/Dsa.lean.rand, with its witnesses after it. The generator search reads a window of at most128·p_lenoctets. If the window is short and no g is found, the search asks for more entropy, and the generator loop stops when fewer thanp_lenoctets are left.32769·L; otherwise it asks formin(2·max(avail, 256·L), 32769·L)octets.state,used) are each loaded in their own block, as the constant-time proof needs.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/X86.lean.Proofs
Envnow has the single taperand. Each seed and each h window is a slice of it at an offset, so the per-seed q, p and g proofs and their constant-time proofs carry over with small edits.refillAttempt. The controller (Search,SearchCT) uses the sharedsearch_*lemmas, and the result (Finish,FinishCT) usesrequested_requests.Entry,ABI,ABIEnv,Correct,TopCTandSatisfiablewere rewritten.Init.leanreuses the i686 FFDH init helpers fromProof/Ffdh/X86/ParamInit.lean.seedList,sCont/sNext, the outcome based onseedResult) are removed.Rust
src/dsa/parameters/search.rsnow covers i686 too: a cdeclSearchtype and an exhaustive match over the SHA-1/SHA-256 backends.search/tests.rschecks the i686 dispatch table against the emitted feature sets, and runs each selectable variant.select, its three-tape test and its imports are removed fromparameters.rs.Size
Checks
lake buildpasses.Emit.lean --checkpasses with the standard axiom audit, and no file usessorry,native_decide,bv_decideormaxHeartbeats.check_lean_public_imports --base origin/main.cargo fmtandclippy -D warningspass on x86-64 and oni686-unknown-linux-gnu.VG_CPU_FEATURES=none, and on x86-64.Benchmark
Run: https://github.com/pyca/verified-garbage/actions/runs/42124762826 (
arches: x86,modules: dsa, basemain).none)none)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 gives different seeds and witnesses, and the search does a different amount of work. The same shift appears on every architecture (#4293, #4296, #4297): about 1% less at 1024 bits, 2–3% less at 2048 and 4–6% more at 3072. It measures which candidates this tape yields, not how fast the code runs.The other DSA benchmarks run code this PR does not change. With detected features they move by noise in both directions; with
nonethey agree within 5%.This conflicts with #4293 only in the
cfgs ofsrc/dsa/parameters*.rs. Whichever merges second gets rebased.🤖 Generated with Claude Code
https://claude.ai/code/session_015ajQWxFgLnhRDJS1FKU7Ub