Skip to content

PPC64LE DSA: verify by one joint power g^u1 y^u2 (two-bit windows) - #4662

Merged
alex merged 1 commit into
mainfrom
claude/ppc64le-dsa
Nov 8, 2026
Merged

alex merged 1 commit into
mainfrom
claude/ppc64le-dsa

Conversation

@alex

@alex alex commented Nov 8, 2026 •

Copy link
Copy Markdown
Member

Part of #4141 (finding 7 of the PPC64LE audit). This PR changes no Spec/ or TCB/ file and no Rust code outside the generated PPC64LE crate.

What was slow

Impl/Dsa/PPC64LE/Verify.lean's combine computed g^u1 mod p and y^u2 mod p with two separate bit-serial ModExp.powSecret calls, each doing a square and a multiply for every bit, then multiplied the two results. That is 4 Montgomery multiplications modulo p per bit of q.

What changed

  • combine (Impl/Dsa/PPC64LE/Verify.lean) computes g^u1 y^u2 mod p with one joint power, the way RISC-V does (Impl/Dsa/RISCV64/Verify.lean):

    • It builds a table of g^i y^j R mod p for i, j < 4 in arrays 8–23 (jointTable).
    • For each pair of bits of u1 and u2 (jointWindow), it does two squares and one multiplication by the entry those bits select. The entry is read by ModExp.select, the four-bit windows' masked scan of every entry.
    • u1's bytes are read through r30 and u2's through r25, so products and the buffer layout are unchanged.

    That is 1.5 multiplications per bit, plus the selection, instead of 4. The code stays constant time (Verify.body's taint_decide is unchanged).

  • Proof (Proof/Dsa/PPC64LE/VerifyComb.lean) follows RISC-V's VerifyComb.lean over the PPC64LE four-bit windows' working space (Win.WCtx, Win.mont, Win.select_ok, Win.copy_ok). It covers jointTable_ok, jointWindow_ok, jointByte_ok and jointLoop_ok, then combine_ok. combine_ok's statement, which VerifyBody uses, is unchanged. The frame lemmas that Sign/Gk.lean and Derive/Y.lean use stay in this file.

  • powP (signing, key derivation) is unchanged; moving it to powWin is a separate PR.

Numbers

Benchmarks run 42510853830: POWER9, dsa, groups dsa_verify_q[0-9]+ dsa_verify_cold_q[0-9]+, base = main at a07cdef, one run of each side.

Benchmark Base Head Change OpenSSL Head vs OpenSSL
dsa_verify_q160/1024 637.50 µs 420.53 µs 34.0% faster 98.51 µs 4.3×
dsa_verify_q160/2048 2.42 ms 1.56 ms 35.4% faster 292.08 µs 5.4×
dsa_verify_q224/2048 3.01 ms 1.81 ms 39.9% faster 390.05 µs 4.6×
dsa_verify_q256/2048 3.32 ms 1.93 ms 41.7% faster 438.19 µs 4.4×
dsa_verify_q256/3072 7.20 ms 4.12 ms 42.8% faster 892.19 µs 4.6×
dsa_verify_cold_q160/1024 1.24 ms 1.03 ms 17.4% faster 118.77 µs 8.6×
dsa_verify_cold_q160/2048 4.80 ms 3.97 ms 17.4% faster 316.84 µs 12.5×
dsa_verify_cold_q224/2048 6.00 ms 4.79 ms 20.2% faster 407.34 µs 11.8×
dsa_verify_cold_q256/2048 6.58 ms 5.19 ms 21.1% faster 462.37 µs 11.2×
dsa_verify_cold_q256/3072 14.30 ms 11.26 ms 21.3% faster 922.26 µs 12.2×

The cold variants still run the key import's bit-serial g^q and y^q checks. The next PR moves those, signing and key generation to the four-bit windows. The rest of the gap is the Montgomery multiplication itself, which the bignum workstream is working on.

Checks

  • lake build (every module) and Emit.lean --check pass. check_lean_public_imports.py is OK on both changed modules.
  • Every step of the Static checks job passes, with check_lean_single_importer.py --base origin/main.
  • cargo build --release --target powerpc64le-unknown-linux-gnu --lib builds the regenerated crate. CI's ppc64le jobs run the tests (Wycheproof and CAVP DSA verification).

🤖 Generated with Claude Code

https://claude.ai/code/session_01TKUFHEf743DNZVAyToasZ6

Verification computed g^u1 mod p and y^u2 mod p by two separate
bit-at-a-time exponentiations (`powSecret`: a square and a multiplication
per bit), then their product. It now computes g^u1 y^u2 mod p by one joint
power, as RISC-V does: a table of g^i y^j R mod p for i, j < 4 in arrays
8-23, then for each pair of bits of u1 and u2 two squares and one
multiplication by the entry they select (`ModExp.select`, the four-bit
windows' masked scan). That is 1.5 Montgomery multiplications per exponent
bit in place of 4.

The proof (`VerifyComb.lean`) follows RISC-V's, over the PPC64LE four-bit
windows' working space (`Win.WCtx`, `Win.select_ok`); `combine_ok`'s
statement is unchanged. No change to the TCB, the specs or the Rust code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TKUFHEf743DNZVAyToasZ6
@github-actions github-actions Bot added the untrusted-only This changes exclusively implementations and proofs, and thus is entirely formally verified. label Nov 8, 2026
@alex
alex added this pull request to the merge queue Nov 8, 2026
Merged via the queue into main with commit 24da64c Nov 8, 2026
24 checks passed
@alex
alex deleted the claude/ppc64le-dsa branch November 8, 2026 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

untrusted-only This changes exclusively implementations and proofs, and thus is entirely formally verified.

Development

Successfully merging this pull request may close these issues.

2 participants