Skip to content

Conversation

@JuArce
Copy link
Collaborator

@JuArce JuArce commented Jun 17, 2025

Integrate Circom Verifier

Description

Description of the pull request changes and motivation.

Tasks

  • Integrate circom in batcher
  • Integrate circom in operator
  • Update docs
  • Add proof generator to test files
  • Add targets to send circom proofs
  • Update CI

How to Test

  1. Start Ethereum Package
make ethereum_package_start
  1. Start batcher
cargo clean --manifest-path ./crates/batcher/Cargo.toml
make batcher_start_ethereum_package
  1. Start aggregator
make aggregator_start_ethereum_package ENVIRONMENT=devnet
  1. Start operator

Note: You need to rebuild ffis

make build_all_ffi
make operator_full_registration CONFIG_FILE=config-files/config-operator-1-ethereum-package.yaml ENVIRONMENT=devnet
make operator_start CONFIG_FILE=config-files/config-operator-1-ethereum-package.yaml ENVIRONMENT=devnet
  1. Start explorer
make explorer_clean_db
make explorer_start
  1. Send proofs
make aligned_install_compiling
make batcher_send_circom_groth16_bn128_task
make batcher_send_circom_groth16_bn128_burst
  1. Check the proofs are verified in the explorer (http://localhost:4000/)

Note: Examples in docs won't work in Holesky until the deploy is done.

Type of change

  • New feature

Checklist

  • “Hotfix” to testnet, everything else to staging
  • Linked to Github Issue
  • This change depends on code or research by an external entity
    • Acknowledgements were updated to give credit
  • Unit tests added
  • This change requires new documentation.
    • Documentation has been added/updated.
  • This change is an Optimization
    • Benchmarks added/run
  • Has a known issue
  • If your PR changes the Operator compatibility (Ex: Upgrade prover versions)
    • This PR adds compatibility for operator for both versions and do not change batcher/docs/examples
    • This PR updates batcher and docs/examples to the newer version. This requires the operator are already updated to be compatible

@JuArce JuArce self-assigned this Jun 17, 2025
@JuArce JuArce linked an issue Jun 17, 2025 that may be closed by this pull request
@JuArce JuArce changed the base branch from testnet to staging June 17, 2025 23:29
@github-actions
Copy link

Changes to gas cost

Generated at commit: edd7f3fd29d60810d8018fe670b52be0aed5da6e, compared to commit: b77e8fdf474834f0b9d018c28322b5c29512002e

🧾 Summary (10% most significant diffs)

Contract Method Avg (+/-) %
RegistryCoordinatorHarness blsApkRegistry
stakeRegistry
+354 ❌
+354 ❌
+57.47%
+51.91%
StakeRegistryHarness delegation +146 ❌ +22.19%

Full diff report 👇
Contract Deployment Cost (+/-) Method Min (+/-) % Avg (+/-) % Median (+/-) % Max (+/-) % # Calls (+/-)
Slasher 728,578 (-870,247) initialize 366 (-556) -60.30% 366 (-556) -60.30% 366 (-556) -60.30% 366 (-556) -60.30% 6 (0)
RegistryCoordinatorHarness 5,528,683 (-4,601,377) blsApkRegistry
initialize
stakeRegistry
970 (+354)
55,078,420 (-1,203,055)
1,036 (+354)
+57.47%
-2.14%
+51.91%
970 (+354)
55,078,420 (-1,203,055)
1,036 (+354)
+57.47%
-2.14%
+51.91%
970 (+354)
55,078,420 (-1,203,055)
1,036 (+354)
+57.47%
-2.14%
+51.91%
970 (+354)
55,078,420 (-1,203,055)
1,036 (+354)
+57.47%
-2.14%
+51.91%
6 (0)
6 (0)
6 (0)
StakeRegistryHarness 2,590,172 (-2,549,338) delegation
initializeQuorum
804 (+146)
144,420 (-1,780)
+22.19%
-1.22%
804 (+146)
164,216 (-1,780)
+22.19%
-1.07%
804 (+146)
164,320 (-1,780)
+22.19%
-1.07%
804 (+146)
164,320 (-1,780)
+22.19%
-1.07%
6 (0)
1,152 (0)
AlignedLayerServiceManager 4,398,072 (-3,921,136) batchesState
createNewTask
disableVerifier
disabledVerifiers
enableVerifier
isVerifierDisabled
receive
setDisabledVerifiers
5,132 (-278)
57,018 (-776)
24,602 (+303)
3,030 (+516)
23,748 (-443)
2,406 (-450)
23,301 (-195)
24,243 (-7)
-5.14%
-1.34%
+1.25%
+20.53%
-1.83%
-15.76%
-0.83%
-0.03%
5,132 (-278)
77,038 (-750)
36,191 (+375)
3,030 (+516)
24,388 (-372)
2,406 (-450)
47,021 (-170)
35,262 (+86)
-5.14%
-0.96%
+1.05%
+20.53%
-1.50%
-15.76%
-0.36%
+0.24%
5,132 (-278)
77,050 (-896)
36,191 (+375)
3,030 (+516)
24,388 (-372)
2,406 (-450)
47,115 (-357)
35,262 (+86)
-5.14%
-1.15%
+1.05%
+20.53%
-1.50%
-15.76%
-0.75%
+0.24%
5,132 (-278)
77,860 (-908)
47,780 (+446)
3,030 (+516)
25,029 (-300)
2,406 (-450)
47,115 (-357)
46,282 (+179)
-5.14%
-1.15%
+0.94%
+20.53%
-1.18%
-15.76%
-0.75%
+0.39%
256 (0)
256 (0)
2 (0)
1 (0)
2 (0)
3 (0)
256 (0)
2 (0)
AVSDirectory 1,485,692 (-1,689,090) initialize 97,570 (-3,067) -3.05% 97,570 (-3,067) -3.05% 97,570 (-3,067) -3.05% 97,570 (-3,067) -3.05% 6 (0)
ServiceManagerMock 1,340,500 (-1,292,283) initialize 71,296 (-2,066) -2.82% 71,296 (-2,066) -2.82% 71,296 (-2,066) -2.82% 71,296 (-2,066) -2.82% 6 (0)
ProxyAdmin 412,495 (-345,151) upgrade
upgradeAndCall
38,758 (-883)
55,403,611 (-1,228,407)
-2.23%
-2.17%
38,767 (-883)
55,403,611 (-1,228,407)
-2.23%
-2.17%
38,770 (-883)
55,403,611 (-1,228,407)
-2.23%
-2.17%
38,770 (-883)
55,403,611 (-1,228,407)
-2.23%
-2.17%
24 (0)
6 (0)
BLSApkRegistryHarness 1,676,721 (-1,447,516) initializeQuorum
setBLSPublicKey
45,382 (-596)
89,551 (-556)
-1.30%
-0.62%
45,382 (-596)
89,551 (-556)
-1.30%
-0.62%
45,382 (-596)
89,551 (-556)
-1.30%
-0.62%
45,382 (-596)
89,551 (-556)
-1.30%
-0.62%
1,152 (0)
6 (0)
TransparentUpgradeableProxy 521,513 (-376,486) fallback 1,634 (+90) +5.83% 47,449 (-617) -1.28% 8,200 (+90) +1.11% 119,180 (-820) -0.68% 30 (0)
StrategyManagerMock 1,146,058 (-1,255,314) setAddresses 88,974 (-768) -0.86% 88,974 (-768) -0.86% 88,974 (-768) -0.86% 88,974 (-768) -0.86% 6 (0)
IndexRegistry 917,377 (-790,180) initializeQuorum 45,244 (-348) -0.76% 45,244 (-348) -0.76% 45,244 (-348) -0.76% 45,244 (-348) -0.76% 1,152 (0)

@MauroToscano MauroToscano force-pushed the 1986-feat-integrate-circom-verifier branch from c451ae5 to 60b70fd Compare June 18, 2025 20:22
@JuArce JuArce marked this pull request as ready for review June 19, 2025 21:44
@JuArce JuArce requested a review from Copilot June 23, 2025 19:24
Copy link

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 adds full support for Circom Groth16 BN128 proofs by introducing proof generation scripts, integrating a Go-based Circom verifier, updating the CLI and batcher/operator code, and extending documentation and Makefiles.

  • Introduce Circom proof generation and test scripts (JSON fixtures, shell, JS, and C++ files).
  • Integrate go-circom-prover-verifier parser/verifier via FFI in batcher and operator.
  • Extend CLI, Dockerfiles, and documentation to recognize CircomGroth16Bn128.

Reviewed Changes

Copilot reviewed 37 out of 62 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
scripts/test_files/circom_groth16_bn128_script/generate_proof.sh Add proof generation steps via snarkjs
scripts/test_files/circom_groth16_bn128_script/circuit_cpp/main.cpp Generated C++ witness calculator for the circuit
operator/pkg/operator.go Add verifyCircomGroth16Bn128Proof for server-side checks
crates/cli/src/main.rs Register new CLI argument CircomGroth16Bn128
crates/batcher/src/circom/verifier.rs FFI wrapper to call Circom verifier from Rust
docs/3_guides/9_aligned_cli.md Document new CircomGroth16Bn128 option in CLI guide
Comments suppressed due to low confidence (3)

scripts/test_files/circom_groth16_bn128_script/circuit_cpp/main.cpp:67

  • Allocating a zero-length array can be confusing and non-portable; consider using nullptr or an empty std::vector<uint> instead.
      u32 dataiomap[(sb.st_size-inisize)/sizeof(u32)];

operator/pkg/operator.go:620

  • Consider adding unit tests for verifyCircomGroth16Bn128Proof to validate parsing errors and successful verification paths.
func (o *Operator) verifyCircomGroth16Bn128Proof(proofBytes []byte, pubInputBytes []byte, verificationKeyBytes []byte) bool {

scripts/test_files/circom_groth16_bn128_script/circuit_cpp/main.cpp:60

  • Avoid using variable-length arrays in C++; prefer std::vector<u32> or dynamic allocation for portability and standard compliance.
      u32 index[get_size_of_io_map()];


# Params:
# PROOF_TYPE = sp1|groth16|plonk|risc0 (default sp1)
# PROOF_TYPE = sp1|groth16|plonk|risc0|circom (default sp1)
Copy link
Contributor

Choose a reason for hiding this comment

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

Proof types should change, since Circom is also groth16, we should rename circom_groth16 and gnark_groth16 and gnark_plonk, we can do the gnark ones in another PR but at least we should rename the circom one

Suggested change
# PROOF_TYPE = sp1|groth16|plonk|risc0|circom (default sp1)
# PROOF_TYPE = sp1|groth16|plonk|risc0|circom (default sp1)

Copy link
Contributor

@MauroToscano MauroToscano left a comment

Choose a reason for hiding this comment

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

  • The CRS for the example shouldn't be needed to be uploaded, randomness can be fixed if it's an example and regenerated quickly
  • FFI's should contain Rust FFIs, not code
  • ListRef is defined twice, it should be under the code of the Rust FFIs
  • Following this, the go code shouldn't be called an FFI, it can be go_verifiers_lib or something like that, it's not very important
  • Paramater on the CLI should clarifiy that is circom_groth16_bn254, at least in the description, or at least circom_grotyh16. We should rename in the future the plonk and groth16 ones to clarify they are from gnark

JuArce added 2 commits June 24, 2025 14:47
…ifier

# Conflicts:
#	crates/cli/send_proof_with_random_address.sh
#	docs/2_architecture/0_supported_verifiers.md
#	docs/3_guides/0_submitting_proofs.md
@MauroToscano MauroToscano added this pull request to the merge queue Jun 25, 2025
Merged via the queue into staging with commit 794087c Jun 25, 2025
5 checks passed
@MauroToscano MauroToscano deleted the 1986-feat-integrate-circom-verifier branch June 25, 2025 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: integrate circom verifier

4 participants