Repository navigation
PPC64LE FFDH parameter candidates: trial division only, p's before q's - #4660
Merged
Merged
Conversation
vg_ffdh_parameter_candidate_sieved no longer runs the bit-serial sieve of the 53 odd primes below 256 on p and on q before RSA's trial division: the table's first 53 entries are those primes, so trial division, which stops at the first divisor, already rejects what the sieve did (trial_shape_iff). q is made and divided only once p's trial division passed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TKUFHGTYqNsecxgCdT9ZaD
This was referenced Nov 8, 2026
This was referenced Nov 9, 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.
Finding 3 of the PPC64LE audit: FFDH parameter generation on ppc64le is 92× OpenSSL with g = 5 and 13× with g = 2.
What it changes
vg_ffdh_parameter_candidate_sieved(Impl/Ffdh/PPC64LE/ParameterCandidate.lean) ran, on every candidate that passed the generator's congruence:smallMod, about 10 instructions per bit) by each of the 53 odd primes below 256, on p and again on q, with no early exit;The first 53 entries of RSA's table are exactly those 53 primes, so step 1 rejected nothing that step 2 doesn't. This PR:
At 512 bits each sieve cost about 270k instructions, which is most of the per-candidate cost. That explains why g = 5, whose congruence passes 2/5 of odd candidates against g = 2's 1/12, was 6× slower.
Proof
MainShape.trial_sieve: trial division by at least 53 entries clears the sieve.trial_shape_iff: the congruence, q's parity and the two trial divisions pass exactly whenSpec.Ffdh.sievedParameterCandidate's shape checks do.main_okandmain_ctfollow the new control flow. q's checks are now a branch (mainQ), and its condition (pOk) is a function of the public candidate.No TCB or spec change. No Rust change: only the generated
vg_ffdh_parameter_candidate_sievedchanges.Checks
lake build: everything.Emit.lean: in full, only this function's files change.check_lean_public_imports.pyon the edited modules.Static checkssteps.ppc64le correctness is tested by CI's ppc64le jobs.
Benchmark
Benchmarks run 42509875481: powerpc64,
modules=ffdh,groups=ffdh_parameters_g(2|5), base 413d7b9.ffdh_parameters_g2/64ffdh_parameters_g5/64The audit's OpenSSL times were 80 ms (g = 2) and 70 ms (g = 5). Stacked follow-ups:
smallMod;🤖 Generated with Claude Code
https://claude.ai/code/session_01TKUFHGTYqNsecxgCdT9ZaD