Repository navigation
AArch64 P-256 verify: build the odd multiples by co-Z arithmetic - #2709
Merged
Merged
Conversation
The verifier's table of Q, 3Q, ..., 15Q is built with ECDH's allocated DBLU and ZADDU blocks: DBLU gives 2Q and Q at one Z, and seven ZADDU steps add 2Q at a shared Z, each returning the next odd multiple and the square and cube of its Z, which the joint loop caches. This replaces the general Jacobian table and the separate pass computing the cached powers. The proof reuses the blocks' certificates on the verifier's slots, states each phase's field environment explicitly, and proves the values from the co-Z formulas; ZADDU's distinct inputs follow from the curve's prime order, which the verifier's proof now takes from the P-256 law variant. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ma2fA9rUTPXEEQjYyCMCRw
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 #991.
What
AArch64
vg_ecdsa_p256_verifybuilds the odd multiplesQ, 3Q, …, 15Qof the public key by co-Z arithmetic, reusing ECDH's register-allocated DBLU and ZADDU blocks (Impl/P256/EcdhTable.lean):Qgives2QandQat oneZ;2Qas the co-Z addend, each of seven ZADDU steps adds2Q, returning the next odd multiple,2Qrescaled to itsZ, and thatZ's square and cube.Each entry and its
Z²,Z³are stored as the joint loop expects (Impl/P256/VerifyTable.lean). This replaces the general Jacobian table (seven additions with exceptional-case branches) and the separate pass that computed the cachedZ²andZ³of each entry (P256Allocated.ops.table := VerifyTable.build,cache := .block []). The verify function shrinks from 15861 to 11226 lines of assembly.No
TCB/orSpec/changes. The registration file passesh.primeand its notes describe the new table.Proof
Proof/P256/VerifyTable/Field.lean: ECDH's allocated DBLU/ZADDU blocks carry their field contract to any slot predicate holding their slots, through their existing certificates on the observed slots.Copies,Store,StoreInv,Build: each phase of the build on the field invariant, with the environment after it an explicit function of the one before (buildEnv), and the frame (AllocatedFrameover ECDH's work regions, the table and its cache).Env.lean: the algebra. EntryaofbuildEnvis(2a−1)Qin Jacobian coordinates, with its cached powers. ZADDU needs(2k+1)Q ≠ ±2Qfork ≤ 6, which follows fromPrimeOrder(n > 17).allocatedVerify_verifiedtherefore now also takes the curve'sPrimeOrder, which theP256AArch64 law variant already provides (h.primein the registration file).Timing.lean: every address and the loop count depend on the scratch pointer alone (taint_decideon the copy and store blocks, ECDH'sDblu.ct/Zaddu.ct), so runs from one field environment leak the same. The table is built from the public key only.Proof/Ecdsa/Verify/AArch64/AllocatedPoints.lean(the allocated sections moved out ofJointPoints.lean, plus the new setup stage) andAllocatedPointsTiming.leanwire it into the verifier's correctness and timing proofs.Performance
llvm-mca of the changed region (the table and its cache; the preparation and the joint loop are unchanged), straight-line along the common path:
Benchmarks: this PR's Benchmarks check (aarch64,
ecdsa_p256, the scopeci/bench_arches.pygives); results in its run summary.Tests
CAVP and Wycheproof P-256 verification (
cargo test --target aarch64-unknown-linux-gnu -- ecdsa_p256, under qemu) pass.lake buildandEmit.lean --checkpass on Lean 4.35.0, as do theci/check_*.pyscripts.Generated by Claude Code