forked from cryptobiu/libscapi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
279 lines (244 loc) · 10.5 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
export builddir=$(abspath ./build)
export prefix=$(abspath ./install)
CXX=g++
uname_os := $(shell uname)
ARCH := $(shell getconf LONG_BIT)
SHARED_LIB_EXT:=.so
INCLUDE_ARCHIVES_START = -Wl,-whole-archive # linking options, we prefer our generated shared object will be self-contained.
INCLUDE_ARCHIVES_END = -Wl,-no-whole-archive
SHARED_LIB_OPT:=-shared
export uname_os
export ARCH
export SHARED_LIB_EXT
export INCLUDE_ARCHIVES_START
export INCLUDE_ARCHIVES_END
export SHARED_LIB_OPT
export exec_prefix=$(prefix)
export includedir=$(prefix)/include
export bindir=$(exec_prefix)/bin
export libdir=$(prefix)/lib
SLib = libscapi.a
CPP_FILES := $(wildcard src/*/*.cpp)
C_FILES := $(wildcard src/*/*.c)
OBJ_FILES := $(patsubst src/%.cpp,obj/%.o,$(CPP_FILES))
OBJ_FILES += $(patsubst src/%.c,obj/%.o,$(C_FILES))
OUT_DIR = obj obj/mid_layer obj/circuits obj/comm obj/infra obj/interactive_mid_protocols obj/primitives obj/circuits_c obj/cryptoInfra obj/commClient
ifeq ($(uname_os), Linux)
INC = -Iinstall/include -Iinstall/include/OTExtensionBristol -Iinstall/include/libOTe -Iinstall/include/libOTe/cryptoTools -I/usr/local/opt/openssl/include/
LIBRARIES_DIR = -Linstall/lib /usr/local/opt/openssl/lib
endif
ifeq ($(uname_os), Darwin)
INC = -Iinstall/include -Iinstall/include/OTExtensionBristol -Iinstall/include/libOTe -Iinstall/include/libOTe/cryptoTools -I/usr/local/opt/openssl/include/
LIBRARIES_DIR = -Linstall/lib /usr/local/opt/openssl/lib
endif
GCC_STANDARD = c++14
CPP_OPTIONS := -g -std=$(GCC_STANDARD) $(INC) -maes -mpclmul -mbmi2 -Wall -Wno-uninitialized -Wno-unused-but-set-variable -Wno-unused-function -Wno-unused-variable -Wno-unused-result -Wno-sign-compare -Wno-parentheses -O3
$(COMPILE.cpp) = g++ -c $(CPP_OPTIONS) -o $@ $<
LD_FLAGS =
SUMO = no
all: libs libscapi tests
echo $(WITH_EMP)
ifeq ($(GCC_STANDARD), c++11)
ifeq ($(uname_os), Linux)
libs: compile-openssl compile-boost compile-ntl compile-blake compile-emp-tool compile-emp-ot compile-emp-m2pc compile-otextension-bristol
endif # Linux c++11
ifeq ($(uname_os), Darwin)
libs: compile-openssl compile-boost compile-ntl compile-blake compile-emp-tool compile-emp-ot compile-emp-m2pc
endif # Darwin c++11
endif # c++11
ifeq ($(GCC_STANDARD), c++14)
ifeq ($(uname_os), Linux)
libs: compile-openssl compile-boost compile-libote compile-ntl compile-blake compile-emp-tool compile-emp-ot compile-emp-m2pc compile-otextension-bristol
endif # Linux c++14
ifeq ($(uname_os), Darwin)
libs: compile-openssl compile-boost compile-libote compile-ntl compile-blake compile-emp-tool compile-emp-ot compile-emp-m2pc
endif # Darwin c++14
endif
libscapi: directories $(SLib)
directories: $(OUT_DIR)
$(OUT_DIR):
mkdir -p $(OUT_DIR)
$(SLib): $(OBJ_FILES)
ar ru $@ $^
ranlib $@
obj/circuits/%.o: src/circuits/%.cpp
g++ -c $(CPP_OPTIONS) -o $@ $<
obj/circuits_c/%.o: src/circuits_c/%.c
gcc -fPIC -mavx -maes -mpclmul -DRDTSC -DTEST=AES128 -O3 -c -o $@ $<
obj/comm/%.o: src/comm/%.cpp
g++ -c $(CPP_OPTIONS) -o $@ $<
obj/commClient/%.o: src/commClient/%.cpp
g++ -c $(CPP_OPTIONS) -o $@ $<
obj/infra/%.o: src/infra/%.cpp
g++ -c $(CPP_OPTIONS) -o $@ $<
obj/interactive_mid_protocols/%.o: src/interactive_mid_protocols/%.cpp
g++ -c $(CPP_OPTIONS) -o $@ $<
obj/primitives/%.o: src/primitives/%.cpp
g++ -c $(CPP_OPTIONS) -o $@ $<
obj/mid_layer/%.o: src/mid_layer/%.cpp
g++ -c $(CPP_OPTIONS) -o $@ $<
obj/cryptoInfra/%.o: src/cryptoInfra/%.cpp
g++ -c $(CPP_OPTIONS) -o $@ $<
tests: compile-tests
cd ./test; ./tests.exe
.PHONY: compile-tests
compile-tests:
@cd ./test; \
g++ -std=c++14 -maes -mavx -I/usr/include/openssl -I../install/include -o tests.exe tests.cpp interactiveMidProtocolsTests.cpp ../libscapi.a -lpthread -L../install/lib ../install/lib/libboost_system.a ../install/lib/libboost_thread.a -l:libssl.a -lntl -lgmp -l:libcrypto.a -ldl -lz;
@cd ..
prepare-emp:compile-openssl
ifeq ($(SUMO),yes)
@mkdir -p $(builddir)/EMP
@cp -r lib/EMP/. $(builddir)/EMP
@cmake -DALIGN=16 -DARCH=X64 -DARITH=curve2251-sse -DCHECK=off -DFB_POLYN=251 -DFB_METHD="INTEG;INTEG;QUICK;QUICK;QUICK;QUICK;LOWER;SLIDE;QUICK" -DFB_PRECO=on -DFB_SQRTF=off -DEB_METHD="PROJC;LODAH;COMBD;INTER" -DEC_METHD="CHAR2" -DCOMP="-O3 -funroll-loops -fomit-frame-pointer -march=native -msse4.2 -mpclmul -Wno-unused-function -Wno-unused-variable -Wno-return-type -Wno-discarded-qualifiers" -DTIMER=CYCLE -DWITH="MD;DV;BN;FB;EB;EC" -DWORD=64 $(builddir)/EMP/relic/CMakeLists.txt
@cd $(builddir)/EMP/relic && $(MAKE)
@cd $(builddir)/EMP/relic && $(MAKE) install
@touch prepare-emp
endif
compile-emp-tool:prepare-emp
ifeq ($(SUMO),yes)
@cd $(builddir)/EMP/emp-tool
@cmake -DOPENSSL_ROOT_DIR=$(includedir) -DOPENSSL_INCLUDE_DIR=$(includedir) \
-DOPENSSL_LIBRARIES=$(libdir) -DOPENSSL_CRYPTO_LIBRARY=$(libdir)/libcrypto.a \
-DOPENSSL_SSL_LIBRARY=$(libdir)/libssl.a \
-D CMAKE_CXX_FLAGS="-Wno-unused-function -Wno-unused-variable -Wno-return-type" \
$(builddir)/EMP/emp-tool/CMakeLists.txt
@cd $(builddir)/EMP/emp-tool/ && $(MAKE)
@cd $(builddir)/EMP/emp-tool/ && $(MAKE) install
@touch compile-emp-tool
endif
compile-emp-ot:compile-emp-tool
ifeq ($(SUMO),yes)
@cd $(builddir)/EMP/emp-ot
@cmake -DOPENSSL_ROOT_DIR=$(includedir) -DOPENSSL_INCLUDE_DIR=$(includedir) \
-DOPENSSL_LIBRARIES=$(libdir) -DOPENSSL_CRYPTO_LIBRARY=$(libdir)/libcrypto.a \
-DOPENSSL_SSL_LIBRARY=$(libdir)/libssl.a \
-D CMAKE_CXX_FLAGS="-Wno-unused-function -Wno-unused-variable -Wno-return-type" \
$(builddir)/EMP/emp-ot/CMakeLists.txt
@cd $(builddir)/EMP/emp-ot/ && $(MAKE)
@cd $(builddir)/EMP/emp-ot/ && $(MAKE) install
@touch compile-emp-ot
endif
compile-emp-m2pc:compile-emp-ot
ifeq ($(SUMO),yes)
@cd $(builddir)/EMP/emp-m2pc
@cmake -DOPENSSL_ROOT_DIR=$(includedir) -DOPENSSL_INCLUDE_DIR=$(includedir) \
-DOPENSSL_LIBRARIES=$(libdir) -DOPENSSL_CRYPTO_LIBRARY=$(libdir)/libcrypto.a \
-DOPENSSL_SSL_LIBRARY=$(libdir)/libssl.a \
-D CMAKE_CXX_FLAGS="-Wno-unused-function -Wno-unused-variable -Wno-return-type" \
$(builddir)/EMP/emp-m2pc/CMakeLists.txt
@cd $(builddir)/EMP/emp-m2pc/ && $(MAKE)
@touch compile-emp-m2pc
endif
compile-blake:
@echo "Compiling the BLAKE2 library"
@mkdir -p $(builddir)/BLAKE2/
@cp -r lib/BLAKE2/sse/. $(builddir)/BLAKE2
@$(MAKE) -C $(builddir)/BLAKE2
@$(MAKE) -C $(builddir)/BLAKE2 BUILDDIR=$(builddir) install
@touch compile-blake
compile-openssl:
@mkdir -p $(PWD)/install/lib
@mkdir -p $(PWD)/install/include
@mkdir -p $(builddir)/
echo "Compiling the openssl library"
@cp -r lib/openssl/ $(builddir)/openssl
export CFLAGS="-fPIC"
ifeq ($(uname_os), Linux)
cd $(builddir)/openssl/; ./config --prefix=$(builddir)/openssl/tmptrgt enable-ec_nistp_64_gcc_128 -no-shared
endif
ifeq ($(uname_os), Darwin)
cd $(builddir)/openssl/; ./Configure darwin64-x86_64-cc --prefix=$(builddir)/openssl/tmptrgt enable-ec_nistp_64_gcc_128 -no-shared
endif
cd $(builddir)/openssl/; make
cd $(builddir)/openssl/; make install
@cp $(builddir)/openssl/tmptrgt/lib/*.a $(PWD)/install/lib/
@cp -r $(builddir)/openssl/tmptrgt/include/openssl/ $(PWD)/install/include/
@touch compile-openssl
compile-boost:
@mkdir -p $(PWD)/install/lib
@mkdir -p $(PWD)/install/include
@mkdir -p $(builddir)/
echo "Compiling the boost library"
@cp -r lib/boost_1_64_0/ $(builddir)/boost_1_64_0
@cd $(builddir)/boost_1_64_0/; bash -c "BOOST_BUILD_PATH='./' ./bootstrap.sh --with-libraries=thread,system,log,serialization \
&& ./b2 -j4"; # compile boost faster with threads
@cp $(builddir)/boost_1_64_0/stage/lib/*.a $(PWD)/install/lib/
ifeq ($(uname_os), Linux)
@cp -r $(builddir)/boost_1_64_0/boost $(PWD)/install/include/
endif
ifeq ($(uname_os), Darwin)
@cp -R $(builddir)/boost_1_64_0/boost $(PWD)/install/include/
endif
@touch compile-boost
# Support only in c++14
compile-libote:compile-boost
@echo "Compiling libOTe library..."
@cp -r lib/libOTe $(builddir)/libOTe
@cmake $(builddir)/libOTe/CMakeLists.txt -DCMAKE_BUILD_TYPE=Release
@$(MAKE) -C $(builddir)/libOTe/
@cp $(builddir)/libOTe/lib/*.a $(PWD)/install/lib/
@mv $(PWD)/install/lib/liblibOTe.a $(PWD)/install/lib/libOTe.a
@mkdir -p $(PWD)/install/include/libOTe
@cd $(builddir)/libOTe/ && find . -name "*.h" -type f |xargs -I {} cp --parents {} $(PWD)/install/include/libOTe
ifeq ($(uname_os), Linux)
@cp -r $(builddir)/libOTe/cryptoTools/cryptoTools/gsl $(PWD)/install/include/libOTe/cryptoTools/cryptoTools
endif
ifeq ($(uname_os), Darwin)
@cp -R $(builddir)/libOTe/cryptoTools/cryptoTools/gsl $(PWD)/install/include/libOTe/cryptoTools/cryptoTools
endif
@cp $(builddir)/libOTe/cryptoTools/thirdparty/miracl/source/libmiracl.a $(PWD)/install/lib
@touch compile-libote
compile-ntl:
echo "Compiling the NTL library..."
mkdir -p $(builddir)/NTL
cp -r lib/NTL/unix/. $(builddir)/NTL
chmod 777 $(builddir)/NTL/src/configure
cd $(builddir)/NTL/src/ && ./configure CXX=$(CXX) WIZARD=off
$(MAKE) -C $(builddir)/NTL/src/
$(MAKE) -C $(builddir)/NTL/src/ PREFIX=$(prefix) install
touch compile-ntl
compile-otextension-bristol:
@echo "Compiling the OtExtension malicious Bristol library..."
@cp -r lib/OTExtensionBristol $(builddir)/OTExtensionBristol
@$(MAKE) -C $(builddir)/OTExtensionBristol CXX=$(CXX)
@$(MAKE) -C $(builddir)/OTExtensionBristol CXX=$(CXX) install
@touch compile-otextension-bristol
clean-otextension-bristol:
@echo "Cleaning the otextension malicious bristol build dir..."
@rm -rf $(builddir)/OTExtensionBristol
@rm -f compile-otextension-bristol
clean-ntl:
@echo "Cleaning the ntl build dir..."
@rm -rf $(builddir)/NTL
@rm -f compile-ntl
clean-blake:
@echo "Cleaning blake library"
@rm -rf $(builddir)/BLAKE2
@rm -f compile-blake
clean-emp:
@echo "Cleaning EMP library"
@rm -rf $(builddir)/EMP
@rm -f prepare-emp compile-emp-tool compile-emp-ot compile-emp-m2pc
clean-cpp:
@echo "cleaning .obj files"
@rm -rf $(OUT_DIR)
@echo "cleaning lib"
@rm -f $(SLib)
clean-install:
@rm -rf install
clean-tests:
@rm -f test/tests.exe
clean-boost:
@echo "Cleaning boost library"
@rm -rf $(builddir)/boost_1_64_0
@rm -f compile-boost
clean-openssl:
@echo "Cleaning openssl library"
@rm -rf $(builddir)/openssl
@rm -f compile-openssl
clean-libote:
@echo "Cleaning libOTe library"
@rm -rf $(builddir)/libOTe/
@rm -f compile-libote
clean: clean-libote clean-openssl clean-boost clean-emp clean-otextension-bristol clean-ntl clean-install clean-tests clean-cpp