Skip to content

Commit 185f798

Browse files
committed
Merge branch 'refs/heads/staging' into 2003-fixoperator-merkle-tree-ffi-tests
2 parents b933259 + b1a1ba6 commit 185f798

File tree

28 files changed

+251
-224
lines changed

28 files changed

+251
-224
lines changed

Makefile

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -653,24 +653,24 @@ batcher_send_gnark_groth16_bn254_infinite: crates/target/release/aligned ## Send
653653
@mkdir -p scripts/test_files/gnark_groth16_bn254_infinite_script/infinite_proofs
654654
@./crates/cli/send_burst_tasks.sh $(BURST_SIZE) $(START_COUNTER)
655655

656-
batcher_send_circom_groth16_bn128_task: crates/target/release/aligned ## Send a Circom Groth16 BN128 proof to Batcher. Parameters: RPC_URL, NETWORK
657-
@echo "Sending Circom Groth16 BN128 proof to Batcher..."
656+
batcher_send_circom_groth16_bn256_task: crates/target/release/aligned ## Send a Circom Groth16 BN256 proof to Batcher. Parameters: RPC_URL, NETWORK
657+
@echo "Sending Circom Groth16 BN256 proof to Batcher..."
658658
@cd crates/cli/ && cargo run --release -- submit \
659-
--proving_system CircomGroth16Bn128 \
660-
--proof ../../scripts/test_files/circom_groth16_bn128_script/proof.json \
661-
--public_input ../../scripts/test_files/circom_groth16_bn128_script/public.json \
662-
--vk ../../scripts/test_files/circom_groth16_bn128_script/verification_key.json \
659+
--proving_system CircomGroth16Bn256 \
660+
--proof ../../scripts/test_files/circom_groth16_bn256_script/proof.json \
661+
--public_input ../../scripts/test_files/circom_groth16_bn256_script/public.json \
662+
--vk ../../scripts/test_files/circom_groth16_bn256_script/verification_key.json \
663663
--proof_generator_addr 0x66f9664f97F2b50F62D13eA064982f936dE76657 \
664664
--rpc_url $(RPC_URL) \
665665
--network $(NETWORK)
666666

667-
batcher_send_circom_groth16_bn128_burst: crates/target/release/aligned ## Send a burst of Circom Groth16 BN128 proofs to Batcher. Parameters: RPC_URL, NETWORK, BURST_SIZE
668-
@echo "Sending Circom Groth16 BN128 proof to Batcher..."
667+
batcher_send_circom_groth16_bn256_burst: crates/target/release/aligned ## Send a burst of Circom Groth16 BN256 proofs to Batcher. Parameters: RPC_URL, NETWORK, BURST_SIZE
668+
@echo "Sending Circom Groth16 BN256 proof to Batcher..."
669669
@cd crates/cli/ && cargo run --release -- submit \
670-
--proving_system CircomGroth16Bn128 \
671-
--proof ../../scripts/test_files/circom_groth16_bn128_script/proof.json \
672-
--public_input ../../scripts/test_files/circom_groth16_bn128_script/public.json \
673-
--vk ../../scripts/test_files/circom_groth16_bn128_script/verification_key.json \
670+
--proving_system CircomGroth16Bn256 \
671+
--proof ../../scripts/test_files/circom_groth16_bn256_script/proof.json \
672+
--public_input ../../scripts/test_files/circom_groth16_bn256_script/public.json \
673+
--vk ../../scripts/test_files/circom_groth16_bn256_script/verification_key.json \
674674
--proof_generator_addr 0x66f9664f97F2b50F62D13eA064982f936dE76657 \
675675
--repetitions $(BURST_SIZE) \
676676
--rpc_url $(RPC_URL) \
@@ -785,13 +785,13 @@ generate_gnark_groth16_bn254_ineq_proof: ## Run the gnark_plonk_bn254_script
785785
@echo "Running gnark_groth_bn254_ineq script..."
786786
@go run scripts/test_files/gnark_groth16_bn254_infinite_script/cmd/main.go 1
787787

