Skip to content

Commit 0761b8b

Browse files
committed
feat: add scripts to generate and send circom proofs
1 parent b9cbefe commit 0761b8b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+24832
-12
lines changed

Makefile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,29 @@ batcher_send_groth16_bn254_infinite: crates/target/release/aligned ## Send a dif
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..."
658+
@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 \
663+
--proof_generator_addr 0x66f9664f97F2b50F62D13eA064982f936dE76657 \
664+
--rpc_url $(RPC_URL) \
665+
--network $(NETWORK)
666+
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..."
669+
@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 \
674+
--proof_generator_addr 0x66f9664f97F2b50F62D13eA064982f936dE76657 \
675+
--repetitions $(BURST_SIZE) \
676+
--rpc_url $(RPC_URL) \
677+
--network $(NETWORK)
678+
656679
batcher_send_proof_with_random_address: ## Send a proof with a random address to Batcher. Parameters: RPC_URL, NETWORK, PROOF_TYPE, REPETITIONS
657680
@cd crates/cli/ && ./send_proof_with_random_address.sh
658681

@@ -762,6 +785,13 @@ generate_gnark_groth16_bn254_ineq_proof: ## Run the gnark_plonk_bn254_script
762785
@echo "Running gnark_groth_bn254_ineq script..."
763786
@go run scripts/test_files/gnark_groth16_bn254_infinite_script/cmd/main.go 1
764787

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
791+
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
765795

766796
__CONTRACTS_DEPLOYMENT__: ## ____
767797
deploy_aligned_contracts: ## Deploy Aligned Contracts. Parameters: NETWORK=<mainnet|holesky|sepolia>

crates/cli/send_proof_with_random_address.sh

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22

33
# Params:
4-
# PROOF_TYPE = sp1|groth16|plonk|risc0 (default sp1)
4+
# PROOF_TYPE = sp1|groth16|plonk|risc0|circom (default sp1)
55
# RPC_URL (default localhost:8545)
66
# NETWORK devnet|holesky-stage|holesky
77
# REPETITIONS (default 1)
@@ -18,7 +18,7 @@ fi
1818

1919
if [ -z $PROOF_TYPE ]; then
2020
echo "Proof type not provided, using SP1 default"
21-
PROOF_TYPE="sp1" #sp1|groth16|plonk|risc0
21+
PROOF_TYPE="sp1" #sp1|groth16|plonk|risc0|circom
2222
fi
2323

2424
if [ -z $REPETITIONS ]; then
@@ -34,8 +34,8 @@ if [[ $PROOF_TYPE == "sp1" ]]; then
3434
--proving_system SP1 \
3535
--proof ../../scripts/test_files/sp1/sp1_fibonacci_5_0_0.proof \
3636
--vm_program ../../scripts/test_files/sp1/sp1_fibonacci_5_0_0.elf \
37-
--random_address \
38-
--repetitions $REPETITIONS \
37+
--random_address \
38+
--repetitions $REPETITIONS \
3939
--rpc_url $RPC_URL \
4040
--network $NETWORK
4141

@@ -45,8 +45,8 @@ elif [[ $PROOF_TYPE == "groth16" ]]; then
4545
--proof ../../scripts/test_files/gnark_groth16_bn254_script/groth16_0_12_0.proof \
4646
--public_input ../../scripts/test_files/gnark_groth16_bn254_script/groth16_0_12_0.pub \
4747
--vk ../../scripts/test_files/gnark_groth16_bn254_script/groth16_0_12_0.vk \
48-
--random_address \
49-
--repetitions $REPETITIONS \
48+
--random_address \
49+
--repetitions $REPETITIONS \
5050
--rpc_url $RPC_URL \
5151
--network $NETWORK
5252

@@ -57,21 +57,32 @@ elif [[ $PROOF_TYPE == "plonk" ]]; then
5757
--public_input ../../scripts/test_files/gnark_plonk_bn254_script/plonk_pub_input_0_12_0.pub \
5858
--vk ../../scripts/test_files/gnark_plonk_bn254_script/plonk_0_12_0.vk \
5959
--random_address \
60-
--repetitions $REPETITIONS \
60+
--repetitions $REPETITIONS \
6161
--rpc_url $RPC_URL \
6262
--network $NETWORK
6363

6464
elif [[ $PROOF_TYPE == "risc0" ]]; then
6565
aligned submit \
6666
--proving_system Risc0 \
6767
--proof ../../scripts/test_files/risc_zero/fibonacci_proof_generator/risc_zero_fibonacci_2_0.proof \
68-
--vm_program ../../scripts/test_files/risc_zero/fibonacci_proof_generator/fibonacci_id_2_0.bin \
69-
--public_input ../../scripts/test_files/risc_zero/fibonacci_proof_generator/risc_zero_fibonacci_2_0.pub \
68+
--vm_program ../../scripts/test_files/risc_zero/fibonacci_proof_generator/fibonacci_id_2_0.bin \
69+
--public_input ../../scripts/test_files/risc_zero/fibonacci_proof_generator/risc_zero_fibonacci_2_0.pub \
7070
--random_address \
71-
--repetitions $REPETITIONS \
71+
--repetitions $REPETITIONS \
7272
--rpc_url $RPC_URL \
7373
--network $NETWORK
7474

75+
elif [[ $PROOF_TYPE == "circom" ]]; then
76+
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 \
81+
--random_address \
82+
--repetitions $REPETITIONS \
83+
--rpc_url $RPC_URL \
84+
--network $NETWORK
85+
7586
else
7687
echo "Incorrect proof type provided $1"
7788
exit 1

scripts/test_files/README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ make generate_gnark_plonk_bn254_proof
3232
make generate_gnark_plonk_bls12_381_proof
3333
```
3434

35+
## Generate Circom Groth16 BN128 Proof
3536

37+
```bash
38+
make generate_circom_groth16_bn128_proof
39+
```
3640

37-
38-
41+
You can find more details about Circom in [./circom_groth16_bn128_script/README.md](./circom_groth16_bn128_script/README.md).
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Circom
2+
3+
# Circom Groth16 BN128 Script
4+
5+
The proof contained here is generated using the steps from [snarkjs repository](https://github.com/iden3/snarkjs) guide.
6+
7+
The example uses the following dependencies versions:
8+
9+
- Node version `v22.16.0`
10+
- Circom version `2.2.2`
11+
- Snarkjs version `0.7.5`
12+
13+
You can find how to install all dependencies in the snarkjs repository.
14+
15+
## Powers Of Tau Setup
16+
17+
You can run the following command from the repository root to create the setup:
18+
19+
```bash
20+
make generate_circom_groth16_bn128_setup
21+
```
22+
23+
## Generate the Circuit
24+
25+
You can modify `circuit.circom` and `input.json` files to create your own circuit and input.
26+
27+
## Generate the Proof
28+
29+
You can run the following command from the repository root to generate the proof:
30+
31+
```bash
32+
make generate_circom_groth16_bn128_proof
33+
```
34+
35+
This will generate the following files `proof.json`, `public.json`, and `verification_key.json` that can be sent to Aligned.
36+
37+
## Send the Proof to Aligned
38+
39+
You can run the following command from the repository root to send the proof to Aligned:
40+
41+
```bash
42+
make batcher_send_circom_groth16_bn128_task
43+
```
Binary file not shown.
Binary file not shown.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
pragma circom 2.0.0;
2+
3+
template Multiplier(n) {
4+
signal input a;
5+
signal input b;
6+
signal output c;
7+
8+
signal int[n];
9+
10+
int[0] <== a*a + b;
11+
for (var i=1; i<n; i++) {
12+
int[i] <== int[i-1]*int[i-1] + b;
13+
}
14+
15+
c <== int[n-1];
16+
}
17+
18+
component main = Multiplier(1000);
160 KB
Binary file not shown.

0 commit comments

Comments
 (0)