Skip to content

crypto: Use hex literals in bn254 FROBENIUS_COEFFS and make it constexpr#1565

Merged
chfast merged 1 commit into
masterfrom
crypto/frobenius-coeffs-hex
Jun 11, 2026
Merged

crypto: Use hex literals in bn254 FROBENIUS_COEFFS and make it constexpr#1565
chfast merged 1 commit into
masterfrom
crypto/frobenius-coeffs-hex

Conversation

@chfast

@chfast chfast commented Jun 11, 2026

Copy link
Copy Markdown
Member

Hex _u256 literals load directly instead of the costly compile-time decimal parse, halving pairing.cpp compile cost (~35G->15.5G instructions, ~4.5s->2.2s). This also fits the array under -fconstexpr-steps, so promote it to inline constexpr (was static inline const + consteval make_fq2).

Hex _u256 literals load directly instead of the costly compile-time decimal
parse, halving pairing.cpp compile cost (~35G->15.5G instructions, ~4.5s->2.2s).
This also fits the array under -fconstexpr-steps, so promote it to
`inline constexpr` (was `static inline const` + consteval make_fq2).
@chfast chfast force-pushed the crypto/frobenius-coeffs-hex branch from eeb4587 to 8faa995 Compare June 11, 2026 15:41
@codecov

codecov Bot commented Jun 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.36%. Comparing base (ef5008e) to head (8faa995).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1565   +/-   ##
=======================================
  Coverage   97.36%   97.36%           
=======================================
  Files         163      163           
  Lines       14497    14497           
  Branches     3387     3387           
=======================================
  Hits        14115    14115           
  Misses        280      280           
  Partials      102      102           
Flag Coverage Δ
eest-develop 89.67% <ø> (ø)
eest-develop-gmp 26.41% <ø> (ø)
eest-legacy 17.71% <ø> (ø)
eest-libsecp256k1 28.06% <ø> (ø)
eest-stable 89.76% <ø> (ø)
evmone-unittests 92.52% <ø> (ø)

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

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

Copilot AI left a comment

Copy link
Copy Markdown

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 code compilation by replacing large decimal _u256 literals with hex _u256 literals (avoiding expensive compile-time decimal parsing) and promoting the Frobenius coefficient table to an inline constexpr variable now that it fits within constexpr evaluation limits.

Changes:

  • Convert FROBENIUS_COEFFS entries from large decimal literals to hex _u256 literals.
  • Change FROBENIUS_COEFFS storage from static inline const to inline constexpr.
  • Keep coefficient construction via consteval make_fq2().

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

Comment on lines +32 to +36
make_fq2(0x30644e72e131a0295e6dd9e7e0acccb0c28f069fbb966e3de4bd44e5607cfd49_u256, 0),
make_fq2(0x30644e72e131a0295e6dd9e7e0acccb0c28f069fbb966e3de4bd44e5607cfd48_u256, 0),
make_fq2(0x30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd46_u256, 0),
make_fq2(0x59e26bcea0d48bacd4f263f1acdb5c4f5763473177fffffe_u256, 0),
make_fq2(0x59e26bcea0d48bacd4f263f1acdb5c4f5763473177ffffff_u256, 0),
@chfast chfast merged commit e5820b6 into master Jun 11, 2026
24 checks passed
@chfast chfast deleted the crypto/frobenius-coeffs-hex branch June 11, 2026 16:30
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.

2 participants