Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 25 additions & 25 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -653,24 +653,24 @@ batcher_send_gnark_groth16_bn254_infinite: crates/target/release/aligned ## Send
@mkdir -p scripts/test_files/gnark_groth16_bn254_infinite_script/infinite_proofs
@./crates/cli/send_burst_tasks.sh $(BURST_SIZE) $(START_COUNTER)

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

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
@echo "Sending Circom Groth16 BN128 proof to Batcher..."
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
@echo "Sending Circom Groth16 BN256 proof to Batcher..."
@cd crates/cli/ && cargo run --release -- submit \
--proving_system CircomGroth16Bn128 \
--proof ../../scripts/test_files/circom_groth16_bn128_script/proof.json \
--public_input ../../scripts/test_files/circom_groth16_bn128_script/public.json \
--vk ../../scripts/test_files/circom_groth16_bn128_script/verification_key.json \
--proving_system CircomGroth16Bn256 \
--proof ../../scripts/test_files/circom_groth16_bn256_script/proof.json \
--public_input ../../scripts/test_files/circom_groth16_bn256_script/public.json \
--vk ../../scripts/test_files/circom_groth16_bn256_script/verification_key.json \
--proof_generator_addr 0x66f9664f97F2b50F62D13eA064982f936dE76657 \
--repetitions $(BURST_SIZE) \
--rpc_url $(RPC_URL) \
Expand Down Expand Up @@ -785,13 +785,13 @@ generate_gnark_groth16_bn254_ineq_proof: ## Run the gnark_plonk_bn254_script
@echo "Running gnark_groth_bn254_ineq script..."
@go run scripts/test_files/gnark_groth16_bn254_infinite_script/cmd/main.go 1

generate_circom_groth16_bn128_proof: ## Run the circom_groth16_bn128_script
@echo "Running circom_groth16_bn128 script..."
@cd scripts/test_files/circom_groth16_bn128_script && ./generate_proof.sh
generate_circom_groth16_bn256_proof: ## Run the circom_groth16_bn256_script
@echo "Running circom_groth16_bn256 script..."
@cd scripts/test_files/circom_groth16_bn256_script && ./generate_proof.sh

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

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

docker_batcher_send_circom_groth16_bn128_burst:
@echo "Sending Circom Groth16 BN128 task to Batcher..."
docker_batcher_send_circom_groth16_bn256_burst:
@echo "Sending Circom Groth16 BN256 task to Batcher..."
docker exec $(shell docker ps | grep batcher | awk '{print $$1}') aligned submit \
--private_key $(DOCKER_PROOFS_PRIVATE_KEY) \
--proving_system CircomGroth16Bn128 \
--proof ./scripts/test_files/circom_groth16_bn128_script/proof.json \
--public_input ./scripts/test_files/circom_groth16_bn128_script/public.json \
--vk ./scripts/test_files/circom_groth16_bn128_script/verification_key.json \
--proving_system CircomGroth16Bn256 \
--proof ./scripts/test_files/circom_groth16_bn256_script/proof.json \
--public_input ./scripts/test_files/circom_groth16_bn256_script/public.json \
--vk ./scripts/test_files/circom_groth16_bn256_script/verification_key.json \
--proof_generator_addr $(PROOF_GENERATOR_ADDRESS) \
--repetitions $(DOCKER_BURST_SIZE) \
--rpc_url $(DOCKER_RPC_URL) \
Expand All @@ -1147,7 +1147,7 @@ docker_batcher_send_all_proofs_burst:
@$(MAKE) docker_batcher_send_gnark_plonk_bn254_burst
@$(MAKE) docker_batcher_send_gnark_plonk_bls12_381_burst
@$(MAKE) docker_batcher_send_gnark_groth16_burst
@$(MAKE) docker_batcher_send_circom_groth16_bn128_burst
@$(MAKE) docker_batcher_send_circom_groth16_bn256_burst

docker_batcher_send_infinite_groth16:
docker exec $(shell docker ps | grep batcher | awk '{print $$1}') \
Expand Down
14 changes: 7 additions & 7 deletions common/proving_systems.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const (
GnarkGroth16Bn254
SP1
Risc0
CircomGroth16Bn128
CircomGroth16Bn256
)

