Repository navigation
Conversation
P-521's sixteen entries of four-bit windows do not fit the working space past the tables of bits, so its windows take three bits (Impl/Ecdsa/PPC64LE/Window3.lean): a table of [e]P for e < 8, then for each of the 176 windows three Jacobian doublings and one complete addition of the entry selected by a constant-time scan. The proof is P-256's (Proof/Ecdsa/PPC64LE/P256/Window.lean) on P-521's field and nine-word layout. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TKUFHH4GefHP3pmPRSL4N4
brainpoolP512r1's sixteen entries of four-bit windows (192 bytes each) do not fit the working space past the tables of bits, so its windows take three bits, as P-521's do (Window3.lean), with the complete addition and the Jacobian doubling for any a (rcb, dblJa), as brainpoolP384r1's four-bit windows do (WindowA.lean): Impl/Ecdsa/PPC64LE/Window3A.lean. The scalar's 512 bits are 170 windows and two bits above them: a 171st window from R = O would read a bit past the table of bits (the first bit of the table of p - 2's). So R starts at the entry of the top two bits (mul3top), and the 170 windows below them follow. The proof is P-521's on brainpoolP512r1's field and eight-word layout, with the doublings and the addition for any a. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TKUFHFbSpgWBYWAsEnfUks
Regenerated with the full emitter. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TKUFHFbSpgWBYWAsEnfUks
alex
force-pushed
the
claude/ppc64le-ecdh-p521
branch
from
November 8, 2026 22:48
bf9c73c to
5f5d77c
Compare
|
This pull request has conflicts with Posted by |
Member
Author
|
Replaced by the PR for Generated by Claude Code |
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.
Part of #4141 (the PPC64LE audit, finding 1). Stacked on #4722 (P-521 ECDH, three-bit windows), so it stays a draft until #4722 merges. It replaces #4761, which carried #4719's and #4722's commits before #4722 was restacked. These two commits are #4761's, cherry-picked unchanged.
vg_ecdh_brainpoolp512r1on PPC64LE computed[d]Pwith the Montgomery ladder. It now uses three-bit windows with the formulas for anya.Why three bits, and why start from the top two bits
R = Owould read bit 512 in its top window. That is one byte past the table of bits, the first entry of the next table (p − 2's bits), which is 1. Instead,Rstarts at the table's entry for the top two bits (top2, then the usual masked scan, thenR = D), and the 170 windows below follow.What changes
Impl/Ecdsa/PPC64LE/Window3A.lean(new):build3,trip,step3andmul3top.a(rcbwithaatAPand3batB3P;dblJa).Window.Cfg.entry,select3andscanEntry.r3plus a constant (plus3 jfor a window's bits).Proof/Ecdsa/PPC64LE/BrainpoolP512r1/Window.lean(new):mul_ok, which provesR = [k]Pfor everyk < 2^512.asteps (InvJ.dblA',Rep.add).top2_okandtop2_eqfor the start, whereRholds[k >>> 510]Q, which is the windows' invariant atj = 170.Impl/Ecdh/BrainpoolP512r1/PPC64LE.lean:exchangeWithwithWindowA.Cfg.mul3top … B3P.Proof/Ecdh/PPC64LE/BrainpoolP512r1/Verified.lean:win_mulPowOk, as P-521's (PPC64LE P-521 ECDH: [d]P by three-bit windows #4722) with3bfromFixed(F'.b3p).Verifiedgoes throughexchangeWith_ok, and constant time is checked bytaint_decideon the new literal.No TCB, Spec or Rust change. The only crate change is
ecdh_brainpoolp512r1.rsand its assembly.Testing
lake buildandEmit.leanpass onmainwith PPC64LE P-384 ECDH: [d]P by four-bit windows #4719 and PPC64LE P-521 ECDH: [d]P by three-bit windows #4722, and the full emitter's output is committed. Since then PPC64LE P-521 ECDH: [d]P by three-bit windows #4722's window code hasn't changed, andmainhas had no TCB or emitter change.check_lean_public_imports.pypass.Benchmark
A scoped run of this code is queued on #4761's branch:
arches=powerpc64,modules=ecdh_brainpoolp512r1, basebd7184fc(main, whosevg_ecdh_brainpoolp512r1is the ladder). I'll add its results here.Generated by Claude Code