crypto: Precompute Miller-loop lines for G2 generator in KZG verify#1549
Merged
Conversation
The KZG point-evaluation precompile verifies
e(C + [z]·π - [y]·G1, [1]₂) =? e(π, [s]₂)
The right side already uses blst_miller_loop_lines with precomputed
lines for [s]₂. The left side used blst_aggregated_in_g1, which is
a convenience wrapper that calls miller_loop_n(&BLS12_381_G2, sig, 1)
on the fly — no precomputed lines.
Precompute the 68 vec384fp6 Miller-loop lines for the G2 generator
[1]₂ (the same way [s]₂ was done) and route the left pairing through
blst_miller_loop_lines too. Adds ~19.6 KiB of static data.
Both line tables now live in kzg_precomputed_lines.{hpp,cpp} (renamed
from kzg_setup_g2_1_lines.{hpp,cpp}). Each table has a runtime equality
test (memcmp against blst_precompute_lines output) in
test/unittests/precompiles_kzg_test.cpp.
Bench follow-up (TODO from the previous KZG joint-MSM commit refers
to this: ~18% extra win reported by erigontech/go-eth-kzg PR #131).
Member
Author
|
There was a problem hiding this comment.
Pull request overview
This PR precomputes and uses Miller-loop lines for the BLS12-381 G2 generator in KZG proof verification, replacing the previous runtime generator-side pairing helper with the same precomputed-lines path already used for the trusted setup G2 point.
Changes:
- Adds
g2_gen_lines()alongside the existing KZG setup line accessor. - Updates KZG pairing verification to use
blst_miller_loop_lines()for both sides. - Adds a unit test validating the new G2 generator precomputed table against
blst_precompute_lines().
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
lib/evmone_precompiles/kzg.cpp |
Uses precomputed G2 generator Miller-loop lines during KZG pairing verification. |
lib/evmone_precompiles/kzg_precomputed_lines.hpp |
Declares the new g2_gen_lines() accessor. |
lib/evmone_precompiles/kzg_precomputed_lines.cpp |
Adds the generated G2 generator line table and accessor implementation. |
lib/evmone_precompiles/CMakeLists.txt |
Updates target sources to the renamed precomputed-lines files. |
test/unittests/precompiles_kzg_test.cpp |
Adds coverage that verifies the G2 generator precomputed table. |
💡 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 #1549 +/- ##
=======================================
Coverage 96.97% 96.97%
=======================================
Files 163 163
Lines 14444 14449 +5
Branches 3382 3383 +1
=======================================
+ Hits 14007 14012 +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:
|
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.
It turned out the
blst_aggregated_in_g1doesn't use precomputed lines for G2 generator point. Do it ourselves.