forked from HarryR/ethsnarks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
213 lines (138 loc) · 5.11 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
ROOT_DIR := $(shell dirname $(realpath $(MAKEFILE_LIST)))
ifeq ($(OS),Windows_NT)
detected_OS := Windows
DLL_EXT := .dll
else
detected_OS := $(shell uname -s)
ifeq ($(detected_OS),Darwin)
DLL_EXT := .dylib
export LD_LIBRARY_PATH := /usr/local/opt/openssl/lib:"$(LD_LIBRARY_PATH)"
export CPATH := /usr/local/opt/openssl/include:"$(CPATH)"
export PKG_CONFIG_PATH := /usr/local/opt/openssl/lib/pkgconfig:"$(PKG_CONFIG_PATH)"
else
DLL_EXT := .so
endif
endif
PIP_ARGS ?= --user
PYTHON ?= python3
NAME ?= ethsnarks
NPM ?= npm
GANACHE ?= $(ROOT_DIR)/node_modules/.bin/ganache-cli
TRUFFLE ?= $(ROOT_DIR)/node_modules/.bin/truffle
COVERAGE = $(PYTHON) -mcoverage run --source=$(NAME) -p
PINOCCHIO_TESTS=$(wildcard test/pinocchio/*.circuit)
#######################################################################
all: build/src/libmiximus.$(DLL_EXT) truffle-compile
clean: coverage-clean python-clean
rm -rf build
#######################################################################
build:
mkdir -p build
bin/miximus_genKeys: build/Makefile
make -C build
build/src/libmiximus.$(DLL_EXT): build/Makefile
make -C build
cmake-debug: build
cd build && cmake -DCMAKE_BUILD_TYPE=Debug ..
cmake-release: build
cd build && cmake -DCMAKE_BUILD_TYPE=Release ..
release: cmake-release all
debug: cmake-debug all
build/Makefile: build CMakeLists.txt
cd build && cmake ..
depends/libsnarks/CMakeLists.txt:
git submodule update --init --recursive
#######################################################################
.PHONY: test
test: pinocchio-test cxx-tests python-test truffle-test
python-test:
$(COVERAGE) -m unittest discover test/
cxx-tests: zksnark_element/miximus.vk.json
./bin/test_field_packing > /dev/null
./bin/test_hashpreimage
./bin/test_longsightl
./bin/test_longsightl_hash_mp
./bin/test_merkle_tree
./bin/test_one_of_n
./bin/test_r1cs_gg_ppzksnark_zok
./bin/test_shamir_poly
./bin/test_sha256_full_gadget
./bin/test_sha256_many > /dev/null
./bin/test_lookup_1bit
./bin/test_lookup_2bit
./bin/test_lookup_3bit
./bin/test_subadd > /dev/null
./bin/test_jubjub
./bin/test_jubjub_add
./bin/test_jubjub_dbl
./bin/test_jubjub_mul
./bin/test_jubjub_mul_fixed
./bin/test_jubjub_isoncurve > /dev/null
time ./bin/hashpreimage_cli genkeys zksnark_element/hpi.pk.raw zksnark_element/hpi.vk.json
ls -lah zksnark_element/hpi.pk.raw
time ./bin/hashpreimage_cli prove zksnark_element/hpi.pk.raw 0x9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a089f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08 zksnark_element/hpi.proof.json
time ./bin/hashpreimage_cli verify zksnark_element/hpi.vk.json zksnark_element/hpi.proof.json
time ./bin/test_load_proofkey zksnark_element/hpi.pk.raw
zksnark_element/miximus.vk.json:
time ./bin/miximus_cli genkeys zksnark_element/miximus.pk.raw zksnark_element/miximus.vk.json
#######################################################################
# Pinocchio Tests
pinocchio-test: $(addsuffix .result, $(basename $(PINOCCHIO_TESTS)))
pinocchio-clean:
rm -f test/pinocchio/*.result
test/pinocchio/%.result: test/pinocchio/%.circuit test/pinocchio/%.test test/pinocchio/%.input ./bin/pinocchio
./bin/pinocchio $< eval $(basename $<).input > $@
diff -ru $(basename $<).test $@ || rm $@
#######################################################################
coverage: coverage-combine coverage-report
coverage-clean:
rm -rf .coverage .coverage.* htmlcov
coverage-combine:
$(PYTHON) -m coverage combine
coverage-report:
$(PYTHON) -m coverage report
coverage-html:
$(PYTHON) -m coverage html
#######################################################################
lint: python-pyflakes python-pylint cxx-lint solidity-lint
python-pyflakes:
$(PYTHON) -mpyflakes $(NAME)
python-pylint:
$(PYTHON) -mpylint $(NAME) || true
python-clean:
find . -name '*.pyc' -exec rm -f '{}' ';'
find . -name '__pycache__' -exec rm -rf '{}' ';'
cxx-lint:
cppcheck -I depends/libsnark/ -I depends/libsnark/depends/libff/ -I depends/libsnark/depends/libfqfft/ -I src/ --enable=all src/ || true
#######################################################################
python-dependencies: requirements requirements-dev
requirements:
$(PYTHON) -m pip install $(PIP_ARGS) -r requirements.txt
requirements-dev:
$(PYTHON) -m pip install $(PIP_ARGS) -r requirements-dev.txt
fedora-dependencies:
dnf install procps-ng-devel gmp-devel boost-devel cmake g++ python3-pip
ubuntu-dependencies:
apt-get install cmake make g++ libgmp-dev libboost-all-dev libprocps-dev python3-pip
mac-dependencies:
brew install pkg-config boost cmake gmp openssl || true
#######################################################################
solidity-lint:
$(NPM) run lint
#######################################################################
nvm-install:
./utils/nvm-install
nvm install --lts
node_modules:
$(NPM) install
$(TRUFFLE): node_modules
$(GANACHE): node_modules
.PHONY: truffle-test
truffle-test: $(TRUFFLE) zksnark_element/miximus.vk.json
$(NPM) run test
truffle-migrate: $(TRUFFLE)
$(TRUFFLE) migrate
truffle-compile: $(TRUFFLE)
$(TRUFFLE) compile
testrpc: $(TRUFFLE)
$(NPM) run testrpc