precompiles: Add Fq2 sqr() and use it in BN254 pairing helpers#1539
precompiles: Add Fq2 sqr() and use it in BN254 pairing helpers#1539chfast wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR enhances BN254 pairing field arithmetic by introducing an optimized squaring implementation for Fq2 and teaching the generic extension-field multiplication operator to use sqr() when multiplying an element by itself. This fits into the precompiles pairing code by reducing the cost of common “square” operations that appear in pairing-related formulas.
Changes:
- Added
constexpr Fq2 sqr(const Fq2&)using a 2-multiplication squaring formula. - Updated
ecc::ExtFieldElem’soperator*to detecte * eand dispatch tosqr(e)when available via ADL.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
lib/evmone_precompiles/pairing/field_template.hpp |
Optimizes self-multiplication (a * a) by calling sqr(a) when a suitable overload exists. |
lib/evmone_precompiles/pairing/bn254/fields.hpp |
Adds Fq2 squaring helper to enable the generic self-multiply optimization and improve pairing arithmetic performance. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1539 +/- ##
=======================================
Coverage 96.97% 96.97%
=======================================
Files 162 162
Lines 14436 14441 +5
Branches 3383 3384 +1
=======================================
+ Hits 13999 14004 +5
Misses 307 307
Partials 130 130
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
No description provided.