Skip to content

crypto: Express the G2 check's Frobenius powers directly - #1637

Open
chfast wants to merge 1 commit into
masterfrom
crypto/direct-frobenius-powers
Open

crypto: Express the G2 check's Frobenius powers directly#1637
chfast wants to merge 1 commit into
masterfrom
crypto/direct-frobenius-powers

Conversation

@chfast

@chfast chfast commented Aug 10, 2026

Copy link
Copy Markdown
Member

g2_subgroup_check spelled the three consecutive Frobenius powers three
different ways: endomorphism<1>, a chained endomorphism<1>, and
endomorphism<1> composed with endomorphism<2>, although a specialization
exists for each power. Use them directly so the three terms match the
identity being checked, [x+1]P + ψ([x]P) + ψ²([x]P) == ψ³([2x]P).

Collapsing the chains relies on conj(γ₁)·γ₁ == γ₂ and γ₂·γ₁ == γ₃, which
hold for the FROBENIUS_COEFFS values; the Frobenius² coefficients are
real, so the conjugation passes through them unchanged. Drops 2 Fq²
multiplications and 3 conjugations per pair, about 0.1% of the ECPAIRING
instruction count.

🤖 Generated with Claude Code

g2_subgroup_check spelled ψ, ψ² and ψ³ three different ways — endomorphism<1>, a
chained endomorphism<1>, and endomorphism<1> composed with endomorphism<2> — even
though a specialization exists for each power. Use them directly so the three terms
match the [x+1]P + ψ([x]P) + ψ²([x]P) == ψ³([2x]P) identity being checked, which
also drops 2 Fq2 multiplications and 3 conjugations per pair and cuts about 0.1%
off the ECPAIRING instruction count.
@chfast
chfast requested review from rodiazet and a balanced review from Copilot August 10, 2026 21:31

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

Simplifies BN254 G2 subgroup checks by directly applying the required Frobenius powers.

Changes:

  • Replaces chained endomorphisms with direct ψ² and ψ³ calls.
  • Reduces field multiplications and conjugations.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@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 (5e82b05).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1637   +/-   ##
=======================================
  Coverage   97.71%   97.71%           
=======================================
  Files         171      171           
  Lines       15607    15607           
  Branches     3610     3610           
=======================================
  Hits        15251    15251           
  Misses        269      269           
  Partials       87       87           
Flag Coverage Δ
eest-develop 88.62% <100.00%> (ø)
eest-develop-gmp 26.53% <100.00%> (ø)
eest-legacy 17.15% <0.00%> (ø)
eest-libsecp256k1 28.83% <100.00%> (ø)
eest-stable 88.62% <100.00%> (ø)
evmone-unittests 93.42% <100.00%> (ø)

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

Components Coverage Δ
core 96.10% <100.00%> (ø)
tooling 91.92% <ø> (ø)
tests 99.80% <ø> (ø)
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.

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