Skip to content

Conversation

@ivokub
Copy link
Collaborator

@ivokub ivokub commented Jun 18, 2025

Description

Corresponding downstream usage in Consensys/linea-monorepo#915. This PR modifies the interfaces for the EVM precompile gadgets for better compatibility with the glue logic.

Type of change

  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

@ivokub ivokub requested a review from Copilot June 18, 2025 21:00
@ivokub ivokub self-assigned this Jun 18, 2025
@ivokub ivokub added the type: consolidate strengthen an existing feature label Jun 18, 2025
Copy link
Contributor

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 refactors the BLS EVM precompile integration by updating precompile gadget interfaces to accept expected outputs and return errors, and aligns tests and implementations with the new signatures.

  • Changed ECAdd, ECMapTo, and MSM functions to take an expected parameter and perform in-circuit assertions instead of returning points.
  • Updated tests to use the new function signatures, switched to sw_bls12381 types in witnesses, and updated scalar fields to ecc.BLS12_377.
  • Added error propagation (fmt.Errorf) in place of panics and introduced a unified ScalarMul alias in the sw_bls12381 implementation.

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
std/evmprecompiles/bls_test.go Updated test circuits to match new signatures and scalar field.
std/evmprecompiles/11-blsg1add.go Refactored ECAddG1BLS signature to include expected output.
std/evmprecompiles/12-blsg1msm.go Renamed ECMSMG1BLS to ECG1ScalarMulSumBLS with new API and error.
std/evmprecompiles/13-blsg2add.go Refactored ECAddG2BLS signature to include expected output.
std/evmprecompiles/14-blsg2msm.go Renamed ECMSMG2BLS to ECG2ScalarMulSumBLS, updated logic and errors.
std/evmprecompiles/16-blsmaptog1.go Updated ECMapToG1BLS to accept expected output and return error.
std/evmprecompiles/17-blsmaptog2.go Updated ECMapToG2BLS to accept expected output and return error.
std/algebra/emulated/sw_bls12381/g2.go Added a ScalarMul alias for the GLV-based scalar mul method.
Comments suppressed due to low confidence (3)

std/evmprecompiles/14-blsg2msm.go:17

  • The documentation tag references [BLS12_G1MSM], but this function implements the G2 MSM precompile; update the reference to [BLS12_G2MSM].
// [BLS12_G1MSM]: https://eips.ethereum.org/EIPS/eip-2537

std/evmprecompiles/13-blsg2add.go:11

  • [nitpick] This function panics on NewG2 errors but does not return an error; for consistency and better error handling, consider returning an error instead of panicking.
func ECAddG2BLS(api frontend.API, P, Q, expected *sw_bls12381.G2Affine) {

std/evmprecompiles/bls_test.go:54

  • The test uses ecc.BLS12_377.ScalarField(), which may not match the intended BLS12-381 scalar field for these precompiles; consider using the correct BLS12-381 scalar field (e.g., ecc.BLS12381.ScalarField()).
	err := test.IsSolved(circuit, witness, ecc.BLS12_377.ScalarField())

@ivokub ivokub force-pushed the feat/bls-integration branch from afa27f3 to d215974 Compare July 1, 2025 12:44
@ivokub ivokub marked this pull request as ready for review July 1, 2025 12:45
@ivokub ivokub added the dep: linea Issues affecting Linea downstream label Jul 1, 2025
cursor[bot]

This comment was marked as outdated.

@ivokub ivokub requested a review from yelhousni July 1, 2025 12:58
@ivokub
Copy link
Collaborator Author

ivokub commented Jul 1, 2025

@yelhousni - a bit of changes in how we call the methods from Linea side. I'd merge it as I also want to modify the open #1489 PR and don't want to mix things up too much. I'll maybe have some further changes later on as things start to settle.

@ivokub ivokub force-pushed the feat/bls-integration branch from dfa4e64 to a1b012e Compare July 17, 2025 12:42
Copy link
Contributor

@yelhousni yelhousni left a comment

Choose a reason for hiding this comment

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

I don't see any problem with the new interface. Let's merge it if it helps with the glue.

@ivokub ivokub merged commit 8ec0dca into master Jul 19, 2025
7 checks passed
@ivokub ivokub deleted the feat/bls-integration branch July 19, 2025 09:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dep: linea Issues affecting Linea downstream type: consolidate strengthen an existing feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants