Skip to content

PPC64LE FFDH parameter candidates: the generator's congruence from the digit sum - #4677

Merged
alex merged 3 commits into
mainfrom
claude/ppc64le-ffdh-residue
Nov 8, 2026
Merged

alex merged 3 commits into
mainfrom
claude/ppc64le-ffdh-residue

Conversation

@alex

@alex alex commented Nov 8, 2026 •

Copy link
Copy Markdown
Member

Follows #4660 (merged). This is the second step on finding 3 of the PPC64LE audit.

What it changes

After #4660, each candidate's first check, the generator's congruence (residue), dominates g = 2. It reduced p bit-serially modulo 24 or 10: about 10 instructions per bit of p, around 5,000 at 512 bits, on every candidate.

Now:

  • p mod 8 comes from its low digit.
  • p mod 3 (g = 2) or p mod 5 (g = 5) comes from the sum of p's 32-bit digits. 2³² ≡ 1 modulo both, so the sum is congruent to p. The sum is then reduced by mulhdu with the reciprocal ⌈2⁶⁵/3⌉ or ⌈2⁶⁶/5⌉, which is exact for every 64-bit value.

That is about 4 instructions per digit plus 20. goodRes and the proofs that use it are unchanged.

Search's smallMod, trial and sieve have no other user, so they and their proofs (Proof/MillerRabin/PPC64LE/Search/{SmallMod,Sieve}.lean) are deleted. bad_post moves to Residue.lean.

Proof (Proof/Ffdh/PPC64LE/ParameterCandidate/Residue.lean)

  • val32_mod: a number is congruent to its digit sum modulo any d with 2³² mod d = 1.
  • digitSum_ok: the loop.
  • mod3_bv and mod5_bv, with quot3 and quot5 by omega: the reciprocal remainder.
  • flag2 and flag5, by decide over the bounded residues: the flags.
  • residue2_ok, residue5_ok and residue_ok.

The constant-time proof of residue is unchanged: every branch is still on the public generator.

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.

After rebasing onto main (which changed the PPC64LE encoder), the function's generated .rs was regenerated in its own commit.

Benchmark

Benchmarks run 42513095210: powerpc64, modules=ffdh, groups=ffdh_parameters_g(2|5), base 5fd5181 = #4660's head. Medians:

Benchmark Base (#4660) Head Change
ffdh_parameters_g2/64 208.37 ms 115.04 ms 44.8% faster
ffdh_parameters_g5/64 448.49 ms 313.80 ms 30.0% faster

main before #4660 took 1.09 s and 6.43 s; the audit's OpenSSL times were 80 ms and 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
Base automatically changed from claude/ppc64le-ffdh-params to main November 8, 2026 20:03
@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown

This pull request has conflicts with main, found after c0cf184 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.

…e digit sum

residue no longer reduces p bit-serially modulo 24 or 10 (about ten
instructions per bit of p, on every candidate). p modulo 8 is its low
digit's; p modulo 3 or 5 is the sum of its 32-bit digits' (2^32 ≡ 1),
reduced by a multiplication by the divisor's reciprocal (mulhdu),
exact for every 64-bit sum (mod3_bv, mod5_bv).

Search's smallMod, trial and sieve, and their proofs, are no longer
used, and are deleted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TKUFHGTYqNsecxgCdT9ZaD
@alex
alex force-pushed the claude/ppc64le-ffdh-residue branch from 14275dd to 80ce837 Compare November 8, 2026 20:22
@alex
alex marked this pull request as ready for review November 8, 2026 20:22
@alex
alex enabled auto-merge November 8, 2026 20:32
@alex
alex added this pull request to the merge queue Nov 8, 2026
Merged via the queue into main with commit 4b6eb50 Nov 8, 2026
21 checks passed
@alex
alex deleted the claude/ppc64le-ffdh-residue branch November 8, 2026 20:40
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