crypto: Move the twisted curve's b coefficient onto E2 - #1641
Merged
Conversation
The twist's b = 3/ξ sat in Fq6Config as _3_ksi_inv: a field config holding a curve constant, named after how it is derived rather than what it is, while E2 had no B at all even though Curve has one. Move it to E2::B so is_on_twisted_curve reads y2 == x3 + E2::B and the twist is described like G1. The compiled binary is byte-identical.
There was a problem hiding this comment.
Pull request overview
Moves the BN254 twisted-curve coefficient from field configuration into the E2 curve definition.
Changes:
- Adds
E2::Bwith the existing coefficient value. - Updates twisted-curve validation to use
E2::B. - Removes the misplaced
_3_ksi_invfield constant.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
lib/evmone_precompiles/bn254.hpp |
Defines the twisted curve’s B coefficient. |
lib/evmone_precompiles/pairing/bn254/fields.hpp |
Removes the coefficient from Fq6Config. |
lib/evmone_precompiles/pairing/bn254/utils.hpp |
Uses E2::B during curve validation. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1641 +/- ##
=======================================
Coverage 97.71% 97.71%
=======================================
Files 171 171
Lines 15607 15607
Branches 3610 3610
=======================================
Hits 15251 15251
Misses 269 269
Partials 87 87
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The twisted curve's
b = 3/ξlived inFq6Configas_3_ksi_inv— a field configholding a curve constant, named after how it is derived rather than what it is —
while
E2carried noBat all, even thoughCurvehasB = Fp{3}. Its single usenow reads
y2 == x3 + E2::Binstead ofy2 == x3 + Fq6Config::_3_ksi_inv, and thetwist is described the same way as G1.
The value is moved verbatim (extracted programmatically, not retyped). I also
confirmed it really is
3/ξ: it equals(27/82, −3/82)mod p, which is3(9−u)/((9+u)(9−u)), andξ · B == (3, 0).The compiled binary is byte-identical —
cmpreports no difference againstmaster, which is the expected outcome for relocating a compile-time constant, and
makes this a zero-risk change on the performance side. 1172/1172 unit tests pass.
🤖 Generated with Claude Code