Repository navigation
Conversation
`Z^(p-2)` and `k^(n-2)` were the bit-by-bit power, two multiplications per bit. They are now the chain of the exponent that AArch64's and x86's use (`Impl/Weierstrass/Chain.lean`): a table of the odd powers x, x³, …, x¹⁵ and x², then squarings and a multiplication per window of at most four bits, about 1.2 multiplications per bit (`Impl/Weierstrass/PPC64LE/Chain.lean`, `chainPow_ok`, with `pow_ok`'s postcondition but for the table it writes). The table is the nine slots from `DX`, the ladder's, which nothing reads after it. The signature, the public key and ECDH take `Z^(p-2)` by it (`invP`, through `ladPow_ok`), and the signature `k^(n-2)` (`invN`). Each curve's `CfgOk` checks its chains (`chainCheck`, by `decide`). 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
github-merge-queue
Bot
removed this pull request from the merge queue due to a conflict with the base branch
Nov 8, 2026
|
This pull request has conflicts with Posted by |
Member
Author
|
Replaced by #4749: the same change rebased onto Generated by Claude Code |
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.
Replaces #4714. It's the same change, rebased linearly onto
main(cd0c332) instead of havingmainmerged in. Since #4712 landed, P-256's ECDH windows (win_mulPowOk) takeZ^(p−2)by the chain too, soMulPowOknow statesinvP.Part of #4141 (PPC64LE audit). Every PPC64LE elliptic-curve function inverted by the bit-by-bit power: two Montgomery multiplications per bit of p − 2 (affine conversion) and of n − 2 (the signature's k⁻¹). Once the combs (#4675's stack) shrink the scalar multiplication, those powers are the largest part of a public key or a signature.
What changes
Impl/Weierstrass/PPC64LE/Chain.leangives a power by the exponent's sliding windows:ChainCfg,slide,chainVal(Impl/Weierstrass/Chain.lean), which AArch64 and x86 already use. It works as on AArch64:That is about 1.2 multiplications per bit instead of 2. The exponent is the code's, so nothing depends on secret data.
Proof/Weierstrass/PPC64LE/Chain.lean:chainPow_ok, a port of AArch64's proof onto PPC64LE's calls of the field functions (mulCall_ok). Its postcondition ispow_ok's, except for what it writes (chainW: the result, the nine-slot table, the functions' own space).Impl/Ecdsa/PPC64LE.lean:chainP/invP(Z^(p−2)) andchainN/invN(k^(n−2)). Their tables are the nine slots fromDX, the ladder's temporaries, which nothing reads after the ladder. Callers:invP;invN(Middle.lean).CfgOkgainschainPandchainN, each curve's chains checked bychainCheck(decide +kernel, as AArch64's are).Verification,
Impl/Ecdsa/Verify/PPC64LE.lean, still usespow. Its new owner (the verification session) will switch toinvP/invNin its own PR. The setup still writes the bits of p − 2 and n − 2, which verification reads.No TCB or Spec change.
Testing
lake buildandEmit.leanpass on this tree. The crate changes are only incrates/verified-garbage-asm-powerpc64le: the public key, ECDH andvg_ecdsa_<curve>_sign_kof all nine curves.check_lean_public_imports.pypass.Benchmark
Benchmarks run 42519677222, scoped to
arches=powerpc64, with base bdbde97 (before #4712). Onmainthe ladder still takes most of the time, so the relative gain here is small. In absolute terms it saves about 17 µs per p-inversion on P-256, 120 µs on P-521, and twice that for a signature.ec_p256_public_key/65ecdh_p256/32ecdsa_p256_sha256_sign/64ec_p521_public_key/133ecdh_p521/66ecdsa_p521_sha512_sign/64Generated by Claude Code