Repository navigation
AArch64 P-384 ECDH: register-allocated doublings in the window - #2867
Merged
Merged
Conversation
This was referenced Oct 19, 2026
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
… n = 6 (unbuilt) 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
|
rebase this stack and handle the new visibility rules |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ma2fA9rUTPXEEQjYyCMCRw
alex
force-pushed
the
claude/a64-p384-ecdh-dbl
branch
from
October 20, 2026 06:27
62ccb5c to
27af4ec
Compare
Member
Author
|
Done: I rebased the whole stack (#2867 → #2870 → #2872 → #2874) onto main at 6135dd5 and force-pushed it. Each PR now ends with a commit that adapts its own files to the private-import rules: For each PR on its own base, all of these pass locally:
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.
On N2, P-384 ECDH was the only rustls primitive where we trailed aws-lc-rs (0.99×). This is the first PR of a series that register-allocates P-384's ECDH, following P-256's.
Before this PR, every field operation in the window's doublings was an out-of-line call to
vg_p384_mul_mod_porvg_p384_sqr_mod_p, with its operands in memory. Each doubling is now one straight-line block, allocated into registers and checked by a certificate, the way P-256's are.Changes
Implementation
Impl/P384/Ops.lean. P-384's field operations inline on the working space atx0:_altproduct and square cores (P384Mul,P384Sqr, adapted from s2n-bignum) load their operands from slots, not through the functions' pointers.Impl/P384/EcdhDouble.lean. The window's doubling (dblJ) as a straight line of those operations, in both directions (R→D,D→R).Impl/P256/VerifyRegisters.lean) allocates them, run bylean/GenerateP384Ecdh.lean; its output is the literalImpl/P384/EcdhAllocatedCode.lean.x1–x17andx21–x25. ECDH already savesx21–x25on entry and restores them on exit.E, the addition's temporaries, andtmp.WinCfg.windowJ(andquadJ,stepJ,stepLast) take an optional pair of doubling blocks in place offprogBofdouble.vg_ecdh_p384passes the allocated ones.VerifyRegisters.allocatetakes its spill slots as a parameter. The default is P-256's area, so P-256's literals are unchanged.Proofs
Proof/P384/Ops.lean. The inline product and square are correct and change onlyclobX, i.e.clob 6plusx21–x25. They reuseP384Mul.prod_okandP384Sqr.sq_ok, generalized to any base register and offset (prodAt_ok,sqAt_ok); the functions' code and proofs are instances of those.Proof/P384/EcdhDouble/Raw.lean. The raw doubling meets whatwinN_oksays of the call-based one.Proof/P384/EcdhDouble/Certificate.lean. For each direction, the allocated block agrees with the raw one on every slot except the spills (Forward kernel,decide +kernel, about 4 s each). It changes onlyregsand its output and spill slots, and is constant-time.Proof/P384/EcdhDouble/Verified.lean. The allocated blocks meet the window's newDblSpec.WinJStep,WinJLoopandMulJ4take the blocks withDblsOk; the defaultfprogBdoubling meets it too (dblN_spec).combClob 6(the window's and comb's register frame, proof only) now includesx21–x25(winSaved). The ECDH and ECDSA entry code saves and restores them; no emitted code changes.No changes to
TCB/orSpec/.Speed
Neoverse N2, run 39261068075, compared with
main(e5ec778):ecdh_p384ec_p384_public_keyecdsa_p384_sha384_sign64 B / 1 KiB / 16 KiBecdsa_p384_sha384_verify64 B / 1 KiB / 16 KiBChecks
These pass locally:
lake buildsrc/asm/aarch64/ecdh_p384.rschanges)check_lean_imports,check_lean_modules,check_registrations,check_lean_speed,check_vectors,check_arch_gates,check_variants,check_mcdtalgorithms_table.py(table unchanged)Generated by Claude Code