-
Notifications
You must be signed in to change notification settings - Fork 16
/
Makefile
281 lines (236 loc) · 15.1 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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
ROOT_DIR=$(pwd)
benchmark_directory = benchmarks
MATH = math
MACHINE := $(shell cat machine 2> /dev/null || echo DEFAULT)
ZKALC = -b dev https://github.com/asn-d6/zkalc.git
INPUTS = input
FRAMEWORK = src
# Math variables
arkworks_directory = arkworks
arkworks_benchmarks_directory = $(benchmark_directory)/$(MATH)/$(MACHINE)/$(arkworks_directory)
blstrs_directory = blstrs
blstrs_benchmarks_directory = $(benchmark_directory)/$(MATH)/$(MACHINE)/$(blstrs_directory)
curve25519_dalek_directory = curve25519-dalek
curve25519_dalek_benchmarks_directory = $(benchmark_directory)/$(MATH)/$(MACHINE)/$(curve25519_dalek_directory)
pasta_curves_directory = pasta_curves
pasta_curves_benchmarks_directory = $(benchmark_directory)/$(MATH)/$(MACHINE)/$(pasta_curves_directory)
halo2_curves_directory = halo2_curves
halo2_curves_benchmarks_directory = $(benchmark_directory)/$(MATH)/$(MACHINE)/$(halo2_curves_directory)
zkcrypto_directory = zkcrypto
zkcrypto_benchmarks_directory = $(benchmark_directory)/$(MATH)/$(MACHINE)/$(zkcrypto_directory)
pairing_ce_directory = pairing_ce
pairing_ce_benchmarks_directory = $(benchmark_directory)/$(MATH)/$(MACHINE)/$(pairing_ce_directory)
gnark_crypto_directory = gnark_crypto
gnark_crypto_benchmarks_directory = $(benchmark_directory)/$(MATH)/$(MACHINE)/$(gnark_crypto_directory)
ffjavascript_directory = ffjavascript
ffjavascript_benchmarks_directory = $(benchmark_directory)/$(MATH)/$(MACHINE)/$(ffjavascript_directory)
ffiasm_directory = ffiasm
ffiasm_benchmarks_directory = $(benchmark_directory)/$(MATH)/$(MACHINE)/$(ffiasm_directory)
all: math circuits
init:
cargo install cargo-criterion
math-init:
@if [ ! -d "math" ]; then mkdir -p math; fi
############################# ARITHMETICS ######################################
# TODO include ffiasm
math: math-arkworks math-arkworks-curves math-blstrs math-curve25519-dalek math-pasta-curves math-halo2-curves math-zkcrypto math-pairing-ce math-ffjavascript math-gnark
math-arkworks: init math-init
$(info --------------------------------------------)
$(info --------- ARKWORKS MATH BENCHMARKS ---------)
$(info --------------------------------------------)
mkdir -p $(arkworks_benchmarks_directory)
cd math && if [ ! -d "zkalc" ]; then git clone $(ZKALC); fi
cd math/zkalc/backend && make init
cd math/zkalc/backend/arkworks; cargo criterion --message-format=json 1> ../../../../$(arkworks_benchmarks_directory)/arkworks.json || true
math-arkworks-curves: init math-init
$(info --------------------------------------------)
$(info ------ ARKWORKS CURVES MATH BENCHMARKS -----)
$(info --------------------------------------------)
mkdir -p $(arkworks_benchmarks_directory)
cd math && if [ ! -d "zkalc" ]; then git clone $(ZKALC); fi
cd math/zkalc/backend && make init
cd math/zkalc/backend && git clone https://github.com/arkworks-rs/curves.git || true
cd math/zkalc/backend/curves; git fetch; git checkout releases; cargo criterion --features ark-ec/parallel,ark-ff/asm --message-format=json 1> ../../../../$(arkworks_benchmarks_directory)/ark-curves.json || true
math-blstrs: init math-init
$(info --------------------------------------------)
$(info -------- BLSTRS MATH BENCHMARKS ------------)
$(info --------------------------------------------)
mkdir -p $(blstrs_benchmarks_directory)
cd math && if [ ! -d "zkalc" ]; then git clone $(ZKALC); fi
cd math/zkalc/backend && make init
cd math/zkalc/backend/blstrs; cargo criterion --message-format=json 1> ../../../../$(blstrs_benchmarks_directory)/blstrs.json || true
math-curve25519-dalek: init math-init
$(info --------------------------------------------)
$(info ---- curve25519-dalek MATH BENCHMARKS ------)
$(info --------------------------------------------)
mkdir -p $(curve25519_dalek_benchmarks_directory)
cd math && if [ ! -d "zkalc" ]; then git clone $(ZKALC); fi
cd math/zkalc/backend && make init
cd math/zkalc/backend/curve25519-dalek; cargo criterion --message-format=json 1> ../../../../$(curve25519_dalek_benchmarks_directory)/curve25519-dalek.json || true
math-pasta-curves: init math-init
$(info --------------------------------------------)
$(info ----------- PASTA MATH BENCHMARKS ----------)
$(info --------------------------------------------)
mkdir -p $(pasta_curves_benchmarks_directory)
cd math && if [ ! -d "zkalc" ]; then git clone $(ZKALC); fi
cd math/zkalc/backend && make init
cd math/zkalc/backend/pasta_curves; cargo criterion --message-format=json 1> ../../../../$(pasta_curves_benchmarks_directory)/pasta_curves.json || true
math-halo2-curves: init math-init
$(info --------------------------------------------)
$(info ----------- HALO2 MATH BENCHMARKS ----------)
$(info --------------------------------------------)
mkdir -p $(halo2_curves_benchmarks_directory)
cd math && if [ ! -d "zkalc" ]; then git clone $(ZKALC); fi
cd math/zkalc/backend && make init
cd math/zkalc/backend/halo2_curves; cargo criterion --message-format=json 1> ../../../../$(halo2_curves_benchmarks_directory)/halo2_curves.json || true
math-zkcrypto: init math-init
$(info --------------------------------------------)
$(info -------- ZKCRYPTO MATH BENCHMARKS ----------)
$(info --------------------------------------------)
mkdir -p $(zkcrypto_benchmarks_directory)
cd math && if [ ! -d "zkalc" ]; then git clone $(ZKALC); fi
cd math/zkalc/backend && make init
cd math/zkalc/backend/zkcrypto; cargo criterion --message-format=json 1> ../../../../$(zkcrypto_benchmarks_directory)/zkcrypto.json || true
math-pairing-ce: init math-init
$(info --------------------------------------------)
$(info --------- Pairing CE MATHBENCHMARKS --------)
$(info --------------------------------------------)
mkdir -p $(pairing_ce_benchmarks_directory)
cd math && if [ ! -d "zkalc" ]; then git clone $(ZKALC); fi
cd math/zkalc/backend && make init
cd math/zkalc/backend/pairing_ce; cargo criterion --message-format=json 1> ../../../../$(pairing_ce_benchmarks_directory)/pairing_ce.json || true
math-ffjavascript: math-init
$(info --------------------------------------------)
$(info ------- ffjavascript MATHBENCHMARKS --------)
$(info --------------------------------------------)
mkdir -p $(ffjavascript_benchmarks_directory)
cd math && if [ ! -d "zkalc" ]; then git clone $(ZKALC); fi
cd math/zkalc/backend && make init
cd math/zkalc/backend/ffjavascript; node bench.js 2> ../../../../$(ffjavascript_benchmarks_directory)/ffjavascript.json || true
math-gnark: math-init
$(info --------------------------------------------)
$(info ----------- gnark MATHBENCHMARKS -----------)
$(info --------------------------------------------)
mkdir -p $(gnark_crypto_benchmarks_directory)
cd math && if [ ! -d "zkalc" ]; then git clone $(ZKALC); fi
cd math/zkalc/backend && make init
cd math/zkalc/backend; if [ ! -d "gnark-crypto" ]; then git clone -b zkalc https://github.com/ConsenSys/gnark-crypto.git; fi
cd math/zkalc/backend/gnark-crypto && \
bash ./zkalc.sh bls12-381 | tee ../../../../$(gnark_crypto_benchmarks_directory)/gnark-bls12-381.txt && \
bash ./zkalc.sh bls12-377 | tee ../../../../$(gnark_crypto_benchmarks_directory)/gnark-bls12-377.txt && \
bash ./zkalc.sh bn254 | tee ../../../../$(gnark_crypto_benchmarks_directory)/gnark-bn254.txt && \
bash ./zkalc.sh secp256k1 | tee ../../../../$(gnark_crypto_benchmarks_directory)/gnark-secp256k1.txt
math-ffiasm: math-init
$(info --------------------------------------------)
$(info ---------- ffiasm MATHBENCHMARKS -----------)
$(info --------------------------------------------)
mkdir -p $(ffiasm_benchmarks_directory)
cd math && if [ ! -d "zkalc" ]; then git clone $(ZKALC); fi
cd math/zkalc/backend && make init
cd math/zkalc/backend/ffiasm; node scripts/bench.js > ../../../../$(ffjavascript_benchmarks_directory)/ffjavascript.json || true
################################################################################
############################## CIRCUITS ########################################
circuits-test: benchmark-bellman-test-circuit benchmark-halo2-pse-test-circuit benchmark-circom-test-circuit gnark-init benchmark-gnark-test-circuit benchmark-starky-test-circuit
circuits: benchmark-bellman-circuits benchmark-halo2-pse-circuits benchmark-circom-circuits benchmark-gnark-circuits benchmark-starky-circuits
log-init:
mkdir -p .logs
gnark-init:
cd frameworks/gnark && go build
circom-init:
cd frameworks/circom/circuits/benchmarks && if [ ! -d "circomlib" ]; then git clone https://github.com/iden3/circomlib.git; fi
benchmark-bellman-test-circuit: init log-init
$(info --------------------------------------------)
$(info ----- BELLMAN TEST CIRCUIT BENCHMARKS -----)
$(info --------------------------------------------)
python3 -m $(FRAMEWORK).reader --config $(INPUTS)/config/bellman/config_test.json --machine $(MACHINE) 2>&1 | tee -a .logs/bellman.log
benchmark-bellman-test-sha256-circuit: init log-init
$(info --------------------------------------------)
$(info ----- BELLMAN TEST CIRCUIT BENCHMARKS -----)
$(info --------------------------------------------)
python3 -m $(FRAMEWORK).reader --config $(INPUTS)/config/bellman/config_sha256_test.json --machine $(MACHINE) 2>&1 | tee -a .logs/bellman.log
benchmark-bellman-circuits: init log-init
$(info --------------------------------------------)
$(info ------- BELLMAN CIRCUIT BENCHMARKS ---------)
$(info --------------------------------------------)
python3 -m $(FRAMEWORK).reader --config $(INPUTS)/config/bellman/config_circuits.json --machine $(MACHINE) 2>&1 | tee -a .logs/bellman.log
benchmark-halo2-pse-test-circuit: init log-init
$(info --------------------------------------------)
$(info ----- HALO2-PSE TEST CIRCUIT BENCHMARKS -----)
$(info --------------------------------------------)
python3 -m $(FRAMEWORK).reader --config $(INPUTS)/config/halo2_pse/config_test.json --machine $(MACHINE) 2>&1 | tee -a .logs/halo2_pse.log
benchmark-halo2-pse-test-sha256-circuit: init log-init
$(info --------------------------------------------)
$(info ----- HALO2-PSE TEST CIRCUIT BENCHMARKS -----)
$(info --------------------------------------------)
python3 -m $(FRAMEWORK).reader --config $(INPUTS)/config/halo2_pse/config_sha256_test.json --machine $(MACHINE) 2>&1 | tee -a .logs/halo2_pse.log
benchmark-halo2-pse-circuits: init log-init
$(info --------------------------------------------)
$(info ----- HALO2-PSE ARITHMETICS BENCHMARKS ------)
$(info --------------------------------------------)
python3 -m $(FRAMEWORK).reader --config $(INPUTS)/config/halo2_pse/config_circuits.json --machine $(MACHINE) 2>&1 | tee -a .logs/halo2_pse.log
benchmark-circom-test-circuit: init circom-init log-init
$(info --------------------------------------------)
$(info ----- CIRCOM TEST CIRCUIT BENCHMARKS -------)
$(info --------------------------------------------)
python3 -m $(FRAMEWORK).reader --config $(INPUTS)/config/circom/config_test.json --machine $(MACHINE) 2>&1 | tee -a .logs/circom.log
benchmark-circom-test-sha256-circuit: init circom-init log-init
$(info --------------------------------------------)
$(info ----- CIRCOM TEST CIRCUIT BENCHMARKS -------)
$(info --------------------------------------------)
python3 -m $(FRAMEWORK).reader --config $(INPUTS)/config/circom/config_sha256_test.json --machine $(MACHINE) 2>&1 | tee -a .logs/circom.log
benchmark-exponentiate-circom: init log-init
$(info --------------------------------------------)
$(info ----- CIRCOM EXPONENTIATE BENCHMARKS -------)
$(info --------------------------------------------)
python3 -m $(FRAMEWORK).reader --config $(INPUTS)/config/circom/config_exponentiate.json --machine $(MACHINE) 2>&1 | tee -a .logs/circom.log
benchmark-sha-circom: init circom-init log-init
$(info --------------------------------------------)
$(info -------- CIRCOM SHA256 BENCHMARKS ----------)
$(info --------------------------------------------)
python3 -m $(FRAMEWORK).reader --config $(INPUTS)/config/circom/config_sha.json --machine $(MACHINE) 2>&1 | tee -a .logs/circom.log
benchmark-circom-circuits: init circom-init log-init
$(info --------------------------------------------)
$(info -------- CIRCOM CIRCUIT BENCHMARKS ---------)
$(info --------------------------------------------)
python3 -m $(FRAMEWORK).reader --config $(INPUTS)/config/circom/config_circuits.json --machine $(MACHINE) 2>&1 | tee -a .logs/circom.log
benchmark-gnark-test-circuit: gnark-init log-init
$(info --------------------------------------------)
$(info ------ GNARK TEST CIRCUIT BENCHMARKS -------)
$(info --------------------------------------------)
python3 -m $(FRAMEWORK).reader --config $(INPUTS)/config/gnark/config_test.json --machine $(MACHINE) 2>&1 | tee -a .logs/gnark.log
benchmark-gnark--sha256-test-circuit: gnark-init log-init
$(info --------------------------------------------)
$(info ------ GNARK TEST CIRCUIT BENCHMARKS -------)
$(info --------------------------------------------)
python3 -m $(FRAMEWORK).reader --config $(INPUTS)/config/gnark/config_sha256_test.json --machine $(MACHINE) 2>&1 | tee -a .logs/gnark.log
benchmark-gnark-circuits: gnark-init log-init
$(info --------------------------------------------)
$(info -------- GNARK CIRCUITS BENCHMARKS ---------)
$(info --------------------------------------------)
python3 -m $(FRAMEWORK).reader --config $(INPUTS)/config/gnark/config_circuits.json --machine $(MACHINE) 2>&1 | tee -a .logs/gnark.log
benchmark-starky-test-circuit: init log-init
$(info --------------------------------------------)
$(info -------- STARKY TEST CIRCUIT BENCHMARKS --------)
$(info --------------------------------------------)
python3 -m $(FRAMEWORK).reader --config $(INPUTS)/config/starky/config_test.json --machine $(MACHINE) 2>&1 | tee -a .logs/starky.log
benchmark-starky-circuits: init log-init
$(info --------------------------------------------)
$(info -------- STARKY CIRCUIT BENCHMARKS --------)
$(info --------------------------------------------)
python3 -m $(FRAMEWORK).reader --config $(INPUTS)/config/starky/config_circuits.json --machine $(MACHINE) 2>&1 | tee -a .logs/starky.log
benchmark-comparison-circuits: init circom-init gnark-init log-init
python3 -m $(FRAMEWORK).reader --config $(INPUTS)/config/comparison/bellman.json --machine $(MACHINE) 2>&1 | tee -a .logs/bellman.log
python3 -m $(FRAMEWORK).reader --config $(INPUTS)/config/comparison/halo2_pse.json --machine $(MACHINE) 2>&1 | tee -a .logs/halo2_pse.log
python3 -m $(FRAMEWORK).reader --config $(INPUTS)/config/comparison/circom.json --machine $(MACHINE) 2>&1 | tee -a .logs/circom.log
python3 -m $(FRAMEWORK).reader --config $(INPUTS)/config/comparison/gnark.json --machine $(MACHINE) 2>&1 | tee -a .logs/gnark.log
python3 -m $(FRAMEWORK).reader --config $(INPUTS)/config/comparison/starky.json --machine $(MACHINE) 2>&1 | tee -a .logs/starky.log
################################################################################
############################## RECURSION #######################################
benchmark-gnark-recursion: gnark-init
$(info --------------------------------------------)
$(info ----------- GNARK RECURSION BENCHMARKS -----)
$(info --------------------------------------------)
python3 -m $(FRAMEWORK).reader --config $(INPUTS)/config/gnark/config_recursion.json --machine $(MACHINE)
################################################################################
clean:
rm -rf $(benchmark_directory)/*