-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathMakefile
172 lines (137 loc) · 5.25 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
SHELL:=/bin/bash
DIR := ${CURDIR}
output ?= 'build/'
test: test-circuits test-py934 test-contracts
# -------------------- Dev Containers -------------------- #
container-python:
$(info Make: build container for py934)
@docker build -f containers/py934.dockerfile ./ -t ethereum-mw-zokrates-python
container-circuit:
$(info Make: build container and compile circuits)
@docker build -f containers/zokrates.dockerfile ./ -t ethereum-mw-zokrates
container-zokrates-pycrypto: # Used for utils/create_challenge_circuit.py
$(info Make: build zokrates pycrypto container for py934)
@docker build -f containers/zokrates_pycrypto.dockerfile ./ -t ethereum-mw-zokrates-pycrypto
clear-host:
$(info Make: erase ZoKrates output files)
@(rm out out.ztf proof.json proving.key verification.key witness || true) 2> /dev/null
clear-circuit-image:
@(docker rmi ethereum-mw-zokrates || true) 2> /dev/null
# -------------------- ZK Containers -------------------- #
container-zk-deposit:
@docker build -f containers/zkDeposit.dockerfile ./ -t ethereum934/zk-deposit
container-zk-range-proof:
@docker build -f containers/zkRangeProof.dockerfile ./ -t ethereum934/zk-range-proof
container-zk-mimblewimble:
@docker build -f containers/zkMimblewimble.dockerfile ./ -t ethereum934/zk-mimblewimble
container-zk-withdraw:
@docker build -f containers/zkWithdraw.dockerfile ./ -t ethereum934/zk-withdraw
container-zk-mmr-inclusion:
@docker build -f containers/zkMMRInclusion.dockerfile ./ -t ethereum934/zk-mmr-inclusion
container-zk-roll-up:
@docker build -f containers/zkRollUp.dockerfile ./ -t ethereum934/zk-roll-up
container-zk-roll-up-1:
@docker build -f containers/zkRollUp1.dockerfile ./ -t ethereum934/zk-roll-up-1
container-zk-roll-up-2:
@docker build -f containers/zkRollUp2.dockerfile ./ -t ethereum934/zk-roll-up-2
container-zk-roll-up-4:
@docker build -f containers/zkRollUp4.dockerfile ./ -t ethereum934/zk-roll-up-4
container-zk-roll-up-8:
@docker build -f containers/zkRollUp8.dockerfile ./ -t ethereum934/zk-roll-up-8
container-zk-roll-up-16:
@docker build -f containers/zkRollUp16.dockerfile ./ -t ethereum934/zk-roll-up-16
container-zk-roll-up-32:
@docker build -f containers/zkRollUp32.dockerfile ./ -t ethereum934/zk-roll-up-32
container-zk-roll-up-64:
@docker build -f containers/zkRollUp64.dockerfile ./ -t ethereum934/zk-roll-up-64
container-zk-roll-up-128:
@docker build -f containers/zkRollUp128.dockerfile ./ -t ethereum934/zk-roll-up-128
# -------------------- Commands for circuit -------------------- #
test-circuits: clear-host clear-circuit-image clear-container container-circuit
$(info Make: Run unit test for circuits)
@docker run\
--name zokrates-tmp \
ethereum-mw-zokrates \
/bin/bash -c "\
./zokrates compile --light -i tests/circuits/unitTest.zok;\
./zokrates setup --light;\
./zokrates compute-witness --light;\
./zokrates generate-proof;\
"
@docker rm zokrates-tmp
test-host-circuits:
$(info Make: Run unit test for circuits)
@zokrates compile --light -i tests/circuits/unitTest.zok
@zokrates setup --light
@zokrates compute-witness --light
@zokrates generate-proof
verifier: container-circuit clear-container
$(info Make: compile circuits)
@docker run \
--name zokrates-tmp \
ethereum-mw-zokrates \
/bin/bash -c "\
./zokrates compile -i $(circuit);\
./zokrates setup;\
./zokrates export-verifier" \
@mkdir -p build
@docker cp zokrates-tmp:/home/zokrates/verifier.sol $(output)
@docker rm zokrates-tmp
@echo Successfully generated verifier.
@echo ---------------- result -------------------
@echo Circuit: $(circuit)
@echo Output: $(output)
proof: container-circuit clear-container
$(info Make: Generate zkSNARKs proof)
@docker run \
--name zokrates-tmp \
ethereum-mw-zokrates \
/bin/bash -c "\
./zokrates compile -i $(circuit);\
./zokrates setup;\
./zokrates compute-witness $(if $(args), -a $(args)) ;\
./zokrates generate-proof;\
"
@mkdir -p build
@docker cp zokrates-tmp:/home/zokrates/proof.json $(output)
@docker rm zokrates-tmp
@echo ---------------- result -------------------
@echo Circuit: $(circuit)
@echo Args: $(args)
@echo Output: $(output)
shell: container-circuit clear-container
$(info Make: Generate zkSNARKs proof)
@docker run \
-it \
--rm
--name zokrates-tmp \
ethereum-mw-zokrates \
hash-circuit: container-zokrates-pycrypto clear-container
$(info Make: get hasher circuit for tx challenge)
@docker run \
-it \
--name zokrates-tmp \
ethereum-mw-zokrates-pycrypto \
create_challenge_circuit.py
@docker cp zokrates-tmp:/pycrypto/challengeHasher.zok $(output)
@docker rm zokrates-tmp
clear-container:
@(docker rm zokrates-tmp || true) 2> /dev/null
# -------------------- Commands for py934 library -------------------- #
install-python:
@pip3 install -q virtualenv
@[[ -d .venv ]] || virtualenv .venv -p python3
@source .venv/bin/activate; pip3 install -q -r requirements.txt
test-py934: install-python
@source .venv/bin/activate; python -m unittest tests/test*.py
sample_data: install-python
@source .venv/bin/activate; python sample.py
# -------------------- Commands for contracts -------------------- #
install-node:
@npm install
test-contracts:
@npm run test;
# -------------------- Commands for CI/CI -------------------- #
# TODO
travis: compile
$(info Make: Running Travis CI Locally)