linea-monorepo
linea-monorepo copied to clipboard
feat: BLS12-381 precompiles glue
Adds glue for integrating BLS precompiles from gnark with the data provided in the arithmetization.
- I also ported changes from the smallfield branch to gkr-mimc cc @Tabaie.
- fixed gnark interface update for logderivative lookup tables which are now interfaces (to hide generic parameter for supporting small fields)
- updated gnark dependency to include BLS circuits
- added testdata generator for BLS precompiles which should handle all possible succeeding and failing input cases. To generate the tests, run
go generate prover/zkevm/prover/bls/testdataand then run the tests inprover/zkevm/prover/bls
Checklist
- [x] I wrote new tests for my new core changes.
- [x] I have successfully ran tests, style checker and build against my new changes locally.
- [x] I have informed the team of any breaking changes if there are any.
[!NOTE] Wires BLS12-381 precompile modules (G1/G2 add, MSM, map, pairing, point evaluation) into zkEVM and adds comprehensive testdata generators and fixtures.
- zkEVM Integration:
- Add and initialize BLS modules:
BlsG1Add,BlsG2Add,BlsG1Msm,BlsG2Msm,BlsG1Map,BlsG2Map,BlsPairingCheck,PointEvalinzkevm.go.- Expose constructors in
prover/zkevm/prover/bls/zkevm_modules.goand include newBlslimits inSettings.- Test Data & Generators:
- Introduce
prover/zkevm/prover/bls/testdatawith Go generators for add/MSM/map/pairing/point-eval and embedgo:generateentrypoint.- Add large CSV fixtures for pairing and point-eval inputs/outputs.
- Misc:
- Hook assignments for new BLS modules in prover flow; update public APIs/structs accordingly.
Written by Cursor Bugbot for commit b6fb400a4b7b109c9d9e230bfb794078fda0295e. This will update automatically on new commits. Configure here.
Codecov Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 65.21%. Comparing base (c7bc631) to head (5fdb039).
Additional details and impacted files
@@ Coverage Diff @@
## main #915 +/- ##
=========================================
Coverage 65.21% 65.21%
Complexity 1476 1476
=========================================
Files 369 369
Lines 14354 14354
Branches 1378 1378
=========================================
Hits 9361 9361
Misses 4393 4393
Partials 600 600
| Flag | Coverage Δ | *Carryforward flag | |
|---|---|---|---|
| hardhat | 97.33% <ø> (ø) |
||
| kotlin | 63.16% <ø> (ø) |
Carriedforward from c7bc631 |
*This pull request uses carry forward flags. Click here to find out more.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
BLS glue itself is ready, but there are a few blockers:
- to update to the latest zkevm_prague we need need go-corset dependency.
- there is potentially memory regression with GKR, see https://github.com/Consensys/gnark/pull/1616. I have to check how it works and possibly backport it on top of gnark master
I also have some temp branch locally where I have tested implementation against actual traces, but it updates go-corset and I don't want to force it right now in this PR as different versions seem to be incompatible with each other.