Repository navigation
FFDH parameter generation on AArch64: the sieve stops at the first divisor, and p is rejected before q's sieve - #5119
Merged
Conversation
…st divisor The implementation and the sieve's proof (Sieve.lean) build. CTPieces, Main and CTMain do not build yet. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TKUFHFQ9fhoiRgxoBRku5u
…q's, proofs The candidate's proofs and the FFDH registration build. Not yet done: the full build, the regenerated crate and the checks. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TKUFHFQ9fhoiRgxoBRku5u
…visor A candidate that passed the generator's congruence ran RSA's whole trial division on p (512 or 1024 table entries) and then on q, whatever it found, and only then looked at the result. Most candidates have a small factor. The sieve now stops after the first word of the table (four entries) with a divisor, and a p with one is rejected before q's sieve. The result is the same (Spec.Ffdh.sievedParameterCandidate): a divisor among the words read is one among all the entries, so the flag is the whole division's. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TKUFHFQ9fhoiRgxoBRku5u
alex
pushed a commit
that referenced
this pull request
Nov 15, 2026
…d crate Builds in full, and the emitter's check passes, before restacking onto main (step 1 merged as #5119). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TKUFHFQ9fhoiRgxoBRku5u
alex
pushed a commit
that referenced
this pull request
Nov 15, 2026
…d crate Builds in full, and the emitter's check passes, before restacking onto main (step 1 merged as #5119). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TKUFHFQ9fhoiRgxoBRku5u
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.
FFDH parameter generation on AArch64 is 4.1 times as fast with g = 5 and 1.9 times with g = 2. This is the first step on finding 3 of the ARM64 audit, where it was 13–21× and 4× OpenSSL. x86-64 did this step in #4507 and PPC64LE in #4660.
Cause
Every candidate that passed the generator's congruence (40% of them for g = 5, 8% for g = 2) ran the whole trial division on p, 512 table entries, and then the whole one on q, whatever either found. Most candidates have a small factor among the first entries.
Change
Impl/Ffdh/AArch64/ParameterCandidate.lean: after each table word,sieveStopzeroes the count of words left under the mask of a divisor found, which ends the loop.mainchecks the flag after p's sieve and rejects the candidate there; what follows ismainQ.Proof/Ffdh/AArch64/…/Sieve.lean:stopN, the number of words read, andanyPre_stopN: a divisor among the words read is one among all the entries.sieve_ok's statement is unchanged, so nothing after it changed.CTPieces.lean,CTMain.lean: the sieve's relational proof is indexed by the word it stops at; one more stage and branch for the new check.Main.lean,ShapeOk.lean,Generation/Search/Verified.lean: the new reject branch.vg_ffdh_parameter_candidate_sievedalone.No change to
Spec/orTCB/.Measurement
Benchmarks run 43738047927, against
mainat b778027, on the Neoverse N2 runner (512-bit parameters from a fixed tape):ffdh_parameters_g2/64ffdh_parameters_g5/64In the audit OpenSSL took 43–67 ms for g = 5 and 47–52 ms for g = 2 (its own draws, so the comparison is approximate): this leaves about 3–5× and 2×.
What is left
AArch64 still lacks the other steps x86-64 and PPC64LE took, in order of expected gain:
Tests
Under
qemu-aarch64: the eight FFDH tests oftests/cavppass,safe_prime_parameter_generationamong them (it generates 512-bit parameters for both generators and exchanges keys with them), and the sixteen FFDH unit tests, withpublished_candidates_and_tape_consumption,rejected_candidates_are_consumedandcomposite_q_at_modulus_width_boundaries. That is emulation; CI is the first run on an ARM64 CPU. No test was added.Generated by Claude Code