Repository navigation
x86-64 P-521 ECDH: windows in Jacobian coordinates - #1255
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019KRjToTNRB2yxFCdNMux4P
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019KRjToTNRB2yxFCdNMux4P
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019KRjToTNRB2yxFCdNMux4P
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019KRjToTNRB2yxFCdNMux4P
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019KRjToTNRB2yxFCdNMux4P
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019KRjToTNRB2yxFCdNMux4P
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019KRjToTNRB2yxFCdNMux4P
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019KRjToTNRB2yxFCdNMux4P
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019KRjToTNRB2yxFCdNMux4P
This was referenced Oct 7, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to a conflict with the base branch
Oct 8, 2026
reaperhulk
added this pull request to stack #1265
October 8, 2026 02:35
Member
|
conflicts |
#1256 made the x86-64 ECDH proof generic over the scalar multiplication (exchangeWith, MulOk) and added PrimeOrder. P-521 now uses its own mulQJ4 (the 4-bit windows with a Jacobian accumulator) through exchangeWith, instead of a Cfg.jacWin switch in mulQ, and takes its prime order from #1256's PrimeOrder and primeOrder_of in place of OrdN and its own group-order proof. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019KRjToTNRB2yxFCdNMux4P
Member
Author
|
CI failing |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019KRjToTNRB2yxFCdNMux4P
Member
Author
|
The merge of 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.
Summary
P-521 ECDH on x86-64 now keeps the window method's accumulator in Jacobian coordinates from one window to the next and adds the entries in Jacobian coordinates (
WinCfg.windowJ). Each window saves the conversions into Jacobian coordinates and back (6 products) and the complete addition's 29 field additions; the Jacobian addition costs the same 16 products as the complete addition with its conversions.toJof each complete addition's result,buildJ).EwhereRis the point at infinity and byRwhere the entry is (masks of theirZ,selSum); otherwise the operands are never equal or opposite.stepLast), soRends as before.It is P-521's own scalar multiplication for
Cfg.exchangeWith(#1256),Cfg.mulQJ4: the 4-bit windows ofmulQwith the Jacobian accumulator. The 5-bit Jacobian window method of #1256 does not fit nine words in the working space (its table alone is640 nbytes).Why the incomplete addition is safe
Proof/P521/PrimeOrder.leanevaluates[n]G = Oin the kernel by the ladder, in seconds, and givesPrimeOrderby x86-64 P-256 ECDH by 5-bit windows in Jacobian coordinates (−18%) #1256'sprimeOrder_of. It reaches the proofs through the x86-64 variantHasLawInvOrd(x86-64 P-256 ECDH by 5-bit windows in Jacobian coordinates (−18%) #1256's interface); only the variant file imports the Mathlib group theory.P ≠ Oagree only for integers congruent modulon(PrimeOrder.zmul_eq, from x86-64 P-256 ECDH by 5-bit windows in Jacobian coordinates (−18%) #1256'sWindow5.zmul_dvd). Iterationjadds[d_j]Pto[16 e]P, with16 e + 8 < nfor everyj ≥ 1(win_sep,winE_two_bound). So the operands are equal or opposite only if[16 e]P = O.Supporting changes
mulQJ4_ok(Proof/Ecdh/X86_64/MulJ4.lean) is itsMulOk, writing whatmulQwrites (mulQW), soexchangeWith_okgives P-521's exchange. The other curves are unchanged.TblOkR,EntryPostR,WinStR,winEntryR_ok) are generalized over the point representation. The existing statements are unchanged corollaries.No change to
TCB/orSpec/.Speed
ecdh_p521on this machine (Cascade Lake, BMI2+ADX):The two columns are separate
cargo benchruns on a shared machine, so aws-lc-rs also moved by 5%. Against aws-lc-rs the ratio went from 1.39 to 1.32.Checks
main(x86-64 P-256 ECDH by 5-bit windows in Jacobian coordinates (−18%) #1256), the P-521 ECDH proofs build; the fulllake buildandEmit.lean --checkare still running locally.cargo clippy --all-targets -- -D warningsandcargo fmt --checkpass. The P-521 tests pass, Wycheproof and CAVP, also withVG_CPU_FEATURES=none.🤖 Generated with Claude Code
https://claude.ai/code/session_019KRjToTNRB2yxFCdNMux4P