Repository navigation
AArch64 P-384 verify: build the public NAF's table by co-Z arithmetic - #2729
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ma2fA9rUTPXEEQjYyCMCRw
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ma2fA9rUTPXEEQjYyCMCRw
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ma2fA9rUTPXEEQjYyCMCRw
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ma2fA9rUTPXEEQjYyCMCRw
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ma2fA9rUTPXEEQjYyCMCRw
Member
Author
|
why draft? |
alex
marked this pull request as ready for review
October 18, 2026 03:39
Member
Author
|
It was a draft only until the benchmark run it links had finished. That run is in now: verify is 0.9–1.1% faster on aarch64, and the unchanged rows are flat. I've added the results to the description and marked the PR ready. 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.
Part of #991.
What
AArch64
vg_ecdsa_p384_verifybuilds the public NAF's table of the key's odd multiplesQ, 3Q, …, 15Qby co-Z arithmetic (Impl/Weierstrass/CoZ.lean,Impl/Weierstrass/AArch64/PubNaf.lean):Q(itszis one) gives2QandQat oneZ. Its slots are renamed (dbluσ) so that2Qlands inEandQinR, exactly where ZADDU reads them, so no copies follow.coZσ) each add2Q. Each returns the next odd multiple and2Qrescaled to that multiple'sZ, and the multiple is stored into the next entry.This replaces a general doubling and seven complete Jacobian additions, with their exceptional-case branches. The table's field products drop from 120 to 55; each is a call of
vg_p384_mul_mod_porvg_p384_sqr_mod_p. The only generated file that changes issrc/asm/aarch64/ecdsa_p384.rs(+687/−1743 lines). The selection, the doublings and the additions of the main loop are unchanged.No
TCB/orSpec/changes. The registration file (Generic/P384/AArch64/EcdsaP384.lean) now passesh.prime, as P-256's verify already does, and its notes describe the new table.Proof
Proof/Weierstrass/CoZTable.lean(algebra, target-independent):dblu_pts: DBLU of an affinePgives2PandPat one nonzeroZ.zaddu_pts: ZADDU of2Pand(2k+1)Pgives(2k+3)P, and2Pat its newZ. It needs(2k+1)P ≠ ±2Pfork ≤ 6(coz_x), which follows fromPrimeOrderwithn ≥ 17.PubNaf/CoZField.lean: a renaming (Ren) of a co-Z program's slots onto the window method's carries the generic field-program contract (fprogB_ok) over to the numbered program's values (coZ_ok).PubNaf/TableCoZ.lean:table_okcovers the initial copy and store (coZInit_ok), DBLU (dbluStep_ok) and the counted ZADDU loop (coZStep_ok). It replaces the general table's steps inPubNaf/Table.lean.PubNaf/TableTiming.lean:table_relCT.coZ_relCT).x20, and the loop count only onx19.window_ok/window_relCTand the verifier's proofs (PubNafMul,PubNafPoints,PubNafMain,PubNafTiming,P384/Verified) now take three more facts: the curve'sPrimeOrder,17 ≤ n, and that the preparedQ'szis one.P384/Checksdischarges the new taint checks.Performance
Benchmarks run 39092210388, against
02fa10ae2. Its scope is aarch64,cpu_features='- none',modules=ecdsa_p384, the oneci/bench_arches.pygives.VG_CPU_FEATURES=noneecdsa_p384_sha384_verify/64ecdsa_p384_sha384_verify/1024ecdsa_p384_sha384_verify/16384Sign and
ec_p384_public_key, whose code is unchanged, moved by at most 0.1%.llvm-mca of the table's construction, along its common path with the multiply and square callees inlined:
Tests
lake build,Emit.lean --checkand theci/check_*.pyscripts pass. Wycheproof and RFC 6979 P-384 verification (cargo test --release --target aarch64-unknown-linux-gnu -- p384, under qemu) pass.🤖 Generated with Claude Code
https://claude.ai/code/session_01Ma2fA9rUTPXEEQjYyCMCRw