Skip to content

Conversation

@chfast
Copy link
Member

@chfast chfast commented Aug 26, 2025

No description provided.

@chfast chfast requested review from Copilot and rodiazet August 26, 2025 17:39
Copy link

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 improves the "on curve" validation check for bn254 elliptic curve points by consolidating the logic and removing a TODO comment. The change modifies the point validation to check both curve membership and the point-at-infinity case in a single return statement.

  • Consolidates the point validation logic into a more concise form
  • Removes the TODO comment about reverse order checking
  • Maintains the same validation behavior while improving code structure

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines 13 to +16
const auto yy = pt.y * pt.y;
const auto xxx = pt.x * pt.x * pt.x;
return yy == xxx + Curve::B;
const auto on_curve = yy == xxx + Curve::B;
return on_curve || pt == 0;
Copy link

Copilot AI Aug 26, 2025

Choose a reason for hiding this comment

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

The refactored code now computes the expensive curve equation (yy == xxx + Curve::B) even for the point at infinity (pt == 0). The original early return for pt == 0 was more efficient as it avoided unnecessary field arithmetic operations.

Copilot uses AI. Check for mistakes.
Copy link
Member Author

Choose a reason for hiding this comment

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

We optimize for the average case. Point at infinity as the input is an edge case so checking it up front was a pessimization.

@chfast chfast merged commit f6612f0 into master Aug 26, 2025
20 of 22 checks passed
@chfast chfast deleted the bn254_validate branch August 26, 2025 17:46
@codecov
Copy link

codecov bot commented Aug 26, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.16%. Comparing base (bdcd6f7) to head (286c699).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1300      +/-   ##
==========================================
- Coverage   87.16%   87.16%   -0.01%     
==========================================
  Files         167      167              
  Lines       24752    24751       -1     
  Branches     4063     4063              
==========================================
- Hits        21574    21573       -1     
  Misses        537      537              
  Partials     2641     2641              
Flag Coverage Δ
eest-develop 17.71% <50.00%> (+0.06%) ⬆️
eest-develop-gmp 15.75% <50.00%> (+0.07%) ⬆️
eest-fusaka 12.21% <0.00%> (+<0.01%) ⬆️
eest-legacy 11.10% <0.00%> (+<0.01%) ⬆️
eest-legacy-silkpre 17.71% <100.00%> (-0.01%) ⬇️
eest-static 18.74% <100.00%> (-0.01%) ⬇️
evmone-unittests 83.76% <50.00%> (-0.01%) ⬇️

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

Components Coverage Δ
core 93.31% <100.00%> (-0.01%) ⬇️
tooling 88.35% <ø> (ø)
tests 84.12% <ø> (ø)
Files with missing lines Coverage Δ
lib/evmone_precompiles/bn254.cpp 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