Skip to content

DSA parameter search over a refillable tape on PPC64LE - #4293

Merged
reaperhulk merged 9 commits into
mainfrom
claude/unify-random-bytes-crypto-xqmg0z-dsa-ppc64le
Nov 6, 2026
Merged

reaperhulk merged 9 commits into
mainfrom
claude/unify-random-bytes-crypto-xqmg0z-dsa-ppc64le

Conversation

@reaperhulk

@reaperhulk reaperhulk commented Nov 5, 2026 •

Copy link
Copy Markdown
Member

Moves PPC64LE's DSA parameter generation to the refill protocol (Spec/Dsa/ParameterSearch.lean, Spec/Entropy.lean), as #4234 did for x86-64, and deletes PPC64LE's old three-tape function. This is an implementation PR: no change to TCB/ or Spec/.

Lean

PPC64LE's generation code and proofs are changed in place, so the old controller and its proofs are gone rather than kept next to the new ones.

Impl/Dsa/PPC64LE/Generation.lean

  • vg_dsa_parameter_search(out, out_len, used, rand, rand_len, scratch, scratch_len, state) takes all its arguments in r3–r10, uses a 176-byte stack (as before), and dispatches on state[1].
  • Search state lives in the scratch header. It gains a cursor, used/state pointers and result words; fSave moves from 144 to 200.
  • The generator search reads a window of rand at the cursor: min(rand_len − used, 128·p_len). A short window that finds no g asks for more entropy.
  • The controller handles three cases: no seeds left (exhausted), fewer than q_len octets left (more entropy), or run the seed at the cursor. The request is x86-64's min(2·max(avail, 256·p_len), 32769·p_len).
  • vg_dsa_parameter_search_init(state, p_len) writes [4096, p_len, 32769·p_len, 512·p_len].

Proofs (Proof/Dsa/PPC64LE/Gen/)

  • They reuse the target-independent lemmas from Proof/Dsa/Generation/RefillSeed.lean and RefillSearch.lean: refillAttempt, the search_* steps and requested_requests.
  • Gen/Init.lean proves init, reusing initWritten from Proof/Ffdh/PPC64LE/InitCommon.lean.
  • Constant time still holds the same way: the same public data gives the same internal state, so the same trace.

Registrations

  • Generic/MillerRabin/PPC64LE/DsaParameters.lean now registers parameterSearchApi, still once per Miller–Rabin rounds variant.
  • Artifacts/Dsa/PPC64LE.lean registers init.

Rust

src/dsa/parameters/search.rs (the shared entropy::serve path) now covers PPC64LE: a baseline-only exhaustive match on the SHA-1/SHA-256 backends. The old PPC64LE select and its test are removed from parameters.rs.

Size

added removed
Lean (25 files) 2,224 960
Generated crate 3,110 2,397
Rust 66 51

Checks

  • A full lake build passes, and Emit.lean --check passes with the standard axiom audit.
  • All Static checks steps pass, and so does check_lean_public_imports --base origin/main -m <changed>.
  • cargo fmt, plus clippy -D warnings on x86-64 and on powerpc64le-unknown-linux-gnu, pass.
  • PPC64LE tests and coverage pass in CI.

Benchmark

Run: https://github.com/pyca/verified-garbage/actions/runs/42113337717 (arches: powerpc64, modules: dsa, base main).

Benchmark Base Head Change
dsa_generate_parameters/1024 372.98 ms 367.90 ms 1.4% faster
dsa_generate_parameters/2048 609.98 ms 588.72 ms 3.5% faster
dsa_generate_parameters/3072 6432.07 ms 6702.37 ms 4.2% slower

These differences are not noise. The benchmark feeds a fixed tape (fixed_tape in bench/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 (#4295, #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 the speed of the code. The other DSA benchmarks run code this PR does not touch, and they move only by noise.

🤖 Generated with Claude Code

https://claude.ai/code/session_015ajQWxFgLnhRDJS1FKU7Ub

…awaiting emitted code)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015ajQWxFgLnhRDJS1FKU7Ub
…ed attempt)

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
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
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
PPC64LE now generates parameters through the refillable search alone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015ajQWxFgLnhRDJS1FKU7Ub
@reaperhulk
reaperhulk added this pull request to the merge queue Nov 5, 2026
Merged via the queue into main with commit 746375d Nov 6, 2026
38 checks passed
@reaperhulk
reaperhulk deleted the claude/unify-random-bytes-crypto-xqmg0z-dsa-ppc64le branch November 6, 2026 03:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants