Skip to content

Feat/solidity verifier bls12381#1554

Merged
ThomasPiellard merged 50 commits intomasterfrom
feat/solidity-verifier-bls12381
Feb 13, 2026
Merged

Feat/solidity verifier bls12381#1554
ThomasPiellard merged 50 commits intomasterfrom
feat/solidity-verifier-bls12381

Conversation

@ThomasPiellard
Copy link
Copy Markdown
Collaborator

@ThomasPiellard ThomasPiellard commented Jul 25, 2025

Description

This PR adds the bls12-381 solidity verifier.

Fixes #1486

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How has this been tested?

Added in the test suite (see solidityVerification )

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

Note

Medium Risk
Touches cryptography-adjacent Solidity codegen and proof serialization/ABI, where subtle encoding or precompile-call mistakes can break verification. Changes are additive but affect generated contract interfaces and associated snapshots.

Overview
Adds experimental Solidity contract export for Groth16 on BLS12-381 by introducing a new solidityTemplate that targets EIP-2537 precompiles (G1 MSM + pairing), plus Proof.MarshalSolidity() to produce the bytes layout expected by the generated verifier.

Extends PLONK Solidity export to BLS12-381 via a new large verifier template and a new VerifyingKey.ExportSolidity() implementation that renders it (hash-to-field is fixed; custom override is rejected).

Updates the BN254 Groth16 Solidity template/ABI to accept uncompressed proofs as bytes calldata (and parse commitments/PoK from the same blob), aligns Proof.MarshalSolidity() with this encoding, and adjusts test snapshots/fixtures to cover both bn254 and bls12381 for Groth16/PLONK (with and without commitments). CI workflows also drop installing gnark-solidity-checker.

Written by Cursor Bugbot for commit 1c536e4. This will update automatically on new commits. Configure here.

Comment thread backend/plonk/bls12-381/solidity.go Outdated
Comment thread backend/plonk/bls12-381/verify.go Outdated
Comment thread backend/plonk/bls12-381/verify.go Outdated
Comment thread backend/plonk/bls12-381/solidity.go
Comment thread backend/plonk/bls12-381/solidity.go
Comment thread backend/plonk/bls12-381/solidity.go Outdated
Comment thread backend/groth16/bls12-381/solidity.go Outdated
Comment thread backend/groth16/bls12-381/solidity.go
Comment thread backend/groth16/bls12-381/solidity.go
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Comment thread backend/groth16/bls12-381/solidity.go
@ivokub ivokub force-pushed the feat/solidity-verifier-bls12381 branch from af21d26 to 077eed2 Compare February 12, 2026 10:12
@ivokub
Copy link
Copy Markdown
Collaborator

ivokub commented Feb 12, 2026

Updated the PR:

  • fixed Solidity BLS12-381 Plonk verifier to also handle discrepancy when we have points at infinity, in which case gnark encodes with 0x04 prefix (uncompressed infinity), but in Solidity we don't. Otherwise without fixes gamma derivation is incorrect and verification fails. This doesn't apply for BN254 where we have two bits for encoding and we don't use the 0x04 prefix
  • added Groth16 BLS12-381 verifier
  • modified Groth16 BN254 verifier to take as inputs bytes instead of [n]uint256 to simplify proof passing and to align with all other Solidity verifiers where we used bytes.
  • use gnark-solidity-checker as Go tool instead of installing separately. This simplifies testing a bit as we can have the versioned dependency in go.mod. NB! we still have to install solc and abigen. In principle abigen could also be added as a tool, but this pulls in a lot of dependencies I want to avoid.

On the other side, I also updated gnark-solidity-checker to handle BLS12-381 tests. See Consensys/gnark-solidity-checker#5. It is waiting for @gbotrel review. As such, when gnark-solidity-checker update is merged then I'll release v0.2.0 of the Solidity checker tool and update the dependency here. So please don't merge this PR just yet, but otherwise it is good to review.
Updated now. Good to merge on my side when looks good.

@ThomasPiellard ThomasPiellard merged commit 147ac71 into master Feb 13, 2026
13 checks passed
@ThomasPiellard ThomasPiellard deleted the feat/solidity-verifier-bls12381 branch February 13, 2026 08:36
@sug0
Copy link
Copy Markdown

sug0 commented Feb 15, 2026

hey folks! are there any plans for inclusion of these changes in a possible v0.15.0 release?

@ivokub
Copy link
Copy Markdown
Collaborator

ivokub commented Feb 16, 2026

hey folks! are there any plans for inclusion of these changes in a possible v0.15.0 release?

Sure - we usually don't have a concrete timeline for releases and do it in ad-hoc manner. We try to keep master stable though.

I'll discuss internally about doing a new release considering last one was already half a year ago.

@sug0
Copy link
Copy Markdown

sug0 commented Feb 16, 2026

perfect, thanks!

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.

Solidity Export for BLS12-381?

3 participants