Skip to content

PPC64LE P-256: public keys by the signed seven-bit comb - #4729

Merged
alex merged 10 commits into
mainfrom
claude/ppc64le-nist-curves-v2
Nov 8, 2026
Merged

alex merged 10 commits into
mainfrom
claude/ppc64le-nist-curves-v2

Conversation

@alex

@alex alex commented Nov 8, 2026

Copy link
Copy Markdown
Member

Replaces #4675. It's the same change, rebased linearly onto main (cd0c332) instead of having main merged in, because this PR is the base of a stack.

Part of #4141 (PPC64LE audit, finding 1): vg_ec_p256_public_key computed [d]G by the Montgomery ladder, one double, add and select per bit (862 µs on POWER9, 57× OpenSSL).

What changes

[d]G now uses the fixed-base signed comb the other targets share (Impl/P256/CombTable7.lean): 37 windows of seven bits. Each window's entry is selected from a read-only table by scanning all 64 entries under the mask of the digit's magnitude, so timing stays constant. The sign is applied by the field's subtraction, and each window costs one call of the complete addition.

The comb is 32-bit ARM's (Impl/Weierstrass/Arm/TComb.lean, which PPC64LE's ladder layout was ported from), adapted to PPC64LE:

  • Impl/Weierstrass/PPC64LE/TComb.lean: the comb, for any curve whose coordinates fit the point functions' slots (3 to 6 words). P-224 and P-384 can reuse it.
  • Proof/Weierstrass/PPC64LE/TComb.lean: comb_ok, which proves R = [k]G from the table and the scalar's table of bits (the scan, the digits, the sign, the addition, the loop).
  • Proof/P256/PPC64LE/Comb.lean: P-256's configuration, and the comb as the generator of the stages that follow the setup.
  • Proof/EcKey/PPC64LE/P256Comb.lean: the public key with the table as a constant (Abi.withConsts), its constant time (taint_decide with taintSym), and Verified.

The signing and public-key stages now accept any generator that meets GeneratorPost (ladPowWith_ok, stage₂With, publicKeyWith_ok), as on ARM. These changes are proof-only, and the ladder's proofs go through them. The ladder-based P-256 public key and its literal are deleted.

Signing still uses the ladder, because PPC64LE's RFC 6979 wrapper does not yet accept a core with its own table. That is the next PR.

No TCB or Spec change.

Testing

  • lake build and Emit.lean pass on this tree. The only crate change is crates/verified-garbage-asm-powerpc64le (ec_p256, the new consts/vg_p256_comb.rs, and vg_p256_mul moving to the module of its first caller).
  • Static checks and check_lean_public_imports.py pass.
  • Locally, under qemu-ppc64le: the P-256, ECDH and ECDSA tests pass, including Wycheproof and RFC 6979's public keys.

Benchmark

Benchmarks run 42512986586, scoped to arches=powerpc64, modules=ec_p256, groups=ec_p256_public_key, with base 24da64c:

Benchmark Base Head Change
ec_p256_public_key/65 933.64 µs 114.19 µs 87.8% faster

Generated by Claude Code

@alex
alex added this pull request to the merge queue Nov 8, 2026
Merged via the queue into main with commit 4b62f01 Nov 8, 2026
24 checks passed
@alex
alex deleted the claude/ppc64le-nist-curves-v2 branch November 8, 2026 21:37
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