Skip to content

PPC64LE P-521 ECDH: [d]P by three-bit windows - #4722

Merged
alex merged 3 commits into
mainfrom
claude/ppc64le-ecdh-p521
Nov 8, 2026
Merged

alex merged 3 commits into
mainfrom
claude/ppc64le-ecdh-p521

Conversation

@alex

@alex alex commented Nov 8, 2026 •

Copy link
Copy Markdown
Member

Part of #4141 (PPC64LE audit, finding 1). Follows #4719 (P-384), #4715 (P-224) and #4712 (P-256).

vg_ecdh_p521 computed [d]P with the Montgomery ladder of complete additions (4.83 ms on POWER9, 12× OpenSSL). P-521's coordinates are nine words. A four-bit window's sixteen entries (16 × 216 bytes) do not fit the working space past the tables of bits (5824–8192), so P-521 uses three-bit windows instead.

  • Impl/Ecdsa/PPC64LE/Window3.lean: the three-bit variant of PPC64LE P-256 ECDH: [d]P by four-bit windows #4712's windows, reusing its table additions, copies, masks and entry scan.
    • A table of [e]P for e < 8 takes 1728 bytes, from 5824 to 7552.
    • Each of the 176 windows over the 528 bits of a 66-byte scalar does R = 8 R (three Jacobian doublings), reads three bits of the table of bits, scans the eight entries under masks, and does one complete addition.
    • As before, the only branch is on the public counter, and every address is r3 plus a constant.
  • Proof/Ecdsa/PPC64LE/P521/Window.lean: mul_ok, which proves R = [k]P for every k < 2^528. It is P-256's proof on P-521's field and nine-word layout, with the three-bit window step (wstep with 8, nib3_eq).
  • Proof/Ecdh/PPC64LE/P521/Verified.lean: win_mulPowOk and the Verified theorem through exchangeWith_ok. As in PPC64LE: inverses by sliding windows of p − 2 and n − 2 #4762 for the other curves, Z^(p-2) is taken by the addition chain (chainPow_ok). Constant time is checked by taint_decide on the new literal.

Signed four-bit windows (eight entries, Booth digits) would save about 10% more. They need the recoding and negation proofs, so they are left for later.

No TCB or Spec change.

Testing

Benchmark

POWER9, run 42521138146 (before the rebase onto #4762's chain), scoped to arches=powerpc64, modules=ecdh_p521:

Benchmark Base Head Change
ecdh_p521/66 4.81 ms 2.34 ms 51.3% faster

🤖 Generated with Claude Code

https://claude.ai/code/session_01TKUFHH4GefHP3pmPRSL4N4

@alex
alex force-pushed the claude/ppc64le-ecdh-p384 branch from 53a2d68 to db2861d Compare November 8, 2026 20:40
@alex
alex force-pushed the claude/ppc64le-ecdh-p521 branch from c9b8c61 to 5f78b1f Compare November 8, 2026 20:40
@alex
alex force-pushed the claude/ppc64le-ecdh-p384 branch from db2861d to 576c776 Compare November 8, 2026 21:46
@alex
alex force-pushed the claude/ppc64le-ecdh-p521 branch from 5f78b1f to ebdef40 Compare November 8, 2026 21:46
Base automatically changed from claude/ppc64le-ecdh-p384 to main November 8, 2026 22:01
@alex
alex force-pushed the claude/ppc64le-ecdh-p521 branch from ebdef40 to bf9c73c Compare November 8, 2026 22:01
@alex
alex marked this pull request as ready for review November 8, 2026 22:01
@alex
alex enabled auto-merge November 8, 2026 22:07
@alex
alex added this pull request to the merge queue Nov 8, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 8, 2026
@alex
alex added this pull request to the merge queue Nov 8, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Nov 8, 2026
@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown

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

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
ec_p521.rs declares the internal p521 field functions since #4762; ecdh_p521.rs refers to them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TKUFHH4GefHP3pmPRSL4N4
@alex
alex enabled auto-merge November 8, 2026 23:00
@alex
alex added this pull request to the merge queue Nov 8, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 8, 2026

alex commented Nov 8, 2026

Copy link
Copy Markdown
Member Author

The merge queue's failure (run 42533231916) is not this PR's. The failing job is the x86-64 Rust (sde -arl), which failed before any test ran: curl: (6) Could not resolve host: downloadmirror.intel.com while downloading Intel SDE. This PR changes only PPC64LE code. All of CI passed on the PR head (eaad41a), so it only needs to be re-queued.


Generated by Claude Code

@alex
alex added this pull request to the merge queue Nov 8, 2026
Merged via the queue into main with commit 66a3329 Nov 8, 2026
21 checks passed
@alex
alex deleted the claude/ppc64le-ecdh-p521 branch November 8, 2026 23:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants