Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
353 lines (288 loc) · 11.7 KB
/
Copy pathDockerfile
File metadata and controls
353 lines (288 loc) · 11.7 KB
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
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
# ============================================================================
# Stage 1: Build Z3 4.13.0 from source
# ============================================================================
FROM ubuntu:24.04 AS z3_builder
ENV DEBIAN_FRONTEND=noninteractive
WORKDIR /build
RUN apt-get update && apt-get install -y \
git \
cmake \
build-essential \
python3 \
&& rm -rf /var/lib/apt/lists/*
# Build Z3 4.13.0
RUN git clone --depth 1 --branch z3-4.13.0 https://github.com/Z3Prover/z3.git && \
cd z3 && \
mkdir build && \
cd build && \
cmake -DCMAKE_BUILD_TYPE=Release .. && \
make -j$(nproc) && \
ls -la z3
# ============================================================================
# Stage 2: Build CVC5 from source with CoCoA support
# ============================================================================
FROM ubuntu:24.04 AS cvc5_builder
ENV DEBIAN_FRONTEND=noninteractive
WORKDIR /build
RUN apt-get update && apt-get install -y \
git \
cmake \
build-essential \
python3 \
python3-venv \
python3-pip \
libgmp-dev \
flex \
bison \
&& rm -rf /var/lib/apt/lists/*
# Build CVC5 (latest stable) with CoCoA support for finite field problems
# Note: CoCoA is GPL-licensed, so we need --gpl flag
RUN git clone --depth 1 https://github.com/cvc5/cvc5.git && \
cd cvc5 && \
./configure.sh --auto-download --cocoa --gpl --prefix=/usr/local && \
cd build && \
make -j$(nproc) && \
ls -la bin/cvc5
# ============================================================================
# Stage 3: Build circom from source
# ============================================================================
FROM ubuntu:24.04 AS circom_builder
ENV DEBIAN_FRONTEND=noninteractive
ENV CARGO_HOME=/root/.cargo
ENV PATH=/root/.cargo/bin:$PATH
WORKDIR /build
RUN apt-get update && apt-get install -y \
git \
curl \
build-essential \
&& rm -rf /var/lib/apt/lists/*
# Install Rust
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
# Clone and build circom
RUN git clone https://github.com/iden3/circom.git && \
cd circom && \
. "$CARGO_HOME/env" && \
cargo build --release && \
cargo install --path circom && \
ls -la target/release/circom
# ============================================================================
# Stage 4: Build circom_civer from source
# ============================================================================
FROM ubuntu:24.04 AS circom_civer_builder
ENV DEBIAN_FRONTEND=noninteractive
ENV CARGO_HOME=/root/.cargo
ENV PATH=/root/.cargo/bin:$PATH
WORKDIR /build
# Install build dependencies for circom_civer (including libclang for bindgen)
RUN apt-get update && apt-get install -y \
git \
curl \
build-essential \
pkg-config \
libssl-dev \
libz3-dev \
z3 \
libclang-dev \
clang \
llvm-dev \
cmake \
python3 \
python3-setuptools \
python-is-python3 \
&& rm -rf /var/lib/apt/lists/*
# Install Rust
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
# Clone and build circom_civer
RUN git clone https://github.com/costa-group/circom_civer.git && \
cd circom_civer && \
. "$CARGO_HOME/env" && \
cargo build --release --bin civer_circom && \
ls -la target/release/civer_circom
# ============================================================================
# Stage 5: Build circomspect from source
# ============================================================================
FROM ubuntu:24.04 AS circomspect_builder
ENV DEBIAN_FRONTEND=noninteractive
ENV CARGO_HOME=/root/.cargo
ENV PATH=/root/.cargo/bin:$PATH
WORKDIR /build
RUN apt-get update && apt-get install -y \
git \
curl \
build-essential \
pkg-config \
libssl-dev \
&& rm -rf /var/lib/apt/lists/*
# Install Rust
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
# Clone and build circomspect
RUN git clone https://github.com/trailofbits/circomspect.git && \
cd circomspect && \
. "$CARGO_HOME/env" && \
cargo install --path ./cli && \
ls -la /root/.cargo/bin/circomspect
# ============================================================================
# Stage 6: Build zkFuzz from source
# ============================================================================
FROM ubuntu:24.04 AS zkfuzz_builder
ENV DEBIAN_FRONTEND=noninteractive
ENV CARGO_HOME=/root/.cargo
ENV PATH=/root/.cargo/bin:$PATH
WORKDIR /build
RUN apt-get update && apt-get install -y \
git \
curl \
build-essential \
pkg-config \
libssl-dev \
&& rm -rf /var/lib/apt/lists/*
# Install Rust
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
# Clone and build zkFuzz
RUN git clone https://github.com/Koukyosyumei/zkFuzz.git && \
cd zkFuzz && \
. "$CARGO_HOME/env" && \
cargo build --release && \
ls -la target/release/zkfuzz
# ============================================================================
# Stage 7: Main zkhydra image
# ============================================================================
FROM ubuntu:24.04
# Avoid interactive prompts during package installation
ENV DEBIAN_FRONTEND=noninteractive
ENV CARGO_HOME=/root/.cargo
ENV PATH=/root/.cargo/bin:/root/.juliaup/bin:/usr/local/bin:$PATH
# Set working directory
WORKDIR /zkhydra
# Install system dependencies (minimal runtime deps)
RUN apt-get update && apt-get install -y \
git \
curl \
wget \
build-essential \
pkg-config \
libssl-dev \
libgmp-dev \
cmake \
python3-setuptools \
python3-dev \
nodejs \
npm \
racket \
just \
sudo \
vim \
less \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# ============================================================================
# Copy all compiled binaries from builder stages to /usr/local/bin
# ============================================================================
# Copy Z3 4.13.0 from builder stage
COPY --from=z3_builder /build/z3/build/z3 /usr/local/bin/z3
RUN chmod +x /usr/local/bin/z3 && z3 --version
# Copy CVC5 from builder stage (binary and all required libraries)
COPY --from=cvc5_builder /build/cvc5/build/bin/cvc5 /usr/local/bin/cvc5
COPY --from=cvc5_builder /build/cvc5/build/src/libcvc5.so.1 /usr/local/lib/libcvc5.so.1
COPY --from=cvc5_builder /build/cvc5/build/src/parser/libcvc5parser.so.1 /usr/local/lib/libcvc5parser.so.1
COPY --from=cvc5_builder /build/cvc5/build/deps/lib/libpoly.so.0 /usr/local/lib/libpoly.so.0
COPY --from=cvc5_builder /build/cvc5/build/deps/lib/libpolyxx.so.0 /usr/local/lib/libpolyxx.so.0
RUN chmod +x /usr/local/bin/cvc5 && ldconfig && cvc5 --version
# Copy circom from builder stage
COPY --from=circom_builder /root/.cargo/bin/circom /usr/local/bin/circom
RUN chmod +x /usr/local/bin/circom && circom --version && \
echo "circom binary installed to /usr/local/bin"
# Copy circom_civer from builder stage
COPY --from=circom_civer_builder /build/circom_civer/target/release/civer_circom /usr/local/bin/civer_circom
RUN chmod +x /usr/local/bin/civer_circom && \
echo "civer_circom binary installed to /usr/local/bin"
# Copy circomspect from builder stage
COPY --from=circomspect_builder /root/.cargo/bin/circomspect /usr/local/bin/circomspect
RUN chmod +x /usr/local/bin/circomspect && \
echo "circomspect binary installed to /usr/local/bin"
# Copy zkFuzz from builder stage
COPY --from=zkfuzz_builder /build/zkFuzz/target/release/zkfuzz /usr/local/bin/zkfuzz
RUN chmod +x /usr/local/bin/zkfuzz && \
echo "zkfuzz binary installed to /usr/local/bin"
# ============================================================================
# Install additional runtime dependencies
# ============================================================================
# Install Rust toolchain (needed for some runtime dependencies)
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && \
. "$CARGO_HOME/env" && \
rustup default stable
# Install uv for Python package management
RUN curl -LsSf https://astral.sh/uv/install.sh | sh && \
mv /root/.cargo/bin/uv /usr/local/bin/uv || mv /root/.local/bin/uv /usr/local/bin/uv || true
# Install snarkjs globally via npm
RUN npm install -g snarkjs
# Install Julia
RUN curl -fsSL https://install.julialang.org | sh -s -- -y
# ============================================================================
# Copy project files
# ============================================================================
# Copy only necessary files first (excluding .git)
COPY pyproject.toml uv.lock* ./
COPY helpers helpers/
COPY setup setup/
COPY tools tools/
# ============================================================================
# Clone only repositories needed at runtime
# ============================================================================
RUN echo "Cloning runtime dependencies..." && \
# Picus - NEEDED as Racket package
git clone https://github.com/Veridise/Picus.git tools/picus || true && \
# EcneProject - NEEDED as Julia package
git clone https://github.com/franklynwang/EcneProject.git tools/ecneproject || true && \
# ConsCS
git clone https://github.com/jinan789/ConsCS.git tools/conscs || true && \
# Helpers - NEEDED for some tools
git clone https://github.com/cvc5/cvc5.git helpers/cvc5 || true && \
git clone https://github.com/mit-plv/rewriter.git helpers/rewriter || true
# ============================================================================
# Install Racket-based tools (Picus)
# ============================================================================
# Install Racket packages for Picus (ignore Z3 download error - we provide Z3 4.13.0)
RUN raco pkg install --auto rosette csv-reading || true
# Create symlink for Z3 4.13.0 so Rosette can find it (Racket 8.10 path)
RUN mkdir -p /root/.local/share/racket/8.10/pkgs/rosette/bin && \
ln -sf /usr/local/bin/z3 /root/.local/share/racket/8.10/pkgs/rosette/bin/z3 && \
ls -la /root/.local/share/racket/8.10/pkgs/rosette/bin/z3 && \
/root/.local/share/racket/8.10/pkgs/rosette/bin/z3 --version && \
echo "Z3 4.13.0 symlink created for Rosette"
# Install graph dependency for Picus (ignore doc build errors)
RUN raco pkg install --auto graph || true
# Install Picus (ignore doc build errors)
RUN if [ -d "tools/picus" ] && [ -f "tools/picus/info.rkt" ]; then \
cd tools/picus && \
raco pkg install --auto || true; \
fi
# ============================================================================
# Install Julia-based tools (EcneProject)
# ============================================================================
# Setup EcneProject
RUN if [ -d "tools/ecneproject" ] && [ -f "tools/ecneproject/Project.toml" ]; then \
cd tools/ecneproject/Circom_Functions && \
git clone https://github.com/iden3/circomlib || true && \
cd .. && \
julia --project=. -e 'using Pkg; Pkg.update(); Pkg.resolve(); Pkg.instantiate()' && \
just install || true; \
fi
# ============================================================================
# Install Python dependencies
# ============================================================================
COPY zkhydra zkhydra/
RUN uv run python -m zkhydra.main --help
# ============================================================================
# Verify all tool binaries are accessible
# ============================================================================
RUN echo "Verifying tool installations..." && \
which z3 && z3 --version && \
which cvc5 && cvc5 --version && \
which circom && circom --version && \
which circomspect && echo "circomspect: OK" && \
which civer_circom && echo "civer_circom: OK" && \
which zkfuzz && echo "zkfuzz: OK" && \
echo "All tools verified successfully!"
# Set the default command
CMD ["/bin/bash"]