Repository navigation
PPC64LE P-256 ECDH: [d]P by four-bit windows - #4712
Merged
Merged
Conversation
vg_ecdh_p256 computed [d]P by the Montgomery ladder of complete additions over every bit. It now uses RISC-V's four-bit windows: a table of [e]P for e < 16 (built by complete additions for a = -3), then per window four Jacobian doublings and one complete addition of the entry selected by a constant-time scan of the table under masks. ECDH's stages take any multiplication that meets MulPowOk (exchangeWith_ok); the ladder's curves go through it unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TKUFHH4GefHP3pmPRSL4N4
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TKUFHH4GefHP3pmPRSL4N4
alex
pushed a commit
that referenced
this pull request
Nov 8, 2026
P-256's ECDH windows (#4712) now take Z^(p-2) by the addition chain too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TKUFHJ728Kwktcff5BR2sx
This was referenced Nov 8, 2026
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 (PPC64LE audit, finding 1, the variable-base half).
vg_ecdh_p256computed[d]Pwith the Montgomery ladder: one complete addition and one complete doubling for each of the 256 bits (863 µs on POWER9, 8.5× OpenSSL).What changes
[d]Pnow uses RISC-V's four-bit windows (Impl/Ecdsa/RISCV64/Window.lean), ported to PPC64LE's layout and field calls:Impl/Ecdsa/PPC64LE/Window.lean: the code, generic over the signature's layout (the slots ofPand ofb R mod pare parameters).[e]Pfore < 16is built by complete additions fora = -3(rcb3). It sits past the tables of bits, atbitsAt n 3.toJ, 4 ×dblJ,fromJ, withY = 1whereZ = 0). It then adds the selected entry with one complete addition.d's bits. It is selected by scanning all 16 entries under the mask ofnibble = e, so the only branch is on the public counter and every address isr3plus a constant.Proof/Ecdsa/PPC64LE/P256/Window.lean:mul_ok, which provesR = [k]Pfor everyk < 2^256. The proof covers the field programs on slots,R = 16 R(InvJ), the table, the scan, and the loop (wstep).MulPowOk(Impl/Ecdh/PPC64LE.lean'sexchangeWith,Proof/Ecdh/PPC64LE/Main.lean'sexchangeWith_ok). The ladder goes through it too (qMul_mulPowOk), so every other curve's ECDH is unchanged.Proof/Ecdh/PPC64LE/Verified.lean:win_mulPowOkcomposes the window with the powerZ^(p-2). P-256'sVerifiednow uses it. Constant time is checked bytaint_decideon the new code's literal, as before.ECDH is self-contained here; it does not depend on #4675's
GeneratorPost. Signing, public keys and verification are untouched: other sessions own those.No TCB or Spec change. No
sorry,native_decide,bv_decideor new axioms.Testing
lake buildandEmit.lean --checkpass. The only crate change iscrates/verified-garbage-asm-powerpc64le/src/ecdh_p256.rsand its assembly.check_lean_public_imports.pypass, andcargo fmt --checkis clean.Benchmark
Benchmarks run 42519323905, with
arches=powerpc64,modules=ecdh_p256and base b7c10de, on POWER9:ecdh_p256/32ec_p256_public_key/65🤖 Generated with Claude Code
https://claude.ai/code/session_01TKUFHH4GefHP3pmPRSL4N4