Skip to content

PPC64LE secp256k1: public keys and RFC 6979 signatures by the signed seven-bit comb - #4816

Merged
alex merged 3 commits into
mainfrom
claude/ppc64le-secp256k1-comb
Nov 9, 2026
Merged

alex merged 3 commits into
mainfrom
claude/ppc64le-secp256k1-comb

Conversation

@alex

@alex alex commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

Part of #4141 (PPC64LE audit, finding 1). This is the same change as P-256's (#4729, #4780), now for secp256k1.

What changes

secp256k1's [d]G (vg_ec_secp256k1_public_key) and [k]G (vg_ecdsa_secp256k1_sign_k, the core of the RFC 6979 signature) now use the generic comb (Impl/Weierstrass/PPC64LE/TComb.lean) instead of the Montgomery ladder. The comb uses secp256k1's table, the one the other targets already share (Impl/Secp256k1/CombTable7.lean): 37 windows of seven bits, an 18944-word read-only constant.

The files mirror P-256's:

  • Impl/Ecdsa/Secp256k1/PPC64LEComb.lean: secp256k1Comb, secp256k1CombWords, mulGeneratorSecp256k1, publicKeySecp256k1Comb and signSecp256k1Comb.
  • Proof/Secp256k1/PPC64LE/Comb.lean: the comb's configuration, the table's shape (secp256k1Comb7_length, _rows, which nothing else imports), and comb_generator_ok.
  • Proof/EcKey/PPC64LE/Secp256k1/Comb.lean and Proof/Ecdsa/PPC64LE/Secp256k1/Comb.lean: Verified with the table as a constant (Abi.withConsts), and constant time by taint_decide with taintSym.
  • The RFC 6979 core passes the table (cs := secp256k1CombConsts). Its registration requires that VG_SECP256K1_COMB is not one of the HMAC table's function names.
  • Removed: the ladder's secp256k1 public key and signature, their literals and their Verified. The crate's a = 0 point functions now live with ECDH's module, their only remaining caller.

No TCB or Spec change.

Why the general addition, and not the a = 0 one

The comb's additions use vg_secp256k1_point_add (Algorithm 1 of Renes, Costello and Batina), not vg_secp256k1_point_a0_add_affine (Algorithm 8). Algorithm 8 takes its second point to be affine. A window equal to H = 2^(w-1) gives a zero digit, though, and then the comb's entry is the point at infinity, (0 : 1 : 0). Algorithm 8 would treat that as the affine point (0, 1), which is not on the curve. Using it would need a constant-time select of the old R after every addition, and proofs for that select; it could be a follow-up if the saving (about four of the addition's 17 products) is worth it.

Testing

  • lake build and Emit.lean pass on this tree. The only crate changes are secp256k1's, in crates/verified-garbage-asm-powerpc64le.
  • The static checks pass, and so does check_lean_public_imports.py on the edited modules.
  • Locally, under qemu-ppc64le, the secp256k1 tests pass, including RFC 6979's public keys and signatures, and Wycheproof.

Benchmark

Benchmarks run 42617612912, scoped to arches=powerpc64, modules=ecdsa_secp256k1, groups=ec_secp256k1_public_key ecdsa_secp256k1_sha256_sign, with base 55fe2e3:

Benchmark Base Head Change
ec_secp256k1_public_key/65 280.94 µs 58.84 µs 79.1% faster
ecdsa_secp256k1_sha256_sign/64 322.27 µs 79.24 µs 75.4% faster
ecdsa_secp256k1_sha256_sign/1024 324.58 µs 81.81 µs 74.8% faster
ecdsa_secp256k1_sha256_sign/16384 355.10 µs 135.04 µs 62.0% faster

🤖 Generated with Claude Code

https://claude.ai/code/session_01TKUFHJ728Kwktcff5BR2sx

@alex
alex enabled auto-merge November 9, 2026 12:33
@alex
alex added this pull request to the merge queue Nov 9, 2026
Merged via the queue into main with commit b871220 Nov 9, 2026
23 checks passed
@alex
alex deleted the claude/ppc64le-secp256k1-comb branch November 9, 2026 12:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants