Skip to content

Commit 4e82817

Browse files
authored
Merge pull request #3 from freedomofpress/hpc
build: add container, scripts, and documentation for verifying and constructing proofs on an HPC cluster
2 parents 6400b36 + 22f68d5 commit 4e82817

7 files changed

Lines changed: 174 additions & 1 deletion

File tree

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,14 @@ well-formed:
1010
interactive:
1111
@$(TAMARIN_RELEASE) +RTS -N$(N_THREADS) -RTS interactive --image-format=SVG --derivcheck-timeout=0 --port=$(PORT) "./"
1212

13+
# Keep make from deleting a freshly constructed proof as an intermediate file.
14+
.SECONDARY:
15+
1316
proof/%.spthy: securedrop.spthy oracle.py parts/*.spthy
1417
mkdir -p proof
1518
@$(TAMARIN_RELEASE) +RTS -N$(N_THREADS) -RTS --derivcheck-timeout=0 --prove="$**" --output="$@" "securedrop.spthy"
1619

17-
proof/%.log: proof/*.spthy
20+
proof/%.log: proof/%.spthy
1821
@$(TAMARIN_RELEASE) +RTS -N$(N_THREADS) -RTS --derivcheck-timeout=0 "proof/$*.spthy" > "proof/$*.log" 2>&1
1922

2023
debug/%.spthy: securedrop.spthy oracle.py parts/*.spthy

README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ Add `tamarin-prover` to your `PATH`, or provide its path to `make` using the `TA
1616

1717
If you want to explore the model in interactive mode or construct proofs, you must also install [python 3](https://www.python.org/downloads/).
1818

19+
A containerized environment is also available, for example via Docker:
20+
21+
```bash
22+
docker build --tag tamarin hpc
23+
docker run --rm --volume "$PWD:/workspace" tamarin --version
24+
```
25+
1926
## Repository Structure
2027

2128
| File | Description |
@@ -56,3 +63,29 @@ Tamarin traverses proofs using depth-first search and thus typically only needs
5663
| B | `proof/Easy_.spthy` | 03:37:03 | 01:46:27 | 04:39:35 | 30 GB |
5764
| B | `proof/Executability.spthy` | 01:55:26 | 00:37:20 | 01:27:26 | 30 GB |
5865
| B | `proof/Secrecy_.spthy` | 01:49:26 | 00:28:22 | 01:06:19 | 30 GB |
66+
67+
### Running on HPC
68+
69+
If you have access to an HPC cluster, you can construct and verify proofs inside
70+
an Apptainer container. For example, from the root of this repository, via
71+
Slurm:
72+
73+
1. Build the container:
74+
```bash
75+
apptainer build --fakeroot tamarin.sif hpc/tamarin.def
76+
```
77+
78+
2. Run the well-formedness checks:
79+
```bash
80+
salloc --nodes 1 --ntasks 1 --mem=10G --time=1:00:00 apptainer exec tamarin.sif bash -c 'ulimit -Sn $(ulimit -Hn); make well-formed'
81+
```
82+
83+
3. Verify a proof:
84+
```bash
85+
salloc --nodes=1 --ntasks=1 --cpus-per-task=10 --mem=192G --time=12:00:00 apptainer exec tamarin.sif bash -c 'ulimit -Sn $(ulimit -Hn); make proof/Auto_.log'
86+
```
87+
88+
You can also run batch jobs to:
89+
90+
- Verify all proofs: `sbatch hpc/verify.sbatch`
91+
- Reconstruct all proofs: `sbatch hpc/prove.sbatch`

hpc/Dockerfile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
FROM --platform=linux/amd64 debian:trixie-slim
2+
ARG MAUDE_VERSION
3+
ARG TAMARIN_VERSION
4+
5+
COPY setup.sh /tmp/setup.sh
6+
RUN sh /tmp/setup.sh && rm -f /tmp/setup.sh
7+
8+
ENV MAUDE_LIB=/opt/maude \
9+
LC_ALL=C.UTF-8 \
10+
LANG=C.UTF-8
11+
12+
RUN tamarin-prover test
13+
14+
WORKDIR /workspace
15+
ENTRYPOINT ["tamarin-prover"]
16+
CMD ["--help"]

hpc/prove.sbatch

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
#SBATCH --job-name=prove-securedrop-protocol-models
3+
#SBATCH --array=0-4
4+
#SBATCH --nodes=1
5+
#SBATCH --ntasks=1
6+
#SBATCH --cpus-per-task=10
7+
#SBATCH --mem=512G
8+
#SBATCH --time=24:00:00
9+
#SBATCH --requeue
10+
#SBATCH --output=slurm-%x-%A_%a.out
11+
12+
set -euo pipefail
13+
14+
# Path to the Apptainer image (override with: sbatch --export=SIF=$HOME/tamarin.sif ...)
15+
SIF="${SIF:-tamarin.sif}"
16+
17+
PREFIXES=(Agreement_ Auto_ Easy_ Executability Secrecy_)
18+
PREFIX="${PREFIXES[$SLURM_ARRAY_TASK_ID]}"
19+
20+
cd "$SLURM_SUBMIT_DIR"
21+
22+
echo "Constructing proof/${PREFIX}.spthy on $(hostname) with ${SLURM_CPUS_PER_TASK} threads"
23+
24+
apptainer exec "$SIF" bash -c \
25+
"ulimit -Sn \$(ulimit -Hn); make N_THREADS=${SLURM_CPUS_PER_TASK} \
26+
-B \
27+
proof/${PREFIX}.spthy"

hpc/setup.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/sh
2+
set -eux
3+
4+
MAUDE_VERSION="${MAUDE_VERSION:-3.5}"
5+
TAMARIN_VERSION="${TAMARIN_VERSION:-1.12.0}"
6+
7+
export DEBIAN_FRONTEND=noninteractive
8+
9+
# Runtime dependencies:
10+
apt-get update
11+
apt-get install --no-install-recommends --yes \
12+
ca-certificates \
13+
curl \
14+
graphviz \
15+
make \
16+
libffi8 \
17+
libgmp10 \
18+
libstdc++6 \
19+
libtinfo6 \
20+
python3 \
21+
unzip \
22+
zlib1g
23+
rm -rf /var/lib/apt/lists/*
24+
25+
# Maude:
26+
curl -fsSL -o /tmp/maude.zip \
27+
"https://github.com/maude-lang/Maude/releases/download/Maude${MAUDE_VERSION}/Maude-${MAUDE_VERSION}-linux-x86_64.zip"
28+
mkdir -p /opt/maude
29+
unzip -j -o /tmp/maude.zip -d /opt/maude
30+
rm -f /tmp/maude.zip
31+
chmod 0755 /opt/maude/maude
32+
ln -sf /opt/maude/maude /usr/local/bin/maude
33+
34+
# Tamarin:
35+
curl -fsSL -o /tmp/tamarin.tar.gz \
36+
"https://github.com/tamarin-prover/tamarin-prover/releases/download/${TAMARIN_VERSION}/tamarin-prover-${TAMARIN_VERSION}-linux64-ubuntu.tar.gz"
37+
mkdir -p /tmp/tamarin
38+
tar -xzf /tmp/tamarin.tar.gz -C /tmp/tamarin
39+
install -m 0755 \
40+
"$(find /tmp/tamarin -type f -name tamarin-prover | head -n1)" \
41+
/usr/local/bin/tamarin-prover
42+
rm -rf /tmp/tamarin /tmp/tamarin.tar.gz

hpc/tamarin.def

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Bootstrap: docker
2+
From: debian:trixie-slim
3+
4+
%files
5+
hpc/setup.sh /tmp/setup.sh
6+
7+
%post
8+
sh /tmp/setup.sh
9+
rm -f /tmp/setup.sh
10+
11+
%environment
12+
export MAUDE_LIB=/opt/maude
13+
export LC_ALL=C.UTF-8
14+
export LANG=C.UTF-8
15+
16+
%test
17+
tamarin-prover test
18+
19+
%runscript
20+
exec tamarin-prover "$@"
21+
22+
%help
23+
Run Tamarin directly: apptainer run tamarin.sif --help
24+
25+
Open a shell: apptainer shell tamarin.sif

hpc/verify.sbatch

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
#SBATCH --job-name=verify-securedrop-protocol-models
3+
#SBATCH --array=0-4
4+
#SBATCH --nodes=1
5+
#SBATCH --ntasks=1
6+
#SBATCH --cpus-per-task=10
7+
#SBATCH --mem=192G
8+
#SBATCH --time=12:00:00
9+
#SBATCH --requeue
10+
#SBATCH --output=slurm-%x-%A_%a.out
11+
12+
set -euo pipefail
13+
14+
# Path to the Apptainer image (override with: sbatch --export=SIF=$HOME/tamarin.sif ...)
15+
SIF="${SIF:-tamarin.sif}"
16+
17+
PREFIXES=(Agreement_ Auto_ Easy_ Executability Secrecy_)
18+
PREFIX="${PREFIXES[$SLURM_ARRAY_TASK_ID]}"
19+
20+
cd "$SLURM_SUBMIT_DIR"
21+
22+
echo "Verifying proof/${PREFIX}.log on $(hostname) with ${SLURM_CPUS_PER_TASK} threads"
23+
24+
apptainer exec "$SIF" bash -c \
25+
"ulimit -Sn \$(ulimit -Hn); make N_THREADS=${SLURM_CPUS_PER_TASK} \
26+
-W proof/${PREFIX}.spthy \
27+
proof/${PREFIX}.log"

0 commit comments

Comments
 (0)