Skip to content

crypto: Share the Fq12 accumulator across pairing pairs - #1638

Closed
chfast wants to merge 1 commit into
masterfrom
crypto/multi-pair-miller-loop
Closed

crypto: Share the Fq12 accumulator across pairing pairs#1638
chfast wants to merge 1 commit into
masterfrom
crypto/multi-pair-miller-loop

Conversation

@chfast

@chfast chfast commented Aug 10, 2026

Copy link
Copy Markdown
Member

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

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

codecov Bot commented Aug 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.71%. Comparing base (155eb66) to head (9fbd93c).

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           
Flag Coverage Δ
eest-develop 88.63% <100.00%> (+<0.01%) ⬆️
eest-develop-gmp 26.55% <100.00%> (+0.01%) ⬆️
eest-legacy 17.15% <0.00%> (-0.01%) ⬇️
eest-libsecp256k1 28.85% <100.00%> (+0.01%) ⬆️
eest-stable 88.63% <100.00%> (+<0.01%) ⬆️
evmone-unittests 93.42% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
core 96.10% <100.00%> (+<0.01%) ⬆️
tooling 91.92% <ø> (ø)
tests 99.80% <ø> (ø)
Files with missing lines Coverage Δ
lib/evmone_precompiles/pairing/bn254/pairing.cpp 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@chfast

chfast commented Aug 10, 2026

Copy link
Copy Markdown
Member Author

Superseded by #1544, which now carries this implementation. Same change; #1544 is the original PR for the idea.

@chfast chfast closed this Aug 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant