Repository navigation
PPC64LE brainpoolP256r1, P384r1 ECDH: [d]P by four-bit windows for any a - #4731
Merged
Merged
Conversation
`vg_ecdh_brainpoolp{256,384}r1` computed `[d]P` with the Montgomery
ladder. They now use the four-bit windows of `Impl/Ecdsa/PPC64LE/Window.lean`
(#4712) for a curve with any `a`: `Impl/Ecdsa/PPC64LE/WindowA.lean` has the
same table, nibbles, scan and loop, with the complete addition for any `a`
(`rcb`, `3 b` at `B3P`) and the Jacobian doubling for any `a` (`dblJa`).
`dblJa` moves from RISC-V's `Impl/Ecdsa/RISCV64/WindowA.lean` to
`Impl/Weierstrass/JacDblA.lean`, so that both targets share it and its
proof (`Proof/Weierstrass/JacDblA.lean`); RISC-V's code is unchanged.
The proofs (`Proof/Ecdsa/PPC64LE/<Curve>/Window.lean`) are P-224's and
P-384's (#4715, #4719) with `Rep.add` and `InvJ.dblA'` in place of the
lemmas for `a = -3`; the ECDH glue is theirs. The crates follow.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TKUFHFbSpgWBYWAsEnfUks
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TKUFHFbSpgWBYWAsEnfUks
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 (the PPC64LE audit). Before this PR, on PPC64LE,
vg_ecdh_brainpoolp256r1andvg_ecdh_brainpoolp384r1computed[d]Pwith the Montgomery ladder, at 1.6–2.2× OpenSSL in the audit. They now use #4712's four-bit windows, for a curve with anya, and are about 1.9× faster.brainpoolP512r1 needs the 3-bit layout of #4722 (
Window3.lean), because a 16-entry table of 8-word points doesn't fit in the working space. It will follow in a separate PR.What changes
Impl/Ecdsa/PPC64LE/WindowA.lean(new): the windows ofImpl/Ecdsa/PPC64LE/Window.leanfor anya, as RISC-V'sImpl/Ecdsa/RISCV64/WindowA.leanis for RISC-V's.Window.Cfg'sentry,select,copyPtand points.a(rcb, which readsaatAPand3 batB3P) instead ofrcb3.a(dblJa) instead ofdblJ.Window.lean, which four curves use, is unchanged.dblJamoves from RISC-V'sImpl/Ecdsa/RISCV64/WindowA.leantoImpl/Weierstrass/JacDblA.lean, so both targets share it and its proof (Proof/Weierstrass/JacDblA.lean). RISC-V's references now name it there. RISC-V's generated code is unchanged.Proof/Ecdsa/PPC64LE/<Curve>/Window.lean(new): these are P-224's and P-384's proofs (PPC64LE P-224 ECDH: [d]P by four-bit windows #4715, PPC64LE P-384 ECDH: [d]P by four-bit windows #4719), for 4 and 6 words.a = -3, these use the ones for anya: completeness for anya(Rep.add) with3 batB3P, andInvJ.dblA'withaatAP, which each doubling now takes.Impl/Ecdh/<Curve>/PPC64LE.leanandProof/Ecdh/PPC64LE/<Curve>/Verified.lean:exchangeWithwith the windows, andwin_mulPowOk, as in P-224's and P-384's. Constant time istaint_decideon the new literal.No TCB or Spec change. No
sorry,native_decide,bv_decideor new axioms. No Rust change, and no new tests: the curves' Wycheproof and RFC 7027 vectors already cover ECDH.Testing
lake buildandEmit.leanpass. The only crate changes areecdh_brainpoolp{256,384}r1.rsincrates/verified-garbage-asm-powerpc64leand their assembly.check_lean_public_imports.pyand the ppc64le cross-build pass.Benchmark
Benchmarks run 42523348043:
arches=powerpc64,ecdh_brainpoolp256r1andecdh_brainpoolp384r1, base27804a41, on POWER9.ecdh_brainpoolp256r1/32ecdh_brainpoolp384r1/48🤖 Generated with Claude Code
https://claude.ai/code/session_01TKUFHFbSpgWBYWAsEnfUks