788-
generate_circom_groth16_bn128_proof: ## Run the circom_groth16_bn128_script
789-
@echo "Running circom_groth16_bn128 script..."
790-
@cd scripts/test_files/circom_groth16_bn128_script && ./generate_proof.sh
788+
generate_circom_groth16_bn256_proof: ## Run the circom_groth16_bn256_script
789+
@echo "Running circom_groth16_bn256 script..."
790+
@cd scripts/test_files/circom_groth16_bn256_script && ./generate_proof.sh
791791

792-
generate_circom_groth16_bn128_setup: ## Run the circom_groth16_bn128_script setup
793-
@echo "Running circom_groth16_bn128 script setup..."
794-
@cd scripts/test_files/circom_groth16_bn128_script && ./generate_setup.sh
792+
generate_circom_groth16_bn256_setup: ## Run the circom_groth16_bn256_script setup
793+
@echo "Running circom_groth16_bn256 script setup..."
794+
@cd scripts/test_files/circom_groth16_bn256_script && ./generate_setup.sh
795795

796796
__CONTRACTS_DEPLOYMENT__: ## ____
797797
deploy_aligned_contracts: ## Deploy Aligned Contracts. Parameters: NETWORK=<mainnet|holesky|sepolia>
@@ -1127,14 +1127,14 @@ docker_batcher_send_gnark_groth16_burst:
11271127
--rpc_url $(DOCKER_RPC_URL) \
11281128
--max_fee 0.1ether
11291129

1130-
docker_batcher_send_circom_groth16_bn128_burst:
1131-
@echo "Sending Circom Groth16 BN128 task to Batcher..."
1130+
docker_batcher_send_circom_groth16_bn256_burst:
1131+
@echo "Sending Circom Groth16 BN256 task to Batcher..."
11321132
docker exec $(shell docker ps | grep batcher | awk '{print $$1}') aligned submit \
11331133
--private_key $(DOCKER_PROOFS_PRIVATE_KEY) \
1134-
--proving_system CircomGroth16Bn128 \
1135-
--proof ./scripts/test_files/circom_groth16_bn128_script/proof.json \
1136-
--public_input ./scripts/test_files/circom_groth16_bn128_script/public.json \
1137-
--vk ./scripts/test_files/circom_groth16_bn128_script/verification_key.json \
1134+
--proving_system CircomGroth16Bn256 \
1135+
--proof ./scripts/test_files/circom_groth16_bn256_script/proof.json \
1136+
--public_input ./scripts/test_files/circom_groth16_bn256_script/public.json \
1137+
--vk ./scripts/test_files/circom_groth16_bn256_script/verification_key.json \
11381138
--proof_generator_addr $(PROOF_GENERATOR_ADDRESS) \
11391139
--repetitions $(DOCKER_BURST_SIZE) \
11401140
--rpc_url $(DOCKER_RPC_URL) \
@@ -1147,7 +1147,7 @@ docker_batcher_send_all_proofs_burst:
11471147
@$(MAKE) docker_batcher_send_gnark_plonk_bn254_burst
11481148
@$(MAKE) docker_batcher_send_gnark_plonk_bls12_381_burst
11491149
@$(MAKE) docker_batcher_send_gnark_groth16_burst
1150-
@$(MAKE) docker_batcher_send_circom_groth16_bn128_burst
1150+
@$(MAKE) docker_batcher_send_circom_groth16_bn256_burst
11511151

11521152
docker_batcher_send_infinite_groth16:
11531153
docker exec $(shell docker ps | grep batcher | awk '{print $$1}') \

common/proving_systems.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const (
1616
GnarkGroth16Bn254
1717
SP1
1818
Risc0
19-
CircomGroth16Bn128
19+
CircomGroth16Bn256
2020
)
2121

