forked from Daniel-Szego/fabriczkdemo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.sh
executable file
·89 lines (58 loc) · 2.45 KB
/
run.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/bash
set -evx
echo '###########################';
echo '#### COMPILE AND RUN #####';
echo '###########################';
echo "Compile main demo1 circuit";
circom demo1.circom --r1cs --wasm --sym
echo "View information on the demo1 circuit"
snarkjs r1cs info demo1.r1cs
# setup power of tau
cp preparedtau/pot14_0000.ptau demo1_js/pot14_0000.ptau
cp preparedtau/pot14_0001.ptau demo1_js/pot14_0001.ptau
cp preparedtau/pot14_beacon.ptau demo1_js/pot14_beacon.ptau
cp preparedtau/pot14_final.ptau demo1_js/pot14_final.ptau
#copy compiled file
cp input.json demo1_js
cp input.json demo1_cpp
cp demo1.r1cs demo1_js
cp demo1.r1cs demo1_cpp
# generate witness from js
echo "Generate witness from js"
cd demo1_js
node generate_witness.js demo1.wasm input.json witness.wtns
# trusted setup phase1 - powers of tau
echo "Trusted setup phase1 - powers of tau"
#snarkjs powersoftau new bn128 14 pot14_0000.ptau -v
#snarkjs powersoftau contribute pot14_0000.ptau pot14_0001.ptau --name="First contribution" -v
# trusted setup phase2
echo "Trusted setup phase2 power of tau"
#snarkjs powersoftau prepare phase2 pot14_0001.ptau pot14_final.ptau -v
#snarkjs powersoftau contribute pot14_0001.ptau pot14_0002.ptau --name="Second contribution" -v -e="some random text"
#snarkjs powersoftau export challenge pot14_0002.ptau challenge_0003
#snarkjs powersoftau challenge contribute bn128 challenge_0003 response_0003 -e="some random text"
#snarkjs powersoftau import response pot14_0002.ptau response_0003 pot18_0003.ptau -n="Third contribution name"
# verify the protocol
echo "Verify the protocol"
#snarkjs powersoftau verify pot14_0003.ptau
# random beacon
echo "Random beacon"
#snarkjs powersoftau beacon pot14_0003.ptau pot14_beacon.ptau 0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f 10 -n="Final Beacon"
# Prepare phase 2
echo "Random beacon"
#snarkjs powersoftau prepare phase2 pot14_beacon.ptau pot14_final.ptau -v
# Verify final
echo "Verify final power of tau"
#snarkjs powersoftau verify pot14_final.ptau
#setup plonk
echo "setup plonk"
snarkjs plonk setup demo1.r1cs pot14_final.ptau demo1_final.zkey
#export the verification key
echo "export the verification key"
snarkjs zkey export verificationkey demo1_final.zkey verification_key.json
# create proof plonk
echo "create proof plonk"
snarkjs plonk prove demo1_final.zkey witness.wtns proof.json public.json
# verify proof
echo "verify proof"
snarkjs plonk verify verification_key.json public.json proof.json