release: reproducible builds, and sign every asset
All checks were successful
android-ci / android (pull_request) Successful in 12m34s
ci / test (pull_request) Successful in 13m28s
ci / sdk (pull_request) Successful in 1m13s

"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:
agent 2026-10-11 12:20:08 -04:00
commit 601f640f78
No known key found for this signature in database
11 changed files with 962 additions and 76 deletions

124
scripts/verify-reproducible.sh Executable file
View 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