Skip to content

Speed up ARM64 P-256 verification with checked register allocation - #1203

Merged
reaperhulk merged 2 commits into
mainfrom
codex/arm64-p256-verify-registers
Oct 7, 2026
Merged

reaperhulk merged 2 commits into
mainfrom
codex/arm64-p256-verify-registers

Conversation

@reaperhulk

Copy link
Copy Markdown
Member

P-256 verification on ARM64 spends substantial time moving intermediate field values through scratch memory. Keep those values in scalar registers across field operations, specialize canonical correction/subtraction to P-256's sparse prime, and allocate the divstep matrix update the same way. Public scalar inversion finishes after nine batches when g = 0, retaining the tenth-batch fallback.

The generated instruction lists are independently checked by Lean certificates. Correctness, public-input timing, and restoration of the additional callee-saved registers are proved against the existing contract and 8 KB scratch buffer. There are no TCB or specification changes. The proof-only curve interface supplies the existing Montgomery inversion arithmetic theorem for the early finish.

Performance against main 5a8a04e8b, including its new 64-byte constant-table alignment (median latency; lower is better):

CPU / workload Main This PR Reduction AWS-LC OpenSSL 4
M1 Max, fixed 64-byte fixture 41.94 µs 39.41 µs 6.0% 42.79 µs 63.82 µs
M1 Max, rotating 256 signatures 42.69 µs 40.17 µs 5.9% 45.02 µs 63.83 µs
Neoverse N2, fixed 64-byte fixture 51.91 µs 49.26 µs 5.1% 52.24 µs 137.40 µs
Neoverse N2, rotating 256 signatures 52.73 µs 50.01 µs 5.2% 54.53 µs 137.34 µs

Measurements use two interleaved rounds on M1 Max and four on N2, with 1-second warmups, 3-second measurements, and 100 samples. The final generated verifier is byte-for-byte identical to the measured candidate. N2 benchmark run. Measurement harnesses and results are outside the repository.

Validation: full Lean build (10,765 targets), full emitter audit and generated-source check, 174 unit tests and 236 integration tests (including CAVP/Wycheproof), formatting, Clippy with warnings denied, and repository audits all pass.

@reaperhulk
reaperhulk enabled auto-merge October 7, 2026 11:47
@reaperhulk
reaperhulk added this pull request to the merge queue Oct 7, 2026
Merged via the queue into main with commit baf34af Oct 7, 2026
34 checks passed
@reaperhulk
reaperhulk deleted the codex/arm64-p256-verify-registers branch October 7, 2026 12:16
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.

1 participant