Skip to content

Commit be11294

Browse files
committed
chore: no pub input proof
1 parent 0f46e92 commit be11294

File tree

9 files changed

+282
-0
lines changed

9 files changed

+282
-0
lines changed

Makefile

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,30 @@ batcher_send_circom_groth16_bn256_burst: crates/target/release/aligned ## Send a
681681
--rpc_url $(RPC_URL) \
682682
--network $(NETWORK)
683683

684+
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
685+
@echo "Sending Circom Groth16 BN256 proof to Batcher..."
686+
@cd crates/cli/ && cargo run --release -- submit \
687+
--proving_system CircomGroth16Bn256 \
688+
--proof ../../scripts/test_files/circom_groth16_bn256_script/proof.json \
689+
--public_input ../../scripts/test_files/circom_groth16_bn256_script/public.json \
690+
--vk ../../scripts/test_files/circom_groth16_bn256_script/verification_key.json \
691+
--proof_generator_addr 0x66f9664f97F2b50F62D13eA064982f936dE76657 \
692+
--repetitions $(BURST_SIZE) \
693+
--rpc_url $(RPC_URL) \
694+
--network $(NETWORK)
695+
696+
batcher_send_circom_groth16_bn256_no_pub_input_burst: crates/target/release/aligned ## Send a burst of Circom Groth16 BN256 proofs to Batcher. Parameters: RPC_URL, NETWORK, BURST_SIZE
697+
@echo "Sending Circom Groth16 BN256 proof to Batcher..."
698+
@cd crates/cli/ && cargo run --release -- submit \
699+
--proving_system CircomGroth16Bn256 \
700+
--proof ../../scripts/test_files/circom_groth16_bn256_no_pub_input_script/proof.json \
701+
--public_input ../../scripts/test_files/circom_groth16_bn256_no_pub_input_script/public.json \
702+
--vk ../../scripts/test_files/circom_groth16_bn256_no_pub_input_script/verification_key.json \
703+
--proof_generator_addr 0x66f9664f97F2b50F62D13eA064982f936dE76657 \
704+
--repetitions $(BURST_SIZE) \
705+
--rpc_url $(RPC_URL) \
706+
--network $(NETWORK)
707+
684708
batcher_send_proof_with_random_address: ## Send a proof with a random address to Batcher. Parameters: RPC_URL, NETWORK, PROOF_TYPE, REPETITIONS
685709
@cd crates/cli/ && ./send_proof_with_random_address.sh
686710

@@ -802,6 +826,14 @@ generate_circom_groth16_bn256_setup: ## Run the circom_groth16_bn256_script setu
802826
@echo "Running circom_groth16_bn256 script setup..."
803827
@cd scripts/test_files/circom_groth16_bn256_script && ./generate_setup.sh
804828

829+
generate_circom_groth16_bn256_no_pub_input_proof: ## Run the circom_groth16_bn256_script
830+
@echo "Running circom_groth16_bn256 script..."
831+
@cd scripts/test_files/circom_groth16_bn256_no_pub_input_script && ./generate_proof.sh
832+
833+
generate_circom_groth16_bn256_no_pub_input_setup: ## Run the circom_groth16_bn256_script setup
834+
@echo "Running circom_groth16_bn256_no_pub_input_script setup..."
835+
@cd scripts/test_files/circom_groth16_bn256_no_pub_input_script && ./generate_setup.sh
836+
805837
__CONTRACTS_DEPLOYMENT__: ## ____
806838
deploy_aligned_contracts: ## Deploy Aligned Contracts. Parameters: NETWORK=<mainnet|holesky|sepolia>
807839
@echo "Deploying Aligned Contracts on $(NETWORK) network..."
@@ -1150,6 +1182,19 @@ docker_batcher_send_circom_groth16_bn256_burst:
11501182
--rpc_url $(DOCKER_RPC_URL) \
11511183
--max_fee 0.1ether
11521184

1185+
docker_batcher_send_circom_groth16_bn256_burst:
1186+
@echo "Sending Circom Groth16 BN256 task to Batcher..."
1187+
docker exec $(shell docker ps | grep batcher | awk '{print $$1}') aligned submit \
1188+
--private_key $(DOCKER_PROOFS_PRIVATE_KEY) \
1189+
--proving_system CircomGroth16Bn256 \
1190+
--proof ./scripts/test_files/circom_groth16_bn256_no_pub_input_script/proof.json \
1191+
--public_input ./scripts/test_files/circom_groth16_bn256_no_pub_input_script/public.json \
1192+
--vk ./scripts/test_files/circom_groth16_bn256_no_pub_input_script/verification_key.json \
1193+
--proof_generator_addr $(PROOF_GENERATOR_ADDRESS) \
1194+
--repetitions $(DOCKER_BURST_SIZE) \
1195+
--rpc_url $(DOCKER_RPC_URL) \
1196+
--max_fee 0.1ether
1197+
11531198
# Update target as new proofs are supported.
11541199
docker_batcher_send_all_proofs_burst:
11551200
@$(MAKE) docker_batcher_send_sp1_burst
@@ -1158,6 +1203,7 @@ docker_batcher_send_all_proofs_burst:
11581203
@$(MAKE) docker_batcher_send_gnark_plonk_bls12_381_burst
11591204
@$(MAKE) docker_batcher_send_gnark_groth16_burst
11601205
@$(MAKE) docker_batcher_send_circom_groth16_bn256_burst
1206+
@$(MAKE) docker_batcher_send_circom_groth16_bn256_no_pub_input_burst
11611207