2222
func (t *ProvingSystemId) String() string {
@@ -35,8 +35,8 @@ func ProvingSystemIdFromString(provingSystem string) (ProvingSystemId, error) {
3535
return SP1, nil
3636
case "Risc0":
3737
return Risc0, nil
38-
case "CircomGroth16Bn128":
39-
return CircomGroth16Bn128, nil
38+
case "CircomGroth16Bn256":
39+
return CircomGroth16Bn256, nil
4040
}
4141

4242
return 0, fmt.Errorf("unknown proving system: %s", provingSystem)
@@ -54,8 +54,8 @@ func ProvingSystemIdToString(provingSystem ProvingSystemId) (string, error) {
5454
return "SP1", nil
5555
case Risc0:
5656
return "Risc0", nil
57-
case CircomGroth16Bn128:
58-
return "CircomGroth16Bn128", nil
57+
case CircomGroth16Bn256:
58+
return "CircomGroth16Bn256", nil
5959
}
6060

6161
return "", fmt.Errorf("unknown proving system: %d", provingSystem)
@@ -110,8 +110,8 @@ func (s *ProvingSystemId) UnmarshalCBOR(data []byte) error {
110110
*s = SP1
111111
case "Risc0":
112112
*s = Risc0
113-
case "CircomGroth16Bn128":
114-
*s = CircomGroth16Bn128
113+
case "CircomGroth16Bn256":
114+
*s = CircomGroth16Bn256
115115
}
116116

117117
return nil

crates/batcher/build.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ fn main() {
99

1010
// Fix the missing dependency issue
1111
let mut get_cmd = Command::new("go");
12-
get_cmd.arg("get")
13-
.arg("github.com/yetanotherco/go-circom-prover-verifier/[email protected]");
12+
get_cmd
13+
.arg("get")
14+
.arg("github.com/iden3/go-rapidsnark/[email protected]");
1415

1516
let _ = get_cmd.output(); // Run but don't fail if it has issues
1617

crates/batcher/go_verifiers_lib/go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ go 1.22.3
55
require (
66
github.com/consensys/gnark v0.12.0
77
github.com/consensys/gnark-crypto v0.17.0
8-
github.com/yetanotherco/go-circom-prover-verifier v0.0.0-20250618185957-f01a8a8ec4a6
8+
github.com/iden3/go-rapidsnark/types v0.0.3
9+
github.com/iden3/go-rapidsnark/verifier v0.0.5
910
)
1011

1112
require (
@@ -14,6 +15,7 @@ require (
1415
github.com/consensys/bavard v0.1.29 // indirect
1516
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
1617
github.com/google/pprof v0.0.0-20240727154555-813a5fbdbec8 // indirect
18+
github.com/iden3/go-iden3-crypto v0.0.17 // indirect
1719
github.com/ingonyama-zk/icicle/v3 v3.1.1-0.20241118092657-fccdb2f0921b // indirect
1820
github.com/mattn/go-colorable v0.1.13 // indirect
1921
github.com/mattn/go-isatty v0.0.20 // indirect
@@ -26,5 +28,3 @@ require (
2628
golang.org/x/sys v0.30.0 // indirect
2729
rsc.io/tmplfunc v0.0.3 // indirect
2830
)
29-
30-
require github.com/ethereum/go-ethereum v1.14.0 // indirect

crates/batcher/go_verifiers_lib/go.sum

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ github.com/consensys/gnark-crypto v0.17.0/go.mod h1:A2URlMHUT81ifJ0UlLzSlm7TmnE3
1111
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
1212
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
1313
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
14-
github.com/ethereum/go-ethereum v1.14.0/go.mod h1:1STrq471D0BQbCX9He0hUj4bHxX2k6mt5nOQJhDNOJ8=
1514
github.com/fxamacker/cbor/v2 v2.7.0 h1:iM5WgngdRBanHcxugY4JySA0nk1wZorNOpTgCMedv5E=
1615
github.com/fxamacker/cbor/v2 v2.7.0/go.mod h1:pxXPTn3joSm21Gbwsv0w9OSA2y1HFR9qXEeXQVeNoDQ=
1716
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
@@ -20,6 +19,12 @@ github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN
2019
github.com/google/pprof v0.0.0-20240727154555-813a5fbdbec8 h1:FKHo8hFI3A+7w0aUQuYXQ+6EN5stWmeY/AZqtM8xk9k=
2120
github.com/google/pprof v0.0.0-20240727154555-813a5fbdbec8/go.mod h1:K1liHPHnj73Fdn/EKuT8nrFqBihUSKXoLYU0BuatOYo=
2221
github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk=
22+
github.com/iden3/go-iden3-crypto v0.0.17 h1:NdkceRLJo/pI4UpcjVah4lN/a3yzxRUGXqxbWcYh9mY=
23+
github.com/iden3/go-iden3-crypto v0.0.17/go.mod h1:dLpM4vEPJ3nDHzhWFXDjzkn1qHoBeOT/3UEhXsEsP3E=
24+
github.com/iden3/go-rapidsnark/types v0.0.3 h1:f0s1Qdut1qHe1O67+m+xUVRBPwSXnq5j0xSrBi0jqM4=
25+
github.com/iden3/go-rapidsnark/types v0.0.3/go.mod h1:ApgcaUxKIgSRA6fAeFxK7p+lgXXfG4oA2HN5DhFlfF4=
26+
github.com/iden3/go-rapidsnark/verifier v0.0.5 h1:J7y0ovrEjDQoWtZmlrp4tgGng1A9faMeYsQH4igAEqA=
27+
github.com/iden3/go-rapidsnark/verifier v0.0.5/go.mod h1:KgL3Yr9NehlFDI4EIWVLE3UDUi8ulyjbp7HcXSBfiGI=
2328
github.com/ingonyama-zk/icicle/v3 v3.1.1-0.20241118092657-fccdb2f0921b h1:AvQTK7l0PTHODD06PVQX1Tn2o29sRIaKIDOvTJmKurY=
2429
github.com/ingonyama-zk/icicle/v3 v3.1.1-0.20241118092657-fccdb2f0921b/go.mod h1:e0JHb27/P6WorCJS3YolbY5XffS4PGBuoW38OthLkDs=
2530
github.com/leanovate/gopter v0.2.11 h1:vRjThO1EKPb/1NsDXuDrzldR28RLkBflWYcU9CvzWu4=
@@ -45,7 +50,6 @@ github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOf
4550
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
4651
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
4752
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg=
48-
github.com/yetanotherco/go-circom-prover-verifier v0.0.0-20250618185957-f01a8a8ec4a6/go.mod h1:A6TUcQ/lvmwAA/Ir8kRMIX5NcIglk8iNKeHF8Nj6Hu0=
4953
golang.org/x/crypto v0.33.0 h1:IOBPskki6Lysi0lo9qQvbxiQ+FvsCC/YWOecCHAixus=
5054
golang.org/x/crypto v0.33.0/go.mod h1:bVdXmD7IV/4GdElGPozy6U7lWdRXA4qyRVGJV57uQ5M=
5155
golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w=

crates/batcher/go_verifiers_lib/verifier.go

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ import "C"
1313

1414
import (
1515
"bytes"
16-
"github.com/yetanotherco/go-circom-prover-verifier/parsers"
17-
"github.com/yetanotherco/go-circom-prover-verifier/verifier"
16+
"encoding/json"
17+
"github.com/iden3/go-rapidsnark/types"
18+
"github.com/iden3/go-rapidsnark/verifier"
19+
1820
"log"
1921
"unsafe"
2022

@@ -120,29 +122,35 @@ func verifyGnarkGroth16Proof(proofBytesRef C.ListRef, pubInputBytesRef C.ListRef
120122
return err == nil
121123
}
122124

123-
//export VerifyCircomGroth16ProofBN128
124-
func VerifyCircomGroth16ProofBN128(proofBytesRef C.ListRef, pubInputBytesRef C.ListRef, verificationKeyBytesRef C.ListRef) bool {
125+
//export VerifyCircomGroth16ProofBN256
126+
func VerifyCircomGroth16ProofBN256(proofBytesRef C.ListRef, pubInputBytesRef C.ListRef, verificationKeyBytesRef C.ListRef) bool {
125127
proofBytes := listRefToBytes(proofBytesRef)
126128
pubInputBytes := listRefToBytes(pubInputBytesRef)
127129
verificationKeyBytes := listRefToBytes(verificationKeyBytesRef)
128130

129-
proof, err := parsers.ParseProof(proofBytes)
131+
proofData := &types.ProofData{}
132+
err := json.Unmarshal(proofBytes, proofData)
130133
if err != nil {
131-
log.Printf("Could not parse proof: %v", err)
134+
log.Printf("Could not marshal proof: %v", err)
132135
return false
133136
}
134137

135-
public, err := parsers.ParsePublicSignals(pubInputBytes)
138+
var pubSignals []string
139+
err = json.Unmarshal(pubInputBytes, &pubSignals)
136140
if err != nil {
137-
log.Printf("Could not parse public signals: %v", err)
141+
log.Printf("Error unmarshaling JSON: %v", err)
138142
return false
139143
}
140144

141-
vk, err := parsers.ParseVk(verificationKeyBytes)
145+
zkProof := types.ZKProof{
146+
Proof: proofData,
147+
PubSignals: pubSignals,
148+
}
149+
150+
err = verifier.VerifyGroth16(zkProof, verificationKeyBytes)
142151
if err != nil {
143-
log.Printf("Could not parse verification key: %v", err)
152+
log.Printf("Could not verify Groth16 proof: %v", err)
144153
return false
145154
}
146-
147-
return verifier.Verify(vk, proof, public)
155+
return true
148156
}

crates/batcher/src/circom/verifier.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::ffi::circom_ffi::VerifyCircomGroth16ProofBN128;
1+
use crate::ffi::circom_ffi::VerifyCircomGroth16ProofBN256;
22
use aligned_sdk::common::types::ProvingSystemId;
33

44
pub fn verify_circom(
@@ -12,8 +12,8 @@ pub fn verify_circom(
1212
let verification_key = verification_key.into();
1313

1414
match proving_system {
15-
ProvingSystemId::CircomGroth16Bn128 => unsafe {
16-
VerifyCircomGroth16ProofBN128(proof, public_input, verification_key)
15+
ProvingSystemId::CircomGroth16Bn256 => unsafe {
16+
VerifyCircomGroth16ProofBN256(proof, public_input, verification_key)
1717
},
1818
_ => false,
1919
}

crates/batcher/src/ffi/circom_ffi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::ffi::list_ref::ListRef;
22

33
extern "C" {
4-
pub fn VerifyCircomGroth16ProofBN128(
4+
pub fn VerifyCircomGroth16ProofBN256(
55
proof: ListRef,
66
public_input: ListRef,
77
verification_key: ListRef,

crates/batcher/src/zk_utils/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ fn verify_internal(verification_data: &VerificationData) -> bool {
6060
debug!("Gnark proof is valid: {}", is_valid);
6161
is_valid
6262
}
63-
ProvingSystemId::CircomGroth16Bn128 => {
63+
ProvingSystemId::CircomGroth16Bn256 => {
6464
let Some(pub_input) = verification_data.pub_input.as_ref() else {
6565
warn!("Circom Groth16 public input missing");
6666
return false;
@@ -102,7 +102,7 @@ mod test {
102102
ProvingSystemId::GnarkGroth16Bn254,
103103
ProvingSystemId::SP1,
104104
ProvingSystemId::Risc0,
105-
ProvingSystemId::CircomGroth16Bn128,
105+
ProvingSystemId::CircomGroth16Bn256,
106106
];
107107
// Just to make sure we are not missing any verifier. The compilation will fail if we do and it forces us to add it to the vec above.
108108
for verifier in verifiers.iter() {
@@ -112,7 +112,7 @@ mod test {
112112
ProvingSystemId::GnarkPlonkBls12_381 => (),
113113
ProvingSystemId::GnarkPlonkBn254 => (),
114114
ProvingSystemId::GnarkGroth16Bn254 => (),
115-
ProvingSystemId::CircomGroth16Bn128 => (),
115+
ProvingSystemId::CircomGroth16Bn256 => (),
116116
}
117117
}
118118
verifiers

crates/cli/send_proof_with_random_address.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@ elif [[ $PROOF_TYPE == "risc0" ]]; then
7474

7575
elif [[ $PROOF_TYPE == "circom_groth16" ]]; then
7676
aligned submit \
77-
--proving_system CircomGroth16Bn128 \
78-
--proof ../../scripts/test_files/circom_groth16_bn128_script/proof.json \
79-
--public_input ../../scripts/test_files/circom_groth16_bn128_script/public.json \
80-
--vk ../../scripts/test_files/circom_groth16_bn128_script/verification_key.json \
77+
--proving_system CircomGroth16Bn256 \
78+
--proof ../../scripts/test_files/circom_groth16_bn256_script/proof.json \
79+
--public_input ../../scripts/test_files/circom_groth16_bn256_script/public.json \
80+
--vk ../../scripts/test_files/circom_groth16_bn256_script/verification_key.json \
8181
--random_address \
8282
--repetitions $REPETITIONS \
8383
--rpc_url $RPC_URL \

0 commit comments

Comments
 (0)