crypto: Share the Fq12 accumulator across pairing pairs - #1638
Closed
chfast wants to merge 1 commit into
Closed
Conversation
pairing_check ran an independent Miller loop per pair, paying 64 Fq12 squarings each, although the recurrence f ← f²·line is multiplicative across pairs so a single accumulator serves all of them. Collect the surviving pairs and run one loop over the NAF digits, squaring once per iteration and folding every pair's line value into the shared f. For N pairs this drops (N−1)×64 squarings plus the N−1 Fq12 multiplications that combined the per-pair results, cutting about 13% off the ECPAIRING instruction count on the benchmark inputs, which carry 2 to 4 pairs.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1638 +/- ##
=======================================
Coverage 97.71% 97.71%
=======================================
Files 171 171
Lines 15607 15611 +4
Branches 3610 3615 +5
=======================================
+ Hits 15251 15255 +4
Misses 269 269
Partials 87 87
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Member
Author
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.
pairing_check ran an independent Miller loop per pair and multiplied the
results, paying 64 Fq12 squarings each. The recurrence f ← f²·line is
multiplicative across pairs, so a single accumulator serves all of them
and the squaring is paid once per iteration rather than once per pair.
For N pairs this drops (N−1)×64 squarings plus the N−1 Fq12
multiplications that combined the per-pair results, and lets an
all-infinity input skip the final exponentiation. About 13% off the
ECPAIRING instruction count on the benchmark inputs, which carry 2 to 4
pairs.
Supersedes the draft #1544, reimplemented rather than rebased because it
predates the JacPoint rename and the Point removal. One caveat: the
per-pair state needs a vector, so a single-pair call pays an allocation
and saves no squarings.
🤖 Generated with Claude Code