-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dockerfile
149 lines (132 loc) · 7.91 KB
/
Dockerfile
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
###############################################################################
# Build this stage for a build environment, e.g.: #
# #
# docker build --tag mpspdz:buildenv --target buildenv . #
# #
# The above is equivalent to: #
# #
# docker build --tag mpspdz:buildenv \ #
# --target buildenv \ #
# --build-arg arch=native \ #
# --build-arg cxx=clang++-11 \ #
# --build-arg use_ntl=0 \ #
# --build-arg prep_dir="Player-Data" \ #
# --build-arg ssl_dir="Player-Data" #
# --build-arg cryptoplayers=0 #
# #
# To build for an x86-64 architecture, with g++, NTL (for HE), custom #
# prep_dir & ssl_dir, and to use encrypted channels for 4 players: #
# #
# docker build --tag mpspdz:buildenv \ #
# --target buildenv \ #
# --build-arg arch=x86-64 \ #
# --build-arg cxx=g++ \ #
# --build-arg use_ntl=1 \ #
# --build-arg prep_dir="/opt/prepdata" \ #
# --build-arg ssl_dir="/opt/ssl" #
# --build-arg cryptoplayers=4 . #
# #
# To work in a container to build different machines, and compile programs: #
# #
# docker run --rm -it mpspdz:buildenv bash #
# #
# Once in the container, build a machine and compile a program: #
# #
# $ make replicated-ring-party.x #
# $ ./compile.py -R 64 tutorial #
# #
###############################################################################
FROM python:3.10.3-bullseye as buildenv
RUN apt-get update && apt-get install -y --no-install-recommends \
automake \
build-essential \
clang-11 \
git \
libboost-dev \
libboost-thread-dev \
libclang-dev \
libntl-dev \
libsodium-dev \
libssl-dev \
libtool \
m4 \
texinfo \
yasm \
vim \
gdb \
valgrind \
&& rm -rf /var/lib/apt/lists/*
# mpir
COPY --from=initc3/mpir:55fe6a9 /usr/local/mpir/include/* /usr/local/include/
COPY --from=initc3/mpir:55fe6a9 /usr/local/mpir/lib/* /usr/local/lib/
COPY --from=initc3/mpir:55fe6a9 /usr/local/mpir/share/info/* /usr/local/share/info/
ENV MP_SPDZ_HOME /usr/src/MP-SPDZ
WORKDIR $MP_SPDZ_HOME
RUN pip install --upgrade pip ipython
COPY . .
ARG arch=native
ARG cxx=clang++-11
ARG use_ntl=0
ARG prep_dir="Player-Data"
ARG ssl_dir="Player-Data"
RUN echo "ARCH = -march=${arch}" >> CONFIG.mine \
&& echo "CXX = ${cxx}" >> CONFIG.mine \
&& echo "USE_NTL = ${use_ntl}" >> CONFIG.mine \
&& echo "MY_CFLAGS += -I/usr/local/include" >> CONFIG.mine \
&& echo "MY_LDLIBS += -Wl,-rpath -Wl,/usr/local/lib -L/usr/local/lib" \
>> CONFIG.mine \
&& mkdir -p $prep_dir $ssl_dir \
&& echo "PREP_DIR = '-DPREP_DIR=\"${prep_dir}/\"'" >> CONFIG.mine \
&& echo "SSL_DIR = '-DSSL_DIR=\"${ssl_dir}/\"'" >> CONFIG.mine
# ssl keys
ARG cryptoplayers=0
ENV PLAYERS ${cryptoplayers}
RUN ./Scripts/setup-ssl.sh ${cryptoplayers} ${ssl_dir}
###############################################################################
# Use this stage to a build a specific virtual machine. For example: #
# #
# docker build --tag mpspdz:shamir \ #
# --target machine \ #
# --build-arg machine=shamir-party.x \ #
# --build-arg gfp_mod_sz=4 . #
# #
# The above will build shamir-party.x with 256 bit length. #
# #
# If no build arguments are passed (via --build-arg), mascot-party.x is built #
# with the default 128 bit length. #
###############################################################################
FROM buildenv as machine
ARG machine="mascot-party.x"
ARG gfp_mod_sz=2
RUN echo "MOD = -DGFP_MOD_SZ=${gfp_mod_sz}" >> CONFIG.mine
RUN make clean && make ${machine} && cp ${machine} /usr/local/bin/
################################################################################
# This is the default stage. Use it to compile a high-level program. #
# By default, tutorial.mpc is compiled with --field=64 bits. #
# #
# docker build --tag mpspdz:mascot-tutorial \ #
# --build-arg src=tutorial \ #
# --build-arg compile_options="--field=64" . #
# #
# Note that build arguments from previous stages can also be passed. For #
# instance, building replicated-ring-party.x, for 3 crypto players with custom #
# PREP_DIR and SSL_DIR, and compiling tutorial.mpc with --ring=64: #
# #
# docker build --tag mpspdz:replicated-ring \ #
# --build-arg machine=replicated-ring-party.x \ #
# --build-arg prep_dir=/opt/prep \ #
# --build-arg ssl_dir=/opt/ssl \ #
# --build-arg cryptoplayers=3 \ #
# --build-arg compile_options="--ring=64" . #
# #
# Test it: #
# #
# docker run --rm -it mpspdz:replicated-ring ./Scripts/ring.sh tutorial #
################################################################################
FROM machine as program
ARG src="tutorial"
ARG compile_options="--field=64"
RUN ./compile.py ${compile_options} ${src}
RUN mkdir -p Player-Data \
&& echo 1 2 3 4 > Player-Data/Input-P0-0 \
&& echo 1 2 3 4 > Player-Data/Input-P1-0