-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
175 lines (135 loc) Β· 8.65 KB
/
Makefile
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
.PHONY = all
TMPDIR := $(shell mktemp -d)
# trusted set up
rapidsnark/package/bin/prover:
cd circuit/rapidsnark && git submodule init
cd circuit/rapidsnark && git submodule update
cd circuit/rapidsnark && ./build_gmp.sh host
cd circuit/rapidsnark && mkdir -p build_prover
cd circuit/rapidsnark && cd build_prover && cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../package
cd circuit/rapidsnark && cd build_prover && make -j4 && make install
extension: make-verifier firefox chrome
trusted_setup:
mkdir -p circuit/temp/setup
cd circuit && snarkjs powersoftau new bn128 21 temp/setup/pot12_0000.ptau -v
cd circuit && snarkjs powersoftau contribute temp/setup/pot12_0000.ptau temp/setup/pot12_0001.ptau --entropy=1234 --name="first contribution" -v
cd circuit && snarkjs powersoftau prepare phase2 temp/setup/pot12_0001.ptau temp/setup/pot12_final.ptau -v
# mpt_path commands
mpt_path:
mkdir -p circuit/temp/mpt_path
cd circuit && circom mpt_path.circom --r1cs --wasm --sym --c
mv circuit/mpt_path_cpp circuit/temp/mpt_path
mv circuit/mpt_path_js circuit/temp/mpt_path
mv circuit/temp/mpt_path/mpt_path_cpp/main.cpp circuit/temp/mpt_path/mpt_path_cpp/main.cpp.tmp
python3 scripts/spit_output.py < circuit/temp/mpt_path/mpt_path_cpp/main.cpp.tmp > circuit/temp/mpt_path/mpt_path_cpp/main.cpp
rm circuit/temp/mpt_path/mpt_path_cpp/main.cpp.tmp
cd circuit/temp/mpt_path/mpt_path_cpp && make
mv circuit/mpt_path.r1cs circuit/temp/mpt_path/mpt_path.r1cs
mv circuit/mpt_path.sym circuit/temp/mpt_path/mpt_path.sym
mpt_path_zkey:
cd circuit && snarkjs groth16 setup temp/mpt_path/mpt_path.r1cs temp/setup/pot20_final.ptau mpt_path_0000.zkey
mv circuit/mpt_path_0000.zkey circuit/temp/mpt_path/mpt_path_0000.zkey
cd circuit && snarkjs zkey contribute temp/mpt_path/mpt_path_0000.zkey temp/mpt_path/mpt_path_0001.zkey --entropy=1234 --name="second contribution" -v
mpt_path_vkey:
cd circuit && snarkjs zkey export verificationkey temp/mpt_path/mpt_path_0013.zkey temp/mpt_path/verification_key.json
# mpt_last commands
mpt_last:
mkdir -p circuit/temp/mpt_last
cd circuit && circom mpt_last.circom --r1cs --wasm --sym --c
mv circuit/mpt_last_cpp circuit/temp/mpt_last
mv circuit/mpt_last_js circuit/temp/mpt_last
mv circuit/temp/mpt_last/mpt_last_cpp/main.cpp circuit/temp/mpt_last/mpt_last_cpp/main.cpp.tmp
python3 scripts/spit_output.py < circuit/temp/mpt_last/mpt_last_cpp/main.cpp.tmp > circuit/temp/mpt_last/mpt_last_cpp/main.cpp
rm circuit/temp/mpt_last/mpt_last_cpp/main.cpp.tmp
cd circuit/temp/mpt_last/mpt_last_cpp && make
mv circuit/mpt_last.r1cs circuit/temp/mpt_last/mpt_last.r1cs
mv circuit/mpt_last.sym circuit/temp/mpt_last/mpt_last.sym
mpt_last_zkey:
cd circuit && snarkjs groth16 setup temp/mpt_last/mpt_last.r1cs temp/setup/pot20_final.ptau mpt_last_0000.zkey
mv circuit/mpt_last_0000.zkey circuit/temp/mpt_last/mpt_last_0000.zkey
cd circuit && snarkjs zkey contribute temp/mpt_last/mpt_last_0000.zkey temp/mpt_last/mpt_last_0001.zkey --entropy=1234 --name="second contribution" -v
mpt_last_vkey:
cd circuit && snarkjs zkey export verificationkey temp/mpt_last/mpt_last_0013.zkey temp/mpt_last/verification_key.json
# stealth_balance_addition commands
stealth_balance_addition:
mkdir -p circuit/temp/stealth_balance_addition
cd circuit && circom stealth_balance_addition.circom --r1cs --wasm --sym --c
mv circuit/stealth_balance_addition_cpp circuit/temp/stealth_balance_addition
mv circuit/stealth_balance_addition_js circuit/temp/stealth_balance_addition
mv circuit/temp/stealth_balance_addition/stealth_balance_addition_cpp/main.cpp circuit/temp/stealth_balance_addition/stealth_balance_addition_cpp/main.cpp.tmp
python3 scripts/spit_output.py < circuit/temp/stealth_balance_addition/stealth_balance_addition_cpp/main.cpp.tmp > circuit/temp/stealth_balance_addition/stealth_balance_addition_cpp/main.cpp
rm circuit/temp/stealth_balance_addition/stealth_balance_addition_cpp/main.cpp.tmp
cd circuit/temp/stealth_balance_addition/stealth_balance_addition_cpp && make
mv circuit/stealth_balance_addition.r1cs circuit/temp/stealth_balance_addition/stealth_balance_addition.r1cs
mv circuit/stealth_balance_addition.sym circuit/temp/stealth_balance_addition/stealth_balance_addition.sym
stealth_balance_addition_zkey:
cd circuit && snarkjs groth16 setup temp/stealth_balance_addition/stealth_balance_addition.r1cs temp/setup/pot20_final.ptau stealth_balance_addition_0000.zkey
mv circuit/stealth_balance_addition_0000.zkey circuit/temp/stealth_balance_addition/stealth_balance_addition_0000.zkey
cd circuit && snarkjs zkey contribute temp/stealth_balance_addition/stealth_balance_addition_0000.zkey temp/stealth_balance_addition/stealth_balance_addition_0001.zkey --entropy=1234 --name="second contribution" -v
stealth_balance_addition_vkey:
cd circuit && snarkjs zkey export verificationkey temp/stealth_balance_addition/stealth_balance_addition_0013.zkey temp/stealth_balance_addition/verification_key.json
# pol commands
pol:
mkdir -p circuit/temp/pol
cd circuit && circom pol.circom --r1cs --wasm --sym --c
mv circuit/pol_cpp circuit/temp/pol
mv circuit/pol_js circuit/temp/pol
mv circuit/temp/pol/pol_cpp/main.cpp circuit/temp/pol/pol_cpp/main.cpp.tmp
python3 scripts/spit_output.py < circuit/temp/pol/pol_cpp/main.cpp.tmp > circuit/temp/pol/pol_cpp/main.cpp
rm circuit/temp/pol/pol_cpp/main.cpp.tmp
cd circuit/temp/pol/pol_cpp && make
mv circuit/pol.r1cs circuit/temp/pol/pol.r1cs
mv circuit/pol.sym circuit/temp/pol/pol.sym
pol_zkey:
cd circuit && snarkjs groth16 setup temp/pol/pol.r1cs temp/setup/pot20_final.ptau pol_0000.zkey
mv circuit/pol_0000.zkey circuit/temp/pol/pol_0000.zkey
cd circuit && snarkjs zkey contribute temp/pol/pol_0000.zkey temp/pol/pol_0001.zkey --entropy=1234 --name="second contribution" -v
pol_vkey:
cd circuit && snarkjs zkey export verificationkey temp/pol/pol_0013.zkey temp/pol/verification_key.json
# ecdsa verify commands
ecdsa_verify:
mkdir -p circuit/temp/ecdsa_verify
cd circuit && circom ecdsa_verify.circom --r1cs --wasm --sym --c
mv circuit/ecdsa_verify_cpp circuit/temp/ecdsa_verify
mv circuit/ecdsa_verify_js circuit/temp/ecdsa_verify
mv circuit/temp/ecdsa_verify/ecdsa_verify_cpp/main.cpp circuit/temp/ecdsa_verify/ecdsa_verify_cpp/main.cpp.tmp
python3 scripts/spit_output.py < circuit/temp/ecdsa_verify/ecdsa_verify_cpp/main.cpp.tmp > circuit/temp/ecdsa_verify/ecdsa_verify_cpp/main.cpp
rm circuit/temp/ecdsa_verify/ecdsa_verify_cpp/main.cpp.tmp
cd circuit/temp/ecdsa_verify/ecdsa_verify_cpp && make
mv circuit/ecdsa_verify.r1cs circuit/temp/ecdsa_verify/ecdsa_verify.r1cs
mv circuit/ecdsa_verify.sym circuit/temp/ecdsa_verify/ecdsa_verify.sym
ecdsa_verify_zkey:
cd circuit && snarkjs groth16 setup temp/ecdsa_verify/ecdsa_verify.r1cs temp/setup/pot22_final.ptau ecdsa_verify_0000.zkey
mv circuit/ecdsa_verify_0000.zkey circuit/temp/ecdsa_verify/ecdsa_verify_0000.zkey
cd circuit && snarkjs zkey contribute temp/ecdsa_verify/ecdsa_verify_0000.zkey temp/ecdsa_verify/ecdsa_verify_0001.zkey --entropy=1234 --name="second contribution" -v
ecdsa_verify_vkey:
cd circuit && snarkjs zkey export verificationkey temp/ecdsa_verify/ecdsa_verify_0013.zkey temp/ecdsa_verify/verification_key.json
firefox: TMPDIR := $(shell mktemp -d)
firefox:
mkdir -p extensions
cp -r verifier/extension/firefox/* $(TMPDIR)
cp -r verifier/extension/common/* $(TMPDIR)
FILES="$(TMPDIR)/background.js $(TMPDIR)/content.js $(TMPDIR)/popup.js"
for file in $(FILES); do \
sed -i 's/chrome/browser/g' $$file; \
done
cd $(TMPDIR) && zip -r Firefox-sigmab.zip .
mv $(TMPDIR)/Firefox-sigmab.zip extensions/Firefox-sigmab.xpi
chrome: TMPDIR := $(shell mktemp -d)
chrome:
mkdir -p extensions
cp -r verifier/extension/chrome/* $(TMPDIR)
cp -r verifier/extension/common/* $(TMPDIR)
cd $(TMPDIR) && zip -r Chrome-sigmab.zip .
mv $(TMPDIR)/Chrome-sigmab.zip extensions/Chrome-sigmab.zip
make-verifier:
cd verifier && make all
verification_keys: ecdsa_verify_vkey mpt_path_vkey mpt_last_vkey stealth_balance_addition_vkey pol_vkey
# utils
clean:
find . -type d -name '__pycache__' -exec rm -rf {} +
rm -rf circuit/*.r1cs circuit/*.wasm circuit/*.sym circuit/*.json circuit/*.wtns circuit/mpt_last_cpp/ circuit/mpt_last_js/ circuit/mpt_last_cpp/ circuit/mpt_last_js/ circuit/mpt_path_cpp/ circuit/mpt_path_js/ circuit/stealth_balance_addition_cpp/ circuit/stealth_balance_addition_js/
clean_all: clean
rm -rf circuit/*.zkey
# install: clean rapidsnark/package/bin/prover mpt_path mpt_path_zkey mpt_last mpt_last_zkey stealth_balance_addition stealth_balance_addition_zkey pol pol_zkey ecdsa_verify ecdsa_verify_zkey
install: clean mpt_path mpt_path_zkey mpt_last mpt_last_zkey stealth_balance_addition stealth_balance_addition_zkey pol pol_zkey ecdsa_verify ecdsa_verify_zkey