Repository navigation
PPC64LE ECDSA: verification's [u]G + [v]Q by one chain of doublings - #4747
Merged
Merged
Conversation
|
This pull request has conflicts with Posted by |
For curves of at most six words, vg_ecdsa_<curve>_verify computes [u]G + [v]Q by one joint double-and-add (Point.JointCfg.joint) in place of two ladders and the complete addition: per bit of u and v it doubles R once and adds O, G, Q or G + Q, chosen branch-free by the bits' masks, so two point operations per bit instead of four, and the constant-time proof stays the taint check from the pointers. P-521 and brainpoolP512r1 keep the ladders. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TKUFHHNk9SreF92JBY2H8M
alex
force-pushed
the
claude/ppc64le-ecdsa-verify
branch
from
November 8, 2026 21:49
ca49fc9 to
f0d11f7
Compare
alex
enabled auto-merge
November 8, 2026 21:53
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 the PPC64LE audit, #4141 (ECDSA verification).
On PPC64LE,
vg_ecdsa_<curve>_verifyused to compute[u]G + [v]Qwith two ladders and a complete addition. That is four point operations per bit. For the curves of at most six words (P-192, P-224, P-256, P-384, secp256k1, brainpoolP256r1, brainpoolP384r1), it now uses one joint double-and-add,Point.JointCfg.joint(Impl/Weierstrass/PPC64LE/Joint.lean):G + Qonce.Ris doubled once. ThenO,G,QorG + Qis added, chosen by masks ofu's andv's bits. The selection isT = u ? G : O,D = u ? G+Q : Q, thenv ? D : T.The selection is branch-free, so the constant-time proof stays the existing
taint_decidefrom the pointers, and no contract changes.P-521 and brainpoolP512r1 (more than six words, where the point functions don't apply) keep the ladders:
points := if c.n ≤ 6 then joint c else ladders c.Proofs
Proof/Weierstrass/PPC64LE/Joint.lean(new, generic over the curve):acc,acc_step, withacc j = [u >>> j]G + [v >>> j]Q.dbl_ok,selU_ok,selV_ok,add_ok,body_ok.loop_ok, bycountLoop_ok), the setup (setup_ok), the start (start_run,start_ok), andjoint_ok.joint_okstates thatRrepresents[u]G + [v]Qand that onlypowClobandjointWchange.Proof/Ecdsa/Verify/PPC64LE/Points.lean:jointLay: the slots, withG + QinK/D/Eandv's bits atbitsAt n 3.jointPts_ok, for the new code.ladders_ok: the old proof, renamed.points_ok: splits onc.n ≤ 6.Pts.ptnow statesRep R ([u]G + [v]P)directly. The ladder branch gets it throughRep.add, andMain.leanuses it as is.No TCB, Spec or registration changes.
Generated crate. Only PPC64LE changes:
ecdsa_<curve>verification is rewritten.internal/vg_secp256k1_point_addandinternal/vg_secp256k1_point_doubleare new. secp256k1's verification now calls the generic point functions, where its ladders called thea = 0ones.Testing
cargo test --target powerpc64le-unknown-linux-gnu --release ecdsapasses for all nine curves: Wycheproof, CAVP P-256 and RFC 7027.main(PPC64LE P-256: public keys by the signed seven-bit comb #4729 included):lake build(all modules) passes.check_lean_public_imports.pypasses on the edited modules.cargo fmt --checkandcargo clippy --target powerpc64le-unknown-linux-gnu -- -D warningspass.Benchmarks
Run 42526032024:
arches=powerpc64, the seven curves'ecdsa_*_verifygroups, basee4c4e66a. It measured the head before the rebase onto #4729, which doesn't touch verification.ecdsa_p192_sha256_verify/64ecdsa_p224_sha224_verify/64ecdsa_p256_sha256_verify/64ecdsa_p384_sha384_verify/64ecdsa_brainpoolp256r1_sha256_verify/64ecdsa_brainpoolp384r1_sha384_verify/64ecdsa_secp256k1_sha256_verify/64The other sizes (1024 and 16384 bytes) and P-256 with SHA-384 show the same changes: 45–48% faster, and 15–16% for secp256k1. secp256k1 gains less because its ladders used the faster
a = 0point functions (vg_secp256k1_point_a0_*), and the joint loop uses the generic ones.Follow-ups, separately:
a = 0point functions for secp256k1.G, and the sliding-window inverses of PPC64LE: inverses by sliding windows of p − 2 and n − 2 #4714.🤖 Generated with Claude Code
https://claude.ai/code/session_01TKUFHHNk9SreF92JBY2H8M