func (t *ProvingSystemId) String() string {
Expand All @@ -35,8 +35,8 @@ func ProvingSystemIdFromString(provingSystem string) (ProvingSystemId, error) {
return SP1, nil
case "Risc0":
return Risc0, nil
case "CircomGroth16Bn128":
return CircomGroth16Bn128, nil
case "CircomGroth16Bn256":
return CircomGroth16Bn256, nil
}

return 0, fmt.Errorf("unknown proving system: %s", provingSystem)
Expand All @@ -54,8 +54,8 @@ func ProvingSystemIdToString(provingSystem ProvingSystemId) (string, error) {
return "SP1", nil
case Risc0:
return "Risc0", nil
case CircomGroth16Bn128:
return "CircomGroth16Bn128", nil
case CircomGroth16Bn256:
return "CircomGroth16Bn256", nil
}

return "", fmt.Errorf("unknown proving system: %d", provingSystem)
Expand Down Expand Up @@ -110,8 +110,8 @@ func (s *ProvingSystemId) UnmarshalCBOR(data []byte) error {
*s = SP1
case "Risc0":
*s = Risc0
case "CircomGroth16Bn128":
*s = CircomGroth16Bn128
case "CircomGroth16Bn256":
*s = CircomGroth16Bn256
}

return nil
Expand Down
5 changes: 3 additions & 2 deletions crates/batcher/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ fn main() {

// Fix the missing dependency issue
let mut get_cmd = Command::new("go");
get_cmd.arg("get")
.arg("github.com/yetanotherco/go-circom-prover-verifier/parsers@v0.0.0-20250618185957-f01a8a8ec4a6");
get_cmd
.arg("get")
.arg("github.com/iden3/go-rapidsnark/verifier@v0.0.5");

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

Expand Down
6 changes: 3 additions & 3 deletions crates/batcher/go_verifiers_lib/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ go 1.22.3
require (
github.com/consensys/gnark v0.12.0
github.com/consensys/gnark-crypto v0.17.0
github.com/yetanotherco/go-circom-prover-verifier v0.0.0-20250618185957-f01a8a8ec4a6
github.com/iden3/go-rapidsnark/types v0.0.3
github.com/iden3/go-rapidsnark/verifier v0.0.5
)

require (
Expand All @@ -14,6 +15,7 @@ require (
github.com/consensys/bavard v0.1.29 // indirect
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
github.com/google/pprof v0.0.0-20240727154555-813a5fbdbec8 // indirect
github.com/iden3/go-iden3-crypto v0.0.17 // indirect
github.com/ingonyama-zk/icicle/v3 v3.1.1-0.20241118092657-fccdb2f0921b // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
Expand All @@ -26,5 +28,3 @@ require (
golang.org/x/sys v0.30.0 // indirect
rsc.io/tmplfunc v0.0.3 // indirect
)

require github.com/ethereum/go-ethereum v1.14.0 // indirect
8 changes: 6 additions & 2 deletions crates/batcher/go_verifiers_lib/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ github.com/consensys/gnark-crypto v0.17.0/go.mod h1:A2URlMHUT81ifJ0UlLzSlm7TmnE3
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/ethereum/go-ethereum v1.14.0/go.mod h1:1STrq471D0BQbCX9He0hUj4bHxX2k6mt5nOQJhDNOJ8=
github.com/fxamacker/cbor/v2 v2.7.0 h1:iM5WgngdRBanHcxugY4JySA0nk1wZorNOpTgCMedv5E=
github.com/fxamacker/cbor/v2 v2.7.0/go.mod h1:pxXPTn3joSm21Gbwsv0w9OSA2y1HFR9qXEeXQVeNoDQ=
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
Expand All @@ -20,6 +19,12 @@ github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN
github.com/google/pprof v0.0.0-20240727154555-813a5fbdbec8 h1:FKHo8hFI3A+7w0aUQuYXQ+6EN5stWmeY/AZqtM8xk9k=
github.com/google/pprof v0.0.0-20240727154555-813a5fbdbec8/go.mod h1:K1liHPHnj73Fdn/EKuT8nrFqBihUSKXoLYU0BuatOYo=
github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk=
github.com/iden3/go-iden3-crypto v0.0.17 h1:NdkceRLJo/pI4UpcjVah4lN/a3yzxRUGXqxbWcYh9mY=
github.com/iden3/go-iden3-crypto v0.0.17/go.mod h1:dLpM4vEPJ3nDHzhWFXDjzkn1qHoBeOT/3UEhXsEsP3E=
github.com/iden3/go-rapidsnark/types v0.0.3 h1:f0s1Qdut1qHe1O67+m+xUVRBPwSXnq5j0xSrBi0jqM4=
github.com/iden3/go-rapidsnark/types v0.0.3/go.mod h1:ApgcaUxKIgSRA6fAeFxK7p+lgXXfG4oA2HN5DhFlfF4=
github.com/iden3/go-rapidsnark/verifier v0.0.5 h1:J7y0ovrEjDQoWtZmlrp4tgGng1A9faMeYsQH4igAEqA=
github.com/iden3/go-rapidsnark/verifier v0.0.5/go.mod h1:KgL3Yr9NehlFDI4EIWVLE3UDUi8ulyjbp7HcXSBfiGI=
github.com/ingonyama-zk/icicle/v3 v3.1.1-0.20241118092657-fccdb2f0921b h1:AvQTK7l0PTHODD06PVQX1Tn2o29sRIaKIDOvTJmKurY=
github.com/ingonyama-zk/icicle/v3 v3.1.1-0.20241118092657-fccdb2f0921b/go.mod h1:e0JHb27/P6WorCJS3YolbY5XffS4PGBuoW38OthLkDs=
github.com/leanovate/gopter v0.2.11 h1:vRjThO1EKPb/1NsDXuDrzldR28RLkBflWYcU9CvzWu4=
Expand All @@ -45,7 +50,6 @@ github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOf
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg=
github.com/yetanotherco/go-circom-prover-verifier v0.0.0-20250618185957-f01a8a8ec4a6/go.mod h1:A6TUcQ/lvmwAA/Ir8kRMIX5NcIglk8iNKeHF8Nj6Hu0=
golang.org/x/crypto v0.33.0 h1:IOBPskki6Lysi0lo9qQvbxiQ+FvsCC/YWOecCHAixus=
golang.org/x/crypto v0.33.0/go.mod h1:bVdXmD7IV/4GdElGPozy6U7lWdRXA4qyRVGJV57uQ5M=
golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w=
Expand Down
32 changes: 20 additions & 12 deletions crates/batcher/go_verifiers_lib/verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ import "C"

import (
"bytes"
"github.com/yetanotherco/go-circom-prover-verifier/parsers"
"github.com/yetanotherco/go-circom-prover-verifier/verifier"
"encoding/json"
"github.com/iden3/go-rapidsnark/types"
"github.com/iden3/go-rapidsnark/verifier"

"log"
"unsafe"

Expand Down Expand Up @@ -120,29 +122,35 @@ func verifyGnarkGroth16Proof(proofBytesRef C.ListRef, pubInputBytesRef C.ListRef
return err == nil
}

//export VerifyCircomGroth16ProofBN128
func VerifyCircomGroth16ProofBN128(proofBytesRef C.ListRef, pubInputBytesRef C.ListRef, verificationKeyBytesRef C.ListRef) bool {
//export VerifyCircomGroth16ProofBN256
func VerifyCircomGroth16ProofBN256(proofBytesRef C.ListRef, pubInputBytesRef C.ListRef, verificationKeyBytesRef C.ListRef) bool {
proofBytes := listRefToBytes(proofBytesRef)
pubInputBytes := listRefToBytes(pubInputBytesRef)
verificationKeyBytes := listRefToBytes(verificationKeyBytesRef)

proof, err := parsers.ParseProof(proofBytes)
proofData := &types.ProofData{}
err := json.Unmarshal(proofBytes, proofData)
if err != nil {
log.Printf("Could not parse proof: %v", err)
log.Printf("Could not marshal proof: %v", err)
return false
}

public, err := parsers.ParsePublicSignals(pubInputBytes)
var pubSignals []string
err = json.Unmarshal(pubInputBytes, &pubSignals)
if err != nil {
log.Printf("Could not parse public signals: %v", err)
log.Printf("Error unmarshaling JSON: %v", err)
return false
}

vk, err := parsers.ParseVk(verificationKeyBytes)
zkProof := types.ZKProof{
Proof: proofData,
PubSignals: pubSignals,
}

err = verifier.VerifyGroth16(zkProof, verificationKeyBytes)
if err != nil {
log.Printf("Could not parse verification key: %v", err)
log.Printf("Could not verify Groth16 proof: %v", err)
return false
}

return verifier.Verify(vk, proof, public)
return true
}
6 changes: 3 additions & 3 deletions crates/batcher/src/circom/verifier.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::ffi::circom_ffi::VerifyCircomGroth16ProofBN128;
use crate::ffi::circom_ffi::VerifyCircomGroth16ProofBN256;
use aligned_sdk::common::types::ProvingSystemId;

pub fn verify_circom(
Expand All @@ -12,8 +12,8 @@ pub fn verify_circom(
let verification_key = verification_key.into();

match proving_system {
ProvingSystemId::CircomGroth16Bn128 => unsafe {
VerifyCircomGroth16ProofBN128(proof, public_input, verification_key)
ProvingSystemId::CircomGroth16Bn256 => unsafe {
VerifyCircomGroth16ProofBN256(proof, public_input, verification_key)
},
_ => false,
}
Expand Down
2 changes: 1 addition & 1 deletion crates/batcher/src/ffi/circom_ffi.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::ffi::list_ref::ListRef;

extern "C" {
pub fn VerifyCircomGroth16ProofBN128(
pub fn VerifyCircomGroth16ProofBN256(
proof: ListRef,
public_input: ListRef,
verification_key: ListRef,
Expand Down
6 changes: 3 additions & 3 deletions crates/batcher/src/zk_utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ fn verify_internal(verification_data: &VerificationData) -> bool {
debug!("Gnark proof is valid: {}", is_valid);
is_valid
}
ProvingSystemId::CircomGroth16Bn128 => {
ProvingSystemId::CircomGroth16Bn256 => {
let Some(pub_input) = verification_data.pub_input.as_ref() else {
warn!("Circom Groth16 public input missing");
return false;
Expand Down Expand Up @@ -102,7 +102,7 @@ mod test {
ProvingSystemId::GnarkGroth16Bn254,
ProvingSystemId::SP1,
ProvingSystemId::Risc0,
ProvingSystemId::CircomGroth16Bn128,
ProvingSystemId::CircomGroth16Bn256,
];
// 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.
for verifier in verifiers.iter() {
Expand All @@ -112,7 +112,7 @@ mod test {
ProvingSystemId::GnarkPlonkBls12_381 => (),
ProvingSystemId::GnarkPlonkBn254 => (),
ProvingSystemId::GnarkGroth16Bn254 => (),
ProvingSystemId::CircomGroth16Bn128 => (),
ProvingSystemId::CircomGroth16Bn256 => (),
}
}
verifiers
Expand Down
8 changes: 4 additions & 4 deletions crates/cli/send_proof_with_random_address.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ elif [[ $PROOF_TYPE == "risc0" ]]; then

elif [[ $PROOF_TYPE == "circom_groth16" ]]; then
aligned submit \
--proving_system CircomGroth16Bn128 \
--proof ../../scripts/test_files/circom_groth16_bn128_script/proof.json \
--public_input ../../scripts/test_files/circom_groth16_bn128_script/public.json \
--vk ../../scripts/test_files/circom_groth16_bn128_script/verification_key.json \
--proving_system CircomGroth16Bn256 \
--proof ../../scripts/test_files/circom_groth16_bn256_script/proof.json \
--public_input ../../scripts/test_files/circom_groth16_bn256_script/public.json \
--vk ../../scripts/test_files/circom_groth16_bn256_script/verification_key.json \
--random_address \
--repetitions $REPETITIONS \
--rpc_url $RPC_URL \
Expand Down
8 changes: 4 additions & 4 deletions crates/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,8 +356,8 @@ pub enum ProvingSystemArg {
SP1,
#[clap(name = "Risc0")]
Risc0,
#[clap(name = "CircomGroth16Bn128")]
CircomGroth16Bn128,
#[clap(name = "CircomGroth16Bn256")]
CircomGroth16Bn256,
}

const ANVIL_PRIVATE_KEY: &str = "2a871d0798f97d79848a013d4936a73bf4cc922c825d33c1cf7073dff6d409c6"; // Anvil address 9
Expand All @@ -370,7 +370,7 @@ impl From<ProvingSystemArg> for ProvingSystemId {
ProvingSystemArg::GnarkGroth16Bn254 => ProvingSystemId::GnarkGroth16Bn254,
ProvingSystemArg::SP1 => ProvingSystemId::SP1,
ProvingSystemArg::Risc0 => ProvingSystemId::Risc0,
ProvingSystemArg::CircomGroth16Bn128 => ProvingSystemId::CircomGroth16Bn128,
ProvingSystemArg::CircomGroth16Bn256 => ProvingSystemId::CircomGroth16Bn256,
}
}
}
Expand Down Expand Up @@ -914,7 +914,7 @@ fn verification_data_from_args(args: &SubmitArgs) -> Result<VerificationData, Su
args.pub_input_file_name.clone(),
)?);
}
ProvingSystemId::CircomGroth16Bn128 => {
ProvingSystemId::CircomGroth16Bn256 => {
verification_key = Some(read_file_option(
"--vk",
args.verification_key_file_name.clone(),
Expand Down
4 changes: 2 additions & 2 deletions crates/sdk/src/common/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub enum ProvingSystemId {
#[default]
SP1,
Risc0,
CircomGroth16Bn128,
CircomGroth16Bn256,
}

impl Display for ProvingSystemId {
Expand All @@ -57,7 +57,7 @@ impl Display for ProvingSystemId {
ProvingSystemId::GnarkGroth16Bn254 => write!(f, "GnarkGroth16Bn254"),
ProvingSystemId::SP1 => write!(f, "SP1"),
ProvingSystemId::Risc0 => write!(f, "Risc0"),
ProvingSystemId::CircomGroth16Bn128 => write!(f, "CircomGroth16Bn128"),
ProvingSystemId::CircomGroth16Bn256 => write!(f, "CircomGroth16Bn256"),
}
}
}
Expand Down
Loading
Loading