Skip to content

PPC64LE FFDH parameter candidates: q's trial division before p's whole - #4684

Merged
alex merged 1 commit into
mainfrom
claude/ppc64le-ffdh-order
Nov 8, 2026
Merged

alex merged 1 commit into
mainfrom
claude/ppc64le-ffdh-order

Conversation

@alex

@alex alex commented Nov 8, 2026 •

Copy link
Copy Markdown
Member

#4660 and #4677 have merged. This is the third step on finding 3 of the PPC64LE audit, and it is x86-64's "sieve p's first primes before q's".

What it changes

After #4677, g = 5 still spent most of its time in trial division. Its congruence passes 2/5 of odd candidates. For each small prime s, a third of them have p ≡ 1 (mod s), which means s divides q. That was found only after p's whole trial division, which such a p usually survives.

main now runs:

  1. p's trial division by the table's first 16 entries (trialSieveN firstEntries);
  2. q's whole trial division (mainQ);
  3. with p loaded again (shapeP), p's whole trial division (mainP);
  4. the tests.

Each step stops at the first divisor.

Proof

  • Trial.lean: MB.trialA and MB.loopArgs take the count as a parameter. Added MB.countN and trialSieveN_ok.
  • Main.lean: added MB.reshape (p in array 0 again) and trialPrefix_mono (the whole division implies the first 16). main_ok follows the new flow.
  • CTMain.lean: MnC, MnT, MnL, MnE and trialGo take the count as a parameter (trialRest_ct). Added trialSieveN_ct, reshape_ct, mainP_ct and the conditions pOk, qOk and allOk. Each one is a function of the public candidate.

No TCB or spec change. No Rust change.

Checks

  • lake build: everything.
  • Emit.lean: in full, only vg_ffdh_parameter_candidate_sieved changes.
  • check_lean_public_imports.py on the edited modules.
  • The Static checks steps.

Benchmark

Benchmarks run 42514854733: powerpc64, modules=ffdh, groups=ffdh_parameters_g(2|5), base 14275dd = #4677's head. Medians:

Benchmark Base (#4677) Head Change
ffdh_parameters_g2/64 115.03 ms 97.77 ms 15.0% faster
ffdh_parameters_g5/64 313.86 ms 174.10 ms 44.5% faster

The three PRs together, from main before #4660:

main #4660 #4677 #4684 OpenSSL (audit)
g = 2 1,090 ms 211 ms 115 ms 97.8 ms 80 ms
g = 5 6,426 ms 454 ms 314 ms 174 ms 70 ms

🤖 Generated with Claude Code

https://claude.ai/code/session_01TKUFHGTYqNsecxgCdT9ZaD

@github-actions github-actions Bot added the untrusted-only This changes exclusively implementations and proofs, and thus is entirely formally verified. label Nov 8, 2026
@alex
alex force-pushed the claude/ppc64le-ffdh-residue branch from 14275dd to 80ce837 Compare November 8, 2026 20:22
@alex
alex force-pushed the claude/ppc64le-ffdh-order branch 2 times, most recently from 4632a48 to e27fee6 Compare November 8, 2026 20:28
Base automatically changed from claude/ppc64le-ffdh-residue to main November 8, 2026 20:40
@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown

This pull request has conflicts with main, found after 4b6eb50 landed on main: rebase it to resolve them. Before rebasing, see CLAUDE.md on checking how much Lean main changed, and on restacking a stacked pull request.

Posted by .github/workflows/conflicts.yml, once per push to a conflicting pull request.

Most candidates that pass the congruence and p's first trial divisions
fail on q, and a small factor of q (p ≡ 1 mod s) was found only after
p's whole trial division. Now p is divided by the table's first 16
entries (trialSieveN), then q by all of them, and only then, with p
loaded again (MB.reshape), p by all of them.

trialSieve's proofs take the count as a parameter (MB.countN,
trialSieveN_ok, trialRest_ct), and trialPrefix_mono drops the first
entries' check from the shape's conjunction.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TKUFHGTYqNsecxgCdT9ZaD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

untrusted-only This changes exclusively implementations and proofs, and thus is entirely formally verified.

Development

Successfully merging this pull request may close these issues.

2 participants