Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add Pectra BLS12-381 elliptic curve precompiles #1447

Open
wants to merge 21 commits into
base: master
Choose a base branch
from

Conversation

yelhousni
Copy link
Contributor

@yelhousni yelhousni commented Mar 14, 2025

Description

This PR adds gnark circuits corresponding to precompiles for BLS12-381 curve operations https://eips.ethereum.org/EIPS/eip-2537.

TODO:

  • BLS12_PAIRING_CHECK: inlcude G2 memerbship in Miller loop (lines computation).
  • BLS12_G2ADD: check the two addends are on G2.
  • BLS12_G2MSM: optimized ScalarMul() with GLS + fakeGLS.
  • BLS12_G1MSM and BLS12_G2MSM: optimize MSM algorithm.

Type of change

  • New feature (non-breaking change which adds functionality)

How has this been tested?

Tests are implemented in std/evmprecompiles/bls_test.go.

How has this been benchmarked?

PLONK (on BLS12-377) number of constraints (scs):

precompile curve membership test? subgroup membership test? constraints (scs)
BLS12_G1ADD Yes No 9 641
BLS12_G2ADD Yes No 23 668
precompile curve membership test? subgroup membership test? constraints (scs)
BLS12_G1MSM (1 pair)
Scalar Multiplication
Yes Yes 590 418
BLS12_G1MSM (2 pairs) Yes Yes 1 132 727
BLS12_G1MSM (3 pairs) Yes Yes 1 569 303
BLS12_G1MSM (5 pairs) Yes Yes 2 442 455
BLS12_G1MSM (10 pairs) Yes Yes 4 625 335
BLS12_G1MSM (20 pairs) Yes Yes 8 991 095
BLS12_G1MSM (100 pairs) Yes Yes 43 917 175
precompile curve membership test? subgroup membership test? constraints (scs)
BLS12_G2MSM (1 pair)
Scalar Multiplication
Yes Yes 1 984 180
BLS12_G2MSM (2 pairs) Yes Yes 3 713 098
BLS12_G2MSM (3 pairs) Yes Yes 5 442 016
BLS12_G2MSM (5 pairs) Yes Yes 8 899 852
BLS12_G2MSM (10 pairs) Yes Yes 17 544 442
BLS12_G2MSM (20 pairs) Yes Yes 34 834 351
precompile curve membership test? subgroup membership test? constraints (scs)
BLS12_PAIRING_CHECK (2 pairs) Yes Yes 2 821 323
BLS12_PAIRING_CHECK (4 pairs) Yes Yes 4 993 571
BLS12_PAIRING_CHECK (9 pairs) Yes Yes 10 424 481
BLS12_PAIRING_CHECK (20 pairs) Yes Yes 22 371 551

Checklist:

  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • I did not modify files generated from templates
  • golangci-lint does not output errors locally
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@yelhousni yelhousni added this to the v0.11.N milestone Mar 14, 2025
@yelhousni yelhousni self-assigned this Mar 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants