release: reproducible builds, and sign every asset
"The source is public" is not a check anyone can run, and against a Tor + Monero tool the surviving objection is that the released binary might not be that source. This makes the build checkable instead of trusted. - scripts/reproducible-build.sh is the single definition of a release build: digest-pinned builder image, fixed in-container paths, SOURCE_DATE_EPOCH from the released commit, --locked, its own apt build deps, and RUSTFLAGS replaced rather than extended. The fixed paths are load-bearing: rustc's --remap-path-prefix cannot reach absolute paths compiled in by a C toolchain, and this graph always has one (rusqlite compiles OpenSSL from vendored sources; the default cuprate-daemon adds RandomX and cmake). It also records toolchain versions in build-info, because the apt build deps are not digest-pinned the way the image is. - release.yml pins the image by digest, resolves SOURCE_DATE_EPOCH from the tag's commit, runs that recipe, and uploads build-info-<target>.txt beside the binary. The cargo target volume is created per run and removed, so the published artifact cannot come out of a cache that a verifier does not have. - scripts/verify-reproducible.sh rebuilds a tag in the same pinned image and compares bytes against the release asset. Two fresh builds of the same tree in that image produce identical sha256. - scripts/sign-release.sh signs with minisign and verifies its own signature against the committed public key. The publish job signs BEFORE publishing and fails closed without MINISIGN_SECRET_KEY, so nothing unsigned reaches the release page: an unsigned release is indistinguishable from a signed one to anyone who is not checking. Checked: signature accepted by an independent minisign -V, a tampered file rejected, a missing key refused, a missing public key refused. - build-release-local.sh runs the same container and the same recipe. A host cargo build would publish a hash nobody could reproduce, which is worse than having no fallback at all. - docs/VERIFY.md is the verifier-facing walkthrough: the dependency graph and where its HTTP actually comes from, the wallet's real seed-read exposure, the rebuild check, the signature check, and an explicit list of what none of it proves. - Cargo.toml repository: point at the Forgejo instance that hosts this and builds its releases. Needs a MINISIGN_SECRET_KEY secret before the next release; without it the publish job stops by design. docs/RELEASING.md has the keygen procedure.
This commit is contained in:
parent
1031092192
commit
601f640f78
11 changed files with 962 additions and 76 deletions
|
|
@ -1,10 +1,14 @@
|
|||
#!/usr/bin/env bash
|
||||
# Offline fallback: build the x86_64 release asset on this host and publish it
|
||||
# to the Forgejo release for <tag>. CI (.forgejo/workflows/release.yml) now
|
||||
# builds both aarch64 (Pi runner) and x86_64 (amd64 runner). Use this script
|
||||
# when you cannot wait for CI or the amd64 runner is down.
|
||||
# Offline fallback: build and publish the x86_64 release asset from this host
|
||||
# when CI (.forgejo/workflows/release.yml) cannot be used.
|
||||
#
|
||||
# Usage: FORGEJO_TOKEN=... scripts/build-release-local.sh v0.1.0
|
||||
# Usage: MINISIGN_SECRET_KEY=... FORGEJO_TOKEN=... scripts/build-release-local.sh v0.14.0
|
||||
#
|
||||
# It runs the SAME recipe CI runs, inside the same digest-pinned builder image,
|
||||
# so the asset it publishes is one a verifier can reproduce. A plain host
|
||||
# `cargo build` would not be: different rustc, different build paths, different
|
||||
# bytes — and the published hash would then match nothing anyone could rebuild,
|
||||
# which is worse than having no fallback at all.
|
||||
#
|
||||
# Does not create or push the tag: the release workflow owns tagging. Idempotent
|
||||
# (same-named assets are replaced). Never moves an existing tag.
|
||||
|
|
@ -15,22 +19,62 @@ target=x86_64-unknown-linux-gnu
|
|||
root="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
cd "$root"
|
||||
|
||||
# Must equal RUST_IMAGE in .forgejo/workflows/release.yml and BUILDER_IMAGE in
|
||||
# scripts/verify-reproducible.sh. Three copies, one digest — see docs/VERIFY.md.
|
||||
BUILDER_IMAGE="rust@sha256:93ce27a88655056a51dbdd8f5f2d7ddc071c7b0070fb288a37b5a285fc83971e"
|
||||
|
||||
command -v docker >/dev/null 2>&1 || {
|
||||
echo "build-release-local: docker is required (the build runs in the pinned image)" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
expected="$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -1)"
|
||||
if [ "$tag" != "v$expected" ]; then
|
||||
echo "warn: tag $tag does not match Cargo.toml version $expected (--version will report $expected)"
|
||||
fi
|
||||
|
||||
echo "==> cargo build --release --locked"
|
||||
cargo build --release --locked
|
||||
sha="$(git rev-parse --verify "$tag^{commit}" 2>/dev/null)" || {
|
||||
echo "build-release-local: tag $tag not found — run: git fetch --tags" >&2
|
||||
exit 1
|
||||
}
|
||||
sde="$(git log -1 --format=%ct "$sha")"
|
||||
echo "==> $tag at $sha, SOURCE_DATE_EPOCH=$sde"
|
||||
|
||||
work="$(mktemp -d)"
|
||||
trap 'rm -rf "$work"' EXIT
|
||||
mkdir -p "$work/src" "$work/out" "$work/target"
|
||||
git archive "$sha" | tar -x -C "$work/src"
|
||||
|
||||
docker volume create onionwire-local-registry >/dev/null
|
||||
docker run --rm \
|
||||
-v "$work/src:/src:ro" \
|
||||
-v onionwire-local-registry:/usr/local/cargo/registry \
|
||||
-v "$work/target:/target" \
|
||||
-v "$work/out:/out" \
|
||||
-e SOURCE_DATE_EPOCH="$sde" \
|
||||
-e BUILDER_IMAGE="$BUILDER_IMAGE" \
|
||||
-e TARGET_TRIPLE="$target" \
|
||||
-e GIT_SHA="$sha" \
|
||||
-w /src \
|
||||
"$BUILDER_IMAGE" \
|
||||
bash scripts/reproducible-build.sh
|
||||
|
||||
mkdir -p dist
|
||||
asset="onionwire-$target"
|
||||
cp "target/release/onionwire" "dist/$asset"
|
||||
strip "dist/$asset"
|
||||
(cd dist && sha256sum "$asset" > "$asset.sha256" && sha256sum -c "$asset.sha256")
|
||||
file "dist/$asset"
|
||||
"dist/$asset" --version
|
||||
cp "$work/out/onionwire-$target" \
|
||||
"$work/out/onionwire-$target.sha256" \
|
||||
"$work/out/build-info-$target.txt" \
|
||||
dist/
|
||||
file "dist/onionwire-$target"
|
||||
"dist/onionwire-$target" --version
|
||||
|
||||
echo "==> signing (needs minisign on PATH and the committed public key)"
|
||||
RELEASE_TAG="$tag" scripts/sign-release.sh \
|
||||
"dist/onionwire-$target" "dist/onionwire-$target.sha256"
|
||||
|
||||
echo "==> publishing to the release for $tag"
|
||||
scripts/publish-release.sh "$tag" "OnionWire $tag" scripts/release-body.md \
|
||||
"dist/$asset" "dist/$asset.sha256"
|
||||
"dist/onionwire-$target" \
|
||||
"dist/onionwire-$target.sha256" \
|
||||
"dist/onionwire-$target.minisig" \
|
||||
"dist/onionwire-$target.sha256.minisig" \
|
||||
"dist/build-info-$target.txt"
|
||||
|
|
@ -6,12 +6,14 @@ Prebuilt Linux binaries. No `tor` package required — Arti runs in-process.
|
|||
# aarch64 (Raspberry Pi, ARM servers)
|
||||
curl -fL -O https://forgejo.siriusdevops.com/sirius/onionwire/releases/download/@TAG@/onionwire-aarch64-unknown-linux-gnu
|
||||
curl -fL -O https://forgejo.siriusdevops.com/sirius/onionwire/releases/download/@TAG@/onionwire-aarch64-unknown-linux-gnu.sha256
|
||||
curl -fL -O https://forgejo.siriusdevops.com/sirius/onionwire/releases/download/@TAG@/onionwire-aarch64-unknown-linux-gnu.minisig
|
||||
sha256sum -c onionwire-aarch64-unknown-linux-gnu.sha256
|
||||
chmod +x onionwire-aarch64-unknown-linux-gnu
|
||||
|
||||
# x86_64 (most PCs / VMs)
|
||||
curl -fL -O https://forgejo.siriusdevops.com/sirius/onionwire/releases/download/@TAG@/onionwire-x86_64-unknown-linux-gnu
|
||||
curl -fL -O https://forgejo.siriusdevops.com/sirius/onionwire/releases/download/@TAG@/onionwire-x86_64-unknown-linux-gnu.sha256
|
||||
curl -fL -O https://forgejo.siriusdevops.com/sirius/onionwire/releases/download/@TAG@/onionwire-x86_64-unknown-linux-gnu.minisig
|
||||
sha256sum -c onionwire-x86_64-unknown-linux-gnu.sha256
|
||||
chmod +x onionwire-x86_64-unknown-linux-gnu
|
||||
|
||||
|
|
@ -22,4 +24,29 @@ Keep the asset filenames so `sha256sum -c` matches. The TLS stack is rustls and
|
|||
OpenSSL (for SQLCipher) is compiled in from vendored sources, so the binaries
|
||||
have no dynamic `libssl` dependency.
|
||||
|
||||
Building from source is covered in the README install guide.
|
||||
## Verify before you run it
|
||||
|
||||
A `.sha256` only proves your download matches this page. Both assets are also
|
||||
signed with minisign, and every binary is reproducible from the tag.
|
||||
|
||||
```bash
|
||||
# 1. The signature. Take the key from the repo, not from this page:
|
||||
# a signature checked against a key fetched from the same place it is
|
||||
# supposed to vouch for proves nothing.
|
||||
curl -fL -O https://forgejo.siriusdevops.com/sirius/onionwire/raw/branch/main/scripts/onionwire-signing.pub
|
||||
minisign -Vm onionwire-x86_64-unknown-linux-gnu -p onionwire-signing.pub
|
||||
|
||||
# 2. The bytes: rebuild this tag and compare, byte for byte.
|
||||
git clone https://forgejo.siriusdevops.com/sirius/onionwire
|
||||
cd onionwire && git fetch --tags
|
||||
scripts/verify-reproducible.sh @TAG@
|
||||
```
|
||||
|
||||
`build-info-<target>.txt`, attached to this release, records the commit, the
|
||||
source date epoch, the toolchain and the builder image digest behind each hash —
|
||||
so a mismatch can be diagnosed instead of merely reported.
|
||||
|
||||
Full walkthrough, including what these checks do and do not prove:
|
||||
[`docs/VERIFY.md`](https://forgejo.siriusdevops.com/sirius/onionwire/src/branch/main/docs/VERIFY.md).
|
||||
|
||||
Building from source is covered in the README install guide.
|
||||
144
scripts/reproducible-build.sh
Executable file
144
scripts/reproducible-build.sh
Executable file
|
|
@ -0,0 +1,144 @@
|
|||
#!/usr/bin/env bash
|
||||
# Canonical OnionWire release build. RUNS INSIDE THE PINNED BUILDER IMAGE
|
||||
# (BUILDER_IMAGE in .forgejo/workflows/release.yml — pinned by digest, not by a
|
||||
# floating tag, and recorded in the build-info asset).
|
||||
#
|
||||
# This is the only supported way to produce a release binary. The bytes it
|
||||
# emits are exactly what `scripts/verify-reproducible.sh` rebuilds and compares,
|
||||
# so anything that can move those bytes is pinned here rather than left to the
|
||||
# environment:
|
||||
#
|
||||
# * the builder image, by digest — `rust:1.98-bookworm` floats, and rustc
|
||||
# patches change codegen;
|
||||
# * every absolute build path (source, cargo target dir, cargo registry).
|
||||
# rustc's `--remap-path-prefix` covers paths that reach rustc's own
|
||||
# strings and debug info, but NOT absolute paths compiled in by a C
|
||||
# toolchain — and this crate always has one: rusqlite's
|
||||
# `bundled-sqlcipher-vendored-openssl` feature compiles OpenSSL from
|
||||
# source, and OpenSSL bakes its build and config paths into the artifact.
|
||||
# The build therefore happens at fixed paths inside the container;
|
||||
# * SOURCE_DATE_EPOCH, from the released commit's committer date, so no
|
||||
# build clock reaches the output (OpenSSL and any date-dependent crate
|
||||
# read it);
|
||||
# * the dependency graph, via `--locked`;
|
||||
# * the strip step and its exact flag (binutils versions differ between
|
||||
# hosts; inside the pinned image they do not).
|
||||
#
|
||||
# RUSTFLAGS is *replaced*, never extended. An ambient RUSTFLAGS from a shell
|
||||
# profile or a CI default would silently change the output bytes, which is
|
||||
# precisely the thing this script exists to prevent.
|
||||
#
|
||||
# Inputs (env):
|
||||
# SOURCE_DATE_EPOCH required. `git log -1 --format=%ct <released-commit>`
|
||||
# SRC source checkout (default /src)
|
||||
# CARGO_TARGET_DIR build directory (default /target)
|
||||
# OUT where dist assets are written (default /out)
|
||||
# TARGET_TRIPLE asset name triple, defaults to the image's rustc host
|
||||
# BUILDER_IMAGE recorded in build-info.txt only (no effect on bytes)
|
||||
# CARGO_BUILD_JOBS build parallelism (no effect on bytes; default 2)
|
||||
#
|
||||
# Outputs in $OUT:
|
||||
# onionwire-<triple> the stripped binary
|
||||
# onionwire-<triple>.sha256 sha256sum-format checksum of it
|
||||
# build-info-<triple>.txt the recipe record: toolchain, epoch, commit,
|
||||
# image, and the hash this run produced
|
||||
set -euo pipefail
|
||||
|
||||
SRC="${SRC:-/src}"
|
||||
OUT="${OUT:-/out}"
|
||||
export CARGO_TARGET_DIR="${CARGO_TARGET_DIR:-/target}"
|
||||
|
||||
: "${SOURCE_DATE_EPOCH:?set SOURCE_DATE_EPOCH to the committer time of the released commit: git log -1 --format=%ct <sha>}"
|
||||
export SOURCE_DATE_EPOCH
|
||||
|
||||
# No colour, no progress bars: not a determinism input, but it keeps CI logs
|
||||
# diffable between two builds of the same commit.
|
||||
export CARGO_TERM_COLOR=never
|
||||
export CARGO_BUILD_JOBS="${CARGO_BUILD_JOBS:-2}"
|
||||
|
||||
# Fixed paths. The remaps make the output independent of where $SRC actually
|
||||
# lives on the verifying host; the container keeps the paths themselves fixed
|
||||
# for the C toolchains that ignore remapping entirely.
|
||||
#
|
||||
# CARGO_HOME is remapped as a whole, not just `registry`: the default feature
|
||||
# set pulls `cuprated` from a pinned git revision, and its checkout lands under
|
||||
# `$CARGO_HOME/git/...` — a path that would otherwise reach the artifact through
|
||||
# cuprate's own `file!()`/panic locations.
|
||||
CARGO_HOME_DIR="${CARGO_HOME:-/usr/local/cargo}"
|
||||
export RUSTFLAGS="--remap-path-prefix=${SRC}=/onionwire --remap-path-prefix=${CARGO_TARGET_DIR}=/onionwire/target --remap-path-prefix=${CARGO_HOME_DIR}=/cargo"
|
||||
|
||||
cd "$SRC"
|
||||
|
||||
# Build dependencies are installed HERE rather than by the caller, so CI and a
|
||||
# verifier get the same toolchain. `cmake` and a C toolchain are required because
|
||||
# the default feature set includes `cuprate-daemon` (RandomX + fjall), which the
|
||||
# release binary ships.
|
||||
#
|
||||
# Honest limit: these apt packages are not digest-pinned the way the image is, so
|
||||
# a Debian security update to gcc or cmake can move the output bytes. build-info
|
||||
# records their versions, so that mismatch is diagnosable instead of mysterious.
|
||||
apt-get -o Acquire::Retries=5 -o Acquire::ForceIPv4=true update
|
||||
apt-get -o Acquire::Retries=5 -o Acquire::ForceIPv4=true install -y --no-install-recommends \
|
||||
pkg-config libssl-dev cmake build-essential
|
||||
|
||||
TARGET_TRIPLE="${TARGET_TRIPLE:-$(rustc -vV | sed -n 's/^host: //p')}"
|
||||
[ -n "$TARGET_TRIPLE" ] || { echo "could not determine the target triple from rustc -vV" >&2; exit 1; }
|
||||
|
||||
# Derived once into variables: the values are wanted twice (the log line and
|
||||
# build-info.txt), and nesting a command substitution with its own quotes
|
||||
# inside a double-quoted string is where this file previously broke.
|
||||
EPOCH_UTC="$(date -u -d "@${SOURCE_DATE_EPOCH}" +%Y-%m-%dT%H:%M:%SZ)"
|
||||
RUSTC_VV="$(rustc -Vv | tr '\n' ' ' | sed 's/ */ /g')"
|
||||
CARGO_V="$(cargo -V)"
|
||||
STRIP_V="$(strip --version | head -1)"
|
||||
CC_V="$(cc --version | head -1)"
|
||||
CMAKE_V="$(cmake --version | head -1)"
|
||||
|
||||
echo "==> builder image: ${BUILDER_IMAGE:-unknown}"
|
||||
echo "==> rustc: ${RUSTC_VV}"
|
||||
echo "==> cargo: ${CARGO_V}"
|
||||
echo "==> SOURCE_DATE_EPOCH: ${SOURCE_DATE_EPOCH} (${EPOCH_UTC})"
|
||||
echo "==> RUSTFLAGS: ${RUSTFLAGS}"
|
||||
|
||||
cargo build --release --locked --bin onionwire
|
||||
|
||||
BIN="${CARGO_TARGET_DIR}/release/onionwire"
|
||||
[ -f "$BIN" ] || { echo "no binary at $BIN" >&2; exit 1; }
|
||||
|
||||
# CI passes the released sha in (the builder image has no git checkout to read);
|
||||
# a verifier running this from a clone lets it derive the sha itself.
|
||||
GIT_SHA="${GIT_SHA:-$(git -C "$SRC" rev-parse HEAD 2>/dev/null || echo unknown)}"
|
||||
|
||||
strip --strip-all "$BIN"
|
||||
|
||||
mkdir -p "$OUT"
|
||||
install -m 755 "$BIN" "${OUT}/onionwire-${TARGET_TRIPLE}"
|
||||
(
|
||||
cd "$OUT"
|
||||
sha256sum "onionwire-${TARGET_TRIPLE}" > "onionwire-${TARGET_TRIPLE}.sha256"
|
||||
sha256sum -c "onionwire-${TARGET_TRIPLE}.sha256"
|
||||
)
|
||||
|
||||
# The recipe record. Published next to the binary so a verifier can see which
|
||||
# toolchain, epoch and commit produced the hash they are comparing against
|
||||
# without having to reverse it out of a CI log.
|
||||
BINARY_SHA="$(cut -d' ' -f1 < "${OUT}/onionwire-${TARGET_TRIPLE}.sha256")"
|
||||
|
||||
{
|
||||
echo "onionwire ${TARGET_TRIPLE}"
|
||||
echo "commit: ${GIT_SHA}"
|
||||
echo "source_date_epoch: ${SOURCE_DATE_EPOCH}"
|
||||
echo "commit_time_utc: ${EPOCH_UTC}"
|
||||
echo "builder_image: ${BUILDER_IMAGE:-unknown}"
|
||||
echo "rustc: ${RUSTC_VV}"
|
||||
echo "cargo: ${CARGO_V}"
|
||||
echo "strip: ${STRIP_V}"
|
||||
echo "cc: ${CC_V}"
|
||||
echo "cmake: ${CMAKE_V}"
|
||||
echo "rustflags: ${RUSTFLAGS}"
|
||||
echo "build_command: cargo build --release --locked --bin onionwire"
|
||||
echo "sha256: ${BINARY_SHA}"
|
||||
} > "${OUT}/build-info-${TARGET_TRIPLE}.txt"
|
||||
|
||||
echo "==> build-info-${TARGET_TRIPLE}.txt"
|
||||
cat "${OUT}/build-info-${TARGET_TRIPLE}.txt"
|
||||
81
scripts/sign-release.sh
Executable file
81
scripts/sign-release.sh
Executable file
|
|
@ -0,0 +1,81 @@
|
|||
#!/usr/bin/env bash
|
||||
# Sign release assets with minisign, and verify our own signatures before
|
||||
# anything reaches the release page.
|
||||
#
|
||||
# Usage: sign-release.sh <file> [<file>...]
|
||||
#
|
||||
# Env:
|
||||
# MINISIGN_SECRET_KEY contents of the secret key file (required).
|
||||
# A CI secret; never committed, never passed as an arg.
|
||||
# MINISIGN_PUBKEY_FILE default scripts/onionwire-signing.pub
|
||||
# RELEASE_TAG optional; recorded in the trusted comment
|
||||
#
|
||||
# Fail closed by design. If the key is missing or a signature we just made does
|
||||
# not verify, this exits non-zero and the publish job stops — an unsigned
|
||||
# release is worse than a missing one, because it looks identical to a signed
|
||||
# one to anyone who is not checking.
|
||||
#
|
||||
# The key must be generated WITHOUT a password (`minisign -G -W`): CI cannot
|
||||
# answer a prompt, and a passphrase that has to sit next to the key in the same
|
||||
# secret store protects nothing. The secret lives only in Forgejo Actions
|
||||
# secrets; the public half is committed so verifiers have it out-of-band from
|
||||
# the release page. See docs/VERIFY.md.
|
||||
set -euo pipefail
|
||||
|
||||
[ "$#" -ge 1 ] || { echo "usage: sign-release.sh <file> [<file>...]" >&2; exit 1; }
|
||||
|
||||
root="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
pub_file="${MINISIGN_PUBKEY_FILE:-$root/scripts/onionwire-signing.pub}"
|
||||
|
||||
command -v minisign >/dev/null 2>&1 || {
|
||||
echo "sign-release: minisign is not installed (apt-get install -y minisign)" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
[ -s "$pub_file" ] || {
|
||||
echo "sign-release: no public key at $pub_file" >&2
|
||||
echo " Generate the pair once, on a machine you control:" >&2
|
||||
echo " minisign -G -W -p scripts/onionwire-signing.pub -s onionwire-signing.key" >&2
|
||||
echo " Commit the .pub file, store the .key file's contents as the Forgejo" >&2
|
||||
echo " Actions secret MINISIGN_SECRET_KEY, then delete the .key file." >&2
|
||||
echo " Procedure: docs/VERIFY.md, \"Maintainer: the signing key\"." >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
: "${MINISIGN_SECRET_KEY:?MINISIGN_SECRET_KEY is not set — add it as a Forgejo Actions secret; see docs/VERIFY.md}"
|
||||
|
||||
tmp="$(mktemp -d)"
|
||||
cleanup() {
|
||||
# The secret key is on disk for the length of this script and no longer.
|
||||
if [ -f "$tmp/onionwire-signing.key" ]; then
|
||||
shred -uz "$tmp/onionwire-signing.key" 2>/dev/null || rm -f "$tmp/onionwire-signing.key"
|
||||
fi
|
||||
rm -rf "$tmp"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
umask 077
|
||||
printf '%s\n' "$MINISIGN_SECRET_KEY" > "$tmp/onionwire-signing.key"
|
||||
chmod 600 "$tmp/onionwire-signing.key"
|
||||
|
||||
# Warm the signature with the same secret we just wrote: an unreadable or
|
||||
# truncated secret fails here rather than after three files are half-signed.
|
||||
[ -s "$tmp/onionwire-signing.key" ] || { echo "sign-release: the secret key is empty" >&2; exit 1; }
|
||||
|
||||
comment="OnionWire ${RELEASE_TAG:-release}"
|
||||
|
||||
for f in "$@"; do
|
||||
[ -f "$f" ] || { echo "sign-release: no such file: $f" >&2; exit 1; }
|
||||
bytes=$(wc -c < "$f")
|
||||
[ "$bytes" -gt 0 ] || { echo "sign-release: refusing to sign empty file $f" >&2; exit 1; }
|
||||
|
||||
minisign -S -W -s "$tmp/onionwire-signing.key" -m "$f" -x "$f.minisig" \
|
||||
-t "$comment" -c "signature for $(basename "$f")"
|
||||
[ -s "$f.minisig" ] || { echo "sign-release: minisign produced no signature for $f" >&2; exit 1; }
|
||||
|
||||
# Verify with the public half, not with the secret we just used: this is the
|
||||
# check a user will run, so it is the check we run.
|
||||
minisign -V -p "$pub_file" -m "$f" -x "$f.minisig" -q \
|
||||
|| { echo "sign-release: our own signature for $f does not verify against $pub_file" >&2; exit 1; }
|
||||
echo "sign-release: signed and verified $(basename "$f") -> $(basename "$f").minisig"
|
||||
done
|
||||
124
scripts/verify-reproducible.sh
Executable file
124
scripts/verify-reproducible.sh
Executable file
|
|
@ -0,0 +1,124 @@
|
|||
#!/usr/bin/env bash
|
||||
# Rebuild a released OnionWire binary from source and compare it, byte for
|
||||
# byte, with the asset on the release page.
|
||||
#
|
||||
# Usage:
|
||||
# scripts/verify-reproducible.sh <tag> [published .sha256 file or URL]
|
||||
#
|
||||
# ./scripts/verify-reproducible.sh v0.14.0
|
||||
# ./scripts/verify-reproducible.sh v0.14.0 /path/to/onionwire-x86_64-unknown-linux-gnu.sha256
|
||||
#
|
||||
# Why this exists: "the source is public" is not a check anyone can run. This
|
||||
# is. It rebuilds the tag's exact tree inside the same pinned builder image CI
|
||||
# uses and tells you whether the bytes match. A mismatch is a finding — it means
|
||||
# the published binary did not come from this source with this recipe.
|
||||
#
|
||||
# What it needs: docker, git, and the tag in your local clone (`git fetch --tags`).
|
||||
# It never touches your working tree: the tag tree is exported with
|
||||
# `git archive`, and everything is built in a temp dir that is removed on exit.
|
||||
#
|
||||
# What it does NOT depend on: your rustc, your distro, your glibc, your
|
||||
# CPU count. All of that is inside the pinned image.
|
||||
set -euo pipefail
|
||||
|
||||
BUILDER_IMAGE="rust@sha256:93ce27a88655056a51dbdd8f5f2d7ddc071c7b0070fb288a37b5a285fc83971e"
|
||||
RELEASE_BASE="${ONIONWIRE_RELEASE_BASE:-https://forgejo.siriusdevops.com/sirius/onionwire/releases/download}"
|
||||
|
||||
die() { echo "verify: $*" >&2; exit 1; }
|
||||
|
||||
tag="${1:?usage: verify-reproducible.sh <tag> [published .sha256 file or URL]}"
|
||||
expect_src="${2:-}"
|
||||
|
||||
command -v docker >/dev/null 2>&1 || die "docker is required to rebuild in the pinned builder image"
|
||||
command -v git >/dev/null 2>&1 || die "git is required"
|
||||
|
||||
repo="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
|
||||
sha="$(git -C "$repo" rev-parse --verify "$tag^{commit}" 2>/dev/null)" \
|
||||
|| die "tag $tag not found locally — run: git fetch --tags"
|
||||
sde="$(git -C "$repo" log -1 --format=%ct "$sha")"
|
||||
|
||||
echo "verify: tag $tag"
|
||||
echo "verify: commit $sha"
|
||||
echo "verify: source_date_epoch $sde"
|
||||
echo "verify: builder image $BUILDER_IMAGE"
|
||||
|
||||
work="$(mktemp -d)"
|
||||
trap 'rm -rf "$work"' EXIT
|
||||
|
||||
# Export the tag, not the working tree: a dirty checkout would otherwise build
|
||||
# something that was never released.
|
||||
mkdir -p "$work/src" "$work/out" "$work/target"
|
||||
git -C "$repo" archive "$sha" | tar -x -C "$work/src"
|
||||
[ -f "$work/src/scripts/reproducible-build.sh" ] \
|
||||
|| die "$tag has no scripts/reproducible-build.sh — it predates reproducible releases"
|
||||
|
||||
echo "verify: building (this is a full release build; expect several minutes)"
|
||||
docker volume create onionwire-verify-registry >/dev/null
|
||||
|
||||
docker run --rm \
|
||||
-v "$work/src:/src:ro" \
|
||||
-v onionwire-verify-registry:/usr/local/cargo/registry \
|
||||
-v "$work/target:/target" \
|
||||
-v "$work/out:/out" \
|
||||
-e SOURCE_DATE_EPOCH="$sde" \
|
||||
-e BUILDER_IMAGE="$BUILDER_IMAGE" \
|
||||
-e CARGO_BUILD_JOBS="${CARGO_BUILD_JOBS:-}" \
|
||||
-w /src \
|
||||
"$BUILDER_IMAGE" \
|
||||
bash scripts/reproducible-build.sh
|
||||
|
||||
sha_file="$(ls "$work"/out/*.sha256 2>/dev/null | head -1)" || true
|
||||
[ -n "${sha_file:-}" ] || die "the build produced no .sha256 — see the build output above"
|
||||
asset="$(basename "$sha_file" .sha256)"
|
||||
|
||||
mine="$(cut -d' ' -f1 < "$sha_file")"
|
||||
echo "verify: rebuilt $asset"
|
||||
echo "verify: rebuilt sha256 $mine"
|
||||
|
||||
# The published hash: an explicit path/URL if given, else the release asset.
|
||||
tmp_expect="$work/expect.sha256"
|
||||
if [ -n "$expect_src" ]; then
|
||||
if [ -f "$expect_src" ]; then
|
||||
cp "$expect_src" "$tmp_expect"
|
||||
else
|
||||
echo "verify: fetching $expect_src"
|
||||
curl -fsSL "$expect_src" -o "$tmp_expect" \
|
||||
|| die "could not fetch the published checksum from $expect_src"
|
||||
fi
|
||||
else
|
||||
url="$RELEASE_BASE/$tag/$asset.sha256"
|
||||
echo "verify: fetching $url"
|
||||
curl -fsSL "$url" -o "$tmp_expect" \
|
||||
|| die "could not download $url — pass the published .sha256 as the second argument instead"
|
||||
fi
|
||||
|
||||
theirs="$(cut -d' ' -f1 < "$tmp_expect")"
|
||||
echo "verify: published sha256 $theirs"
|
||||
|
||||
echo
|
||||
if [ "$mine" = "$theirs" ]; then
|
||||
echo "RESULT: MATCH — the published $asset is byte-for-byte the output of"
|
||||
echo " commit $sha built with the documented recipe."
|
||||
echo
|
||||
echo "The rebuilt binary is at:"
|
||||
echo " $work/out/$asset"
|
||||
echo "(it is deleted when this script exits; copy it out first if you want it)"
|
||||
# Keep the artifact for the user: the trap would remove it, so copy next to
|
||||
# the caller unless they asked for a scratch run.
|
||||
if [ -n "${ONIONWIRE_VERIFY_KEEP:-}" ]; then
|
||||
mkdir -p "$ONIONWIRE_VERIFY_KEEP"
|
||||
cp "$work/out/$asset" "$ONIONWIRE_VERIFY_KEEP/"
|
||||
echo "copied to $ONIONWIRE_VERIFY_KEEP/$asset (ONIONWIRE_VERIFY_KEEP)"
|
||||
fi
|
||||
else
|
||||
echo "RESULT: MISMATCH — the published binary does NOT match a rebuild of this tag." >&2
|
||||
echo " rebuilt: $mine" >&2
|
||||
echo " published: $theirs" >&2
|
||||
echo >&2
|
||||
echo "This is a real finding, not a glitch to shrug at. Report it, and do not" >&2
|
||||
echo "run the published binary until it is explained. Two honest causes to rule" >&2
|
||||
echo "out first: the release was built from a different commit than the tag, or" >&2
|
||||
echo "the builder image digest moved (compare build-info-*.txt on the release)." >&2
|
||||
exit 1
|
||||
fi
|
||||
Loading…
Reference in a new issue