Skip to content

crypto: Optimize line evaluation in BN254 pairings#1541

Merged
chfast merged 1 commit into
masterfrom
precompiles/bn254-lin-func-factor
May 26, 2026
Merged

crypto: Optimize line evaluation in BN254 pairings#1541
chfast merged 1 commit into
masterfrom
precompiles/bn254-lin-func-factor

Conversation

@chfast
Copy link
Copy Markdown
Member

@chfast chfast commented May 25, 2026

Algebraic simplifications in the Jacobian add + line evaluation,
all recovering an intermediate reuse that was implicit in the original
reference but lost when the procedure was re-derived to fix the paper's
typos.

@chfast chfast requested a review from rodiazet May 25, 2026 12:42
@codecov
Copy link
Copy Markdown

codecov Bot commented May 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.97%. Comparing base (8a68f96) to head (f676b62).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1541   +/-   ##
=======================================
  Coverage   96.97%   96.97%           
=======================================
  Files         163      163           
  Lines       14455    14455           
  Branches     3385     3385           
=======================================
  Hits        14018    14018           
  Misses        307      307           
  Partials      130      130           
Flag Coverage Δ
eest-develop 91.94% <100.00%> (ø)
eest-develop-gmp 26.53% <100.00%> (ø)
eest-legacy 17.55% <0.00%> (ø)
eest-libsecp256k1 28.17% <100.00%> (ø)
eest-stable 91.85% <100.00%> (ø)
evmone-unittests 92.64% <100.00%> (ø)

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

Components Coverage Δ
core 96.02% <100.00%> (ø)
tooling 86.71% <ø> (ø)
tests 99.79% <ø> (ø)
Files with missing lines Coverage Δ
lib/evmone_precompiles/pairing/bn254/utils.hpp 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Member

@rodiazet rodiazet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Quite obvious simplification. Wondering why these papers don’t mention this. :)

@chfast chfast force-pushed the precompiles/bn254-fq2-sqr branch from 3d392a0 to 781dccc Compare May 25, 2026 14:00
Base automatically changed from precompiles/bn254-fq2-sqr to master May 25, 2026 15:23
@chfast chfast force-pushed the precompiles/bn254-lin-func-factor branch from d80e632 to a653f6b Compare May 26, 2026 06:49
Algebraic simplifications in the Jacobian add + line evaluation,
all recovering an intermediate reuse that was implicit in the original
reference but lost when the procedure was re-derived to fix the paper's
typos.
@chfast chfast force-pushed the precompiles/bn254-lin-func-factor branch from a653f6b to f676b62 Compare May 26, 2026 07:11
@chfast chfast changed the title precompiles: Optimize line evaluation in BN254 pairings crypto: Optimize line evaluation in BN254 pairings May 26, 2026
@chfast chfast marked this pull request as ready for review May 26, 2026 07:12
@chfast chfast requested a review from Copilot May 26, 2026 07:12
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR optimizes BN254 pairing line-evaluation computations by algebraically simplifying coefficient calculations and reusing intermediates in the Jacobian-add + line evaluation path, aligning with the referenced derivation notes.

Changes:

  • Simplify t[0]/t[1] computations in lin_func_and_add() by reusing H and R (removing redundant multiplications).
  • Factor common terms in lin_func() to reduce field multiplications.
  • Minor comment correction/clarification in the Jacobian add derivation notes inline.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@chfast
Copy link
Copy Markdown
Member Author

chfast commented May 26, 2026

                                                   │ /proc/self/fd/11 │          /proc/self/fd/16          │
                                                   │      gas/s       │    gas/s     vs base               │
precompile<PrecompileId::ecpairing,_evmmax_cpp>-14        92.18M ± 1%   92.73M ± 0%  +0.59% (p=0.001 n=11)

@chfast chfast merged commit 1dc88fc into master May 26, 2026
24 checks passed
@chfast chfast deleted the precompiles/bn254-lin-func-factor branch May 26, 2026 07:36
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.

3 participants