11621208
docker_batcher_send_infinite_groth16:
11631209
docker exec $(shell docker ps | grep batcher | awk '{print $$1}') \
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Circom
2+
3+
# Circom Groth16 BN256 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_bn256_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_bn256_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_bn256_task
43+
```
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
pragma circom 2.0.0;
2+
3+
template Multiplier(n) {
4+
signal input a;
5+
signal input b;
6+
7+
signal int[n];
8+
9+
int[0] <== a*a + b;
10+
for (var i=1; i<n; i++) {
11+
int[i] <== int[i-1]*int[i-1] + b;
12+
}
13+
}
14+
15+
component main = Multiplier(1000);
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
3+
# Reference: https://github.com/iden3/snarkjs?tab=readme-ov-file#10-compile-the-circuit
4+
5+
# 10. Compile the circuit
6+
circom --r1cs --wasm --c --sym --inspect circuit.circom
7+
# 11. View information about the circuit
8+
snarkjs r1cs info circuit.r1cs
9+
# 12. Print the constraints [omitted]
10+
# 13. Export r1cs to json
11+
snarkjs r1cs export json circuit.r1cs circuit.r1cs.json
12+
# 14. Calculate the witness
13+
snarkjs wtns calculate circuit_js/circuit.wasm input.json witness.wtns
14+
# 15. Setup. This generates the reference zkey without phase 2 contributions.
15+
#IMPORTANT: Do not use this zkey in production, as it's not safe. It requires at least one contribution.
16+
snarkjs groth16 setup circuit.r1cs pot14_final.ptau circuit_0000.zkey
17+
# 16. Contribute to the phase 2 ceremony
18+
snarkjs zkey contribute circuit_0000.zkey circuit_0001.zkey --name="1st Contributor Name" -v -e="Random entropy"
19+
# 17. Provide a second contribution
20+
snarkjs zkey contribute circuit_0001.zkey circuit_0002.zkey --name="Second contribution Name" -v -e="Another random entropy"
21+
# 18. Provide a third contribution using third-party software
22+
snarkjs zkey export bellman circuit_0002.zkey challenge_phase2_0003
23+
snarkjs zkey bellman contribute bn128 challenge_phase2_0003 response_phase2_0003 -e="some random text"
24+
snarkjs zkey import bellman circuit_0002.zkey response_phase2_0003 circuit_0003.zkey -n="Third contribution name"
25+
# 19. Verify the latest zkey. Expected output: [INFO] snarkJS: ZKey Ok!
26+
snarkjs zkey verify circuit.r1cs pot14_final.ptau circuit_0003.zkey
27+
# 20. Apply a random beacon
28+
snarkjs zkey beacon circuit_0003.zkey circuit_final.zkey 0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f 10 -n="Final Beacon phase2"
29+
# 21. Verify the final zkey. Expected output: [INFO] snarkJS: ZKey Ok!
30+
snarkjs zkey verify circuit.r1cs pot14_final.ptau circuit_final.zkey
31+
# 22. Export the verification key
32+
snarkjs zkey export verificationkey circuit_final.zkey verification_key.json
33+
# 23a. Calculate the witness and generate the proof in one step
34+
snarkjs groth16 fullprove input.json circuit_js/circuit.wasm circuit_final.zkey proof.json public.json
35+
# 24. Verify the proof
36+
snarkjs groth16 verify verification_key.json public.json proof.json
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
3+
# Reference: https://github.com/iden3/snarkjs?tab=readme-ov-file#guide
4+
5+
# 1. Start a new powers of tau ceremony
6+
snarkjs powersoftau new bn128 14 pot14_0000.ptau -v
7+
# 2. Contribute to the ceremony
8+
snarkjs powersoftau contribute pot14_0000.ptau pot14_0001.ptau --name="First contribution" -v -e="random text"
9+
# 3. Provide a second contribution
10+
snarkjs powersoftau contribute pot14_0001.ptau pot14_0002.ptau --name="Second contribution" -v -e="some random text"
11+
# 4. Provide a third contribution using third-party software
12+
snarkjs powersoftau export challenge pot14_0002.ptau challenge_0003
13+
snarkjs powersoftau challenge contribute bn128 challenge_0003 response_0003 -e="some random text"
14+
snarkjs powersoftau import response pot14_0002.ptau response_0003 pot14_0003.ptau -n="Third contribution name"
15+
# 5. Verify the protocol so far. Expected output: [INFO] snarkJS: Powers Of tau file OK!
16+
snarkjs powersoftau verify pot14_0003.ptau
17+
# 6. Apply a random beacon
18+
snarkjs powersoftau beacon pot14_0003.ptau pot14_beacon.ptau 0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f 10 -n="Final Beacon"
19+
# 7. Prepare phase 2
20+
snarkjs powersoftau prepare phase2 pot14_beacon.ptau pot14_final.ptau -v
21+
# 8. Verify the final ptau. Expected output: [INFO] snarkJS: Powers Of tau file OK!
22+
snarkjs powersoftau verify pot14_final.ptau
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"a": "3", "b": "11"}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"pi_a": [
3+
"21115072306665429462411829368444576367879206259680368742926845548421610954551",
4+
"15826536162676673837980007775740459522013073279102639374712653649720748872772",
5+
"1"
6+
],
7+
"pi_b": [
8+
[
9+
"4845785036047210842142226094121857163165608567619117024784667074391801372377",
10+
"9028619228048001148193967186400054764464887421288541697509556909627454079279"
11+
],
12+
[
13+
"12944744135789192752462212041234439894259735627924745469549879163050103608423",
14+
"11752478782553721856146095067985349625362268652660459598755905158140228002930"
15+
],
16+
[
17+
"1",
18+
"0"
19+
]
20+
],
21+
"pi_c": [
22+
"16696174294419323158962184231720596589000877982616737512707227478200342723123",
23+
"17448524601342443201136768874617298247438105858194482786393832425341658081152",
24+
"1"
25+
],
26+
"protocol": "groth16",
27+
"curve": "bn128"
28+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[
2+
]
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
{
2+
"protocol": "groth16",
3+
"curve": "bn128",
4+
"nPublic": 0,
5+
"vk_alpha_1": [
6+
"9918779842916137281097309067967447678092346302589441779684890414805015302043",
7+
"2245116006205267256637482652017527774340433767985148344592689486682492060011",
8+
"1"
9+
],
10+
"vk_beta_2": [
11+
[
12+
"19795467846227506669566569327407628629743756653390154296116707327727713422404",
13+
"10080100522896944319373435167629871914362737790814693466030029221896331234517"
14+
],
15+
[
16+
"19759588999483567265023876438218873988005360787151938876529379368240470191178",
17+
"5317290321919815360243199114751102516407246330013705305982498762442107602094"
18+
],
19+
[
20+
"1",
21+
"0"
22+
]
23+
],
24+
"vk_gamma_2": [
25+
[
26+
"10857046999023057135944570762232829481370756359578518086990519993285655852781",
27+
"11559732032986387107991004021392285783925812861821192530917403151452391805634"
28+
],
29+
[
30+
"8495653923123431417604973247489272438418190587263600148770280649306958101930",
31+
"4082367875863433681332203403145435568316851327593401208105741076214120093531"
32+
],
33+
[
34+
"1",
35+
"0"
36+
]
37+
],
38+
"vk_delta_2": [
39+
[
40+
"5287361561597638696038027252542940370959047220310558007301254484274339330488",
41+
"18272692030405171489109274923485403268320088128873909211101977818292274841169"
42+
],
43+
[
44+
"14654816428436565836434527237856782653795654809717771541703971003808823958299",
45+
"15886140518148207144428608264454650790323552915769593371590332093703353820495"
46+
],
47+
[
48+
"1",
49+
"0"
50+
]
51+
],
52+
"vk_alphabeta_12": [
53+
[
54+
[
55+
"3182515837374218761009070153560922289064544472417838715134676045207166200360",
56+
"15659148447587893543886047421633238551025300458345827071432549113398554891235"
57+
],
58+
[
59+
"13887299608070640627132065424084075601341702759894905437162747298652611697390",
60+
"10675729835856677595687776050478323090319528241507665171447458056598502946963"
61+
],
62+
[
63+
"14507481048827104381798666262303976489642927640406980577716667947693499191589",
64+
"14975520060376076248474809153913591829160422889026946289992216932658233867411"
65+
]
66+
],
67+
[
68+
[
69+
"21059438183867423682317149130719186445987793317408924192640354639329450697471",
70+
"11003668531704953363826853895606213390237922406572243668320862389217835149181"
71+
],
72+
[
73+
"14710533077736251471613604614330360554556169821677374963562297885732680654515",
74+
"4125833891513511202328278038252740396387683586056321955026371171439730615009"
75+
],
76+
[
77+
"7367634504283625178823087271321834055831898266075634933430441740161893333838",
78+
"13126892315670296393128090729667943403129997007324887301003814581169974890399"
79+
]
80+
]
81+
],
82+
"IC": [
83+
[
84+
"10796297048381905247493692435112713250994815306385524265224436462521926571575",
85+
"13152853727442722440671915253166300291574018033419252989329493517423165625421",
86+
"1"
87+
]
88+
]
89+
}

0 commit comments

Comments
 (0)