Repository navigation
PPC64LE secp256k1: public keys and RFC 6979 signatures by the signed seven-bit comb - #4816
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TKUFHJ728Kwktcff5BR2sx
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TKUFHJ728Kwktcff5BR2sx
…y the comb) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TKUFHJ728Kwktcff5BR2sx
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). 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,publicKeySecp256k1CombandsignSecp256k1Comb.Proof/Secp256k1/PPC64LE/Comb.lean: the comb's configuration, the table's shape (secp256k1Comb7_length,_rows, which nothing else imports), andcomb_generator_ok.Proof/EcKey/PPC64LE/Secp256k1/Comb.leanandProof/Ecdsa/PPC64LE/Secp256k1/Comb.lean:Verifiedwith the table as a constant (Abi.withConsts), and constant time bytaint_decidewithtaintSym.cs := secp256k1CombConsts). Its registration requires thatVG_SECP256K1_COMBis not one of the HMAC table's function names.Verified. The crate'sa = 0point functions now live with ECDH's module, their only remaining caller.No TCB or Spec change.
Why the general addition, and not the
a = 0oneThe comb's additions use
vg_secp256k1_point_add(Algorithm 1 of Renes, Costello and Batina), notvg_secp256k1_point_a0_add_affine(Algorithm 8). Algorithm 8 takes its second point to be affine. A window equal toH = 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 oldRafter 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 buildandEmit.leanpass on this tree. The only crate changes are secp256k1's, incrates/verified-garbage-asm-powerpc64le.check_lean_public_imports.pyon the edited modules.Benchmark
Benchmarks run 42617612912, scoped to
arches=powerpc64,modules=ecdsa_secp256k1,groups=ec_secp256k1_public_key ecdsa_secp256k1_sha256_sign, with base 55fe2e3:ec_secp256k1_public_key/65ecdsa_secp256k1_sha256_sign/64ecdsa_secp256k1_sha256_sign/1024ecdsa_secp256k1_sha256_sign/16384🤖 Generated with Claude Code
https://claude.ai/code/session_01TKUFHJ728Kwktcff5BR2sx