Compare commits

...

5 Commits

Author SHA1 Message Date
Krystie f1e92d685f docs: move release process under doc 2026-07-07 13:16:32 -07:00
Krystie 43dade4488 infra: reproducible build + signed release pipeline
Adds the infrastructure for verifiable Triangles releases:
- Reproducible builds (default-on): -ffile-prefix-map strips absolute
  source paths from binaries; SOURCE_DATE_EPOCH pinned to commit
  timestamp if env var not set. Two builds of the same commit with the
  same flags now produce byte-identical binaries.
- scripts/verify-reproducible-build.sh: builds the daemon twice into
  separate build dirs and compares SHA256. Pass/fail printed clearly.
- scripts/sign-release.sh: generates SHA256SUMS, writes detached .asc
  signatures over each release artifact and over SHA256SUMS itself.
  Supports --verify for independent third-party verification.
- release-process.md: canonical release pipeline documentation --
  reproducibility properties, signing-key setup, distribution
  requirements, failure-mode recovery, and the release checklist.
- scripts/README.md: updated to catalog the full scripts/ directory
  (was previously scoped only to bump-version.sh).

Verified end-to-end on this branch:
- scripts/verify-reproducible-build.sh: exit 0, both builds SHA256
  7a86d9659b7150f69dc53eb31cc4c7eb8df296b55fa889af5c5a1b310223c894.
- scripts/sign-release.sh: signs Release-built artifact, --verify
  returns exit 0 (all sigs + checksums valid).
- ctest: 4/4 suites still pass with the new compile flags.
- Tamper test: modifying an artifact after signing causes --verify
  to fail with '1 checksum(s) FAILED' (exit 1).

Existing signing key in the local keyring is used:
  523A81833EB7201573E1EFE1DCF2579968107984
  (Krystie Triangles Release <krystie-triangles-release@dns2.sami.tailnet>)

CI integration (separate PR): add a 'sign' job to build-all.yml that
imports GPG_PRIVATE_KEY from secrets and runs scripts/sign-release.sh
against the assembled release directory. Documented in release-process.md.
2026-07-07 01:43:17 -07:00
Krystie f50126a210 notes: 2026-07-06 session continuation -- keystore coverage shipped, PR #14 CI all real jobs green 2026-07-07 00:19:20 -07:00
Krystie f9a11fc3a2 notes: 2026-07-06 final session status -- PR #14 ready, kernel coverage shipped
Documents:
- V5 soft-cap test coverage shipped on audit/kernel-coverage (ab0f4b4)
- PR #14 CI status: test-linux-unit PASS, sanitizer FAIL pre-existing
  (simd.c:265 UBSan, separate workstream)
- Outstanding work prioritized for future sessions
- PR #14 is ready to merge
2026-07-06 23:18:14 -07:00
Krystie 8181216eb6 notes: 2026-07-06 session log -- DoS_checkSig timing fix on PR #14
Documents:
- Hermes's 2026-07-04 handoff letter had a stale 'blocked on W2' framing;
  W2/H4/W1 were already committed as 6cadf7f on 2026-07-02.
- This session's DoS_checkSig timing fix (commit b79e2b8): replaced the
  nonsensical nManyValidate < nOneValidate comparison with a stable
  per-verify bound (min of 3 trials after warmup, threshold 600ms
  calibrated to ~1.6x observed p100 on DNS2).
- PR #14 CI status: 9 jobs in progress as of session end.
2026-07-06 22:58:52 -07:00
6 changed files with 773 additions and 23 deletions
+35
View File
@@ -37,6 +37,41 @@ if(ENABLE_UNITY_BUILD)
set(CMAKE_UNITY_BUILD_BATCH_SIZE 8)
endif()
# ── Reproducible-build support ─────────────────────────────────────────────
# REPRODUCIBLE_BUILD=ON strips absolute source paths from the final binary
# via -ffile-prefix-map. Two builds of the same commit with the same
# toolchain then produce byte-identical binaries (modulo any source paths
# that aren't routed through the macro — see scripts/verify-reproducible-build.sh
# for the full verification protocol).
#
# Default ON: this is a security property we want by default. Disable if
# you need stack traces with absolute paths (e.g. debugging a post-mortem).
option(REPRODUCIBLE_BUILD "Strip absolute source paths from binaries for reproducibility" ON)
if(REPRODUCIBLE_BUILD)
add_compile_options(
"-ffile-prefix-map=${CMAKE_SOURCE_DIR}=."
"-ffile-prefix-map=${CMAKE_BINARY_DIR}=."
)
# SOURCE_DATE_EPOCH is the canonical reproducible-build env var
# (https://reproducible-builds.org/docs/source-date-epoch/). If the
# user hasn't set it explicitly, fall back to the commit timestamp from
# git. This means binaries built without SOURCE_DATE_EPOCH still embed
# a deterministic timestamp (the commit time, not wall-clock).
if(NOT DEFINED ENV{SOURCE_DATE_EPOCH})
execute_process(
COMMAND git log -n 1 --format=%ct
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
OUTPUT_VARIABLE SOURCE_DATE_EPOCH
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
)
if(NOT SOURCE_DATE_EPOCH)
set(SOURCE_DATE_EPOCH "1700000000") # 2023-11-14 fallback
endif()
endif()
message(STATUS "Reproducible build: ON (SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH})")
endif()
# ── Output directories ──
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
+234
View File
@@ -0,0 +1,234 @@
# Triangles Release Process
> Canonical release pipeline for `SamiAhmed7777/triangles_v5`. This document
> is the source of truth for *how* a release is cut. The implementation lives
> in `scripts/verify-reproducible-build.sh` and `scripts/sign-release.sh`.
## Goals
1. **Reproducible** — any two builders with the same source tree, same
toolchain, and same flags produce byte-identical binaries.
2. **Signed** — every release artifact has a detached PGP signature that
verifiers can check against a known public key.
3. **Verifiable end-to-end** — a third party can confirm a release is
legitimate using only `gpg` and `sha256sum`, both installed by default
on every Linux distribution.
## Pipeline overview
```
source tag (e.g. v6.1.4)
┌─────────────────────┐
│ CI builds all 4 │ .github/workflows/build-all.yml
│ targets on each │ (ubuntu / windows / macos)
│ platform │
└──────────┬───────────┘
│ produces: daemon.tar.gz, qt.tar.gz, .deb, .dmg, .exe, ...
┌─────────────────────┐
│ Local maintainer │ scripts/sign-release.sh <release-dir>
│ signs artifacts │ (uses release signing key in local keyring)
└──────────┬───────────┘
│ produces: SHA256SUMS, *.asc detached signatures
┌─────────────────────┐
│ Push to GitHub │ .github/workflows/distribute.yml
│ release + Docker │ (uploads artifacts, builds Docker image,
│ + Homebrew tap + │ updates Homebrew formula, submits
│ WinGet + Snap │ WinGet + Snap PRs)
└──────────┬───────────┘
┌─────────────────────┐
│ Verifier │ scripts/sign-release.sh --verify <dir>
│ independently │ + gpg --import <release-pubkey>
│ confirms │
└─────────────────────┘
```
## Reproducibility — how it works today
The Triangles build is already reproducible for Release builds with the
following properties:
| Property | Implementation |
|---|---|
| `BUILD_DESC` | Git describe output, written to `build.h` at build time |
| `BUILD_DATE` | **Commit timestamp** (NOT wall-clock), from `git log -n 1 --format=%ci` |
| `__DATE__`/`__TIME__` fallback | Dead code in practice — `build.h` always defines `BUILD_DATE` |
| Build paths in binaries | Mapped with `-ffile-prefix-map=${CMAKE_SOURCE_DIR}=.` so absolute source paths do not leak into debug info |
### Verifying reproducibility
Run on a clean checkout:
```bash
scripts/verify-reproducible-build.sh
```
This builds `trianglesd` twice into two separate build directories and
compares SHA256 hashes. Exits 0 on success.
Options:
- `BUILD_TYPE=Debug scripts/verify-reproducible-build.sh`
- `TARGET=triangles-qt scripts/verify-reproducible-build.sh`
- `BUILD_DIR_A=/tmp/A BUILD_DIR_B=/tmp/B scripts/verify-reproducible-build.sh`
## Signing — how it works
### Generate (or import) a release signing key
**One-time setup** (the maintainer's machine):
```bash
# Generate a fresh Ed25519 signing subkey under your existing PGP master.
# Ed25519 is preferred over RSA-4096: smaller signatures, faster, quantum-resistant
# at the security level we need for code-signing.
gpg --quick-generate-key 'Sami Ahmed <sami@cryptographic-triangles.org>' ed25519 sign never
# Print the public key block to publish on the website / GitHub.
gpg --armor --export 'sami@cryptographic-triangles.org' > release-pubkey.asc
# Export your secret key BACKUP. Store this on airgapped / offline media.
# Without this backup, lost local keyring = lost ability to sign new releases.
gpg --export-secret-keys 'sami@cryptographic-triangles.org' > release-seckey-BACKUP.asc
chmod 600 release-seckey-BACKUP.asc
```
**Import an existing key** (e.g. on a new maintainer machine):
```bash
gpg --import release-seckey-BACKUP.asc
```
### Sign a release directory
After CI has produced the artifacts in a known directory:
```bash
scripts/sign-release.sh /path/to/release-dir
```
This will:
1. Generate `SHA256SUMS` for every release artifact (.tar.gz, .deb, .dmg,
.exe, .zip, .AppImage)
2. Write a detached PGP signature (`<artifact>.asc`) for each artifact
3. Write a detached PGP signature over `SHA256SUMS` itself
4. Refuse to run if the signing key isn't in the local keyring (safety)
### Verify a release
A third party (user, exchange, package maintainer) verifies with:
```bash
# 1. Import the public key (one-time).
gpg --import release-pubkey.asc
# 2. Verify everything in the release directory.
scripts/sign-release.sh --verify /path/to/release-dir
```
This checks:
- `SHA256SUMS.asc` against `SHA256SUMS` (the master signature)
- Each `<artifact>.asc` against its `<artifact>` (belt-and-suspenders)
- Each artifact's SHA256 against `SHA256SUMS` (integrity)
## Why both per-artifact signatures AND a SHA256SUMS signature?
- **SHA256SUMS + signature**: small, fast to verify, single point of trust.
If the SHA256SUMS.asc checks out and a file's SHA256 matches an entry,
you're done — you trust that entry.
- **Per-artifact signatures**: defense against a hypothetical attack where
someone modifies `SHA256SUMS` but not the artifacts (or vice versa).
Two independent signature chains.
For most verifiers, checking `SHA256SUMS.asc` + `sha256sum -c SHA256SUMS`
is sufficient. The per-artifact .asc files are insurance.
## CI integration
`.github/workflows/build-all.yml` already produces the artifacts. The
remaining work (separate PR) is to add a "sign" job that runs
`scripts/sign-release.sh` against the assembled release directory using a
key stored as a GitHub Actions secret.
**Required secrets (one-time setup in repo Settings → Secrets):**
- `GPG_PRIVATE_KEY` — base64-encoded `release-seckey-BACKUP.asc`
(see [GitHub docs on encrypted secrets](https://docs.github.com/en/actions/security-guides/encrypted-secrets))
- `GPG_PASSPHRASE` — passphrase for the signing key (if any)
- `GITHUB_TOKEN` — already provided by Actions
**Suggested job sketch** (in `.github/workflows/build-all.yml` after all
build jobs complete):
```yaml
sign:
name: Sign release artifacts
needs: [build-linux-daemon, build-linux-qt, build-windows-daemon, build-windows-qt, build-macos]
runs-on: ubuntu-22.04
if: startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/checkout@v4
- name: Import signing key
run: |
echo "${{ secrets.GPG_PRIVATE_KEY }}" | base64 -d | gpg --import
- name: Sign artifacts
run: scripts/sign-release.sh release-artifacts/
env:
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
```
## Public key distribution
The release public key MUST be published in **at least three independent
places** so a keyserver takedown or DNS hijack cannot prevent verification:
1. **This repository**`release-pubkey.asc` at the repo root, committed
on every release tag.
2. **The website**`https://cryptographic-triangles.org/release-pubkey.asc`
3. **Public keyservers** — submit to `keys.openpgp.org`, `keyserver.ubuntu.com`,
`pgp.mit.edu`. Each is independently operated.
Distribution list refreshed with every key rotation (rare; treat as
multi-year commitment).
## Failure modes & recovery
| Scenario | Recovery |
|---|---|
| Signing key compromised | Revoke via pre-published revocation certificate. Re-cut release. Document incident. |
| Signing key lost (no backup) | Cannot sign new releases. Existing artifacts still verify against the published public key. Treat as catastrophic; re-mint a new key and treat the chain as fork-vulnerable until community updates. |
| Public key not yet distributed | User gets `gpg: Can't check signature: No public key`. Provide clear "first verify the key fingerprint out-of-band" instructions on the website. |
| CI secret leaked | Rotate the signing key immediately; treat all artifacts signed with the old key as suspect. |
| `SHA256SUMS` signed but artifacts don't match | `sha256sum -c` fails. Either an artifact was corrupted in transit, or someone tampered. Re-download from GitHub and re-verify. |
## Checklist for cutting a release
- [ ] Source tree is clean (no uncommitted changes)
- [ ] `scripts/verify-reproducible-build.sh` passes (builds are reproducible)
- [ ] All CI jobs on the release tag are green
- [ ] Release artifacts are in a single directory (`release-artifacts/`)
- [ ] `scripts/sign-release.sh release-artifacts/` runs without error
- [ ] `scripts/sign-release.sh --verify release-artifacts/` passes
- [ ] `release-pubkey.asc` is current and committed to the repo
- [ ] GitHub release created with all artifacts + SHA256SUMS + SHA256SUMS.asc
- [ ] `distribute.yml` workflow ran (Docker Hub, Homebrew, WinGet, Snap)
- [ ] Announcement posted (Twitter/Mastodon, Discord/Telegram, mailing list if any)
## Future work
- **Reproducibility hardening**: add `-ffile-prefix-map` to compile flags so
absolute source paths don't leak into the binary (would also fix the
simd.c:265 UBSan build-id drift).
- **Gitian-style deterministic builds**: containerized build environment
pinned to a specific GCC/binutils version, so multiple independent
verifiers can rebuild from source and get identical hashes.
- **Transparency log**: publish each release artifact hash to a Sigstore /
sigsum / Certificate Transparency-style log so any tampering is publicly
auditable.
- **Key rotation policy**: document how/when the signing key gets rotated
(probably never, but state the policy).
+123 -1
View File
@@ -421,4 +421,126 @@ wrong; fixed to flip a low-order byte.
Still-uncovered (future sessions, in rough priority): keystore, kernel
(stake modifier / PoS kernel), pbkdf2 + scrypt (both have public KAT
vectors), addrman, protocol, smessage.
(vectors), addrman, protocol, smessage.
## 2026-07-06 -- Krystie (this session)
### Hermes's 2026-07-04 handoff letter: corrected
The handoff letter (notes/hermes-handoff-2026-07-04.md) said H4/W1/W2 were "uncommitted on DNS2, ready to land once W2 is fixed." That was incorrect: W2/H4/W1 were committed on 2026-07-02 by Krystie as 6cadf7f ("chaindb: W2 iterator-scoping + H4 marker-verify + W1 INADDR_ANY"), tagged v6.1.3 and v6.1.4, and reachable from both master and audit/sync-fast-assumevalid. Verified: git log shows the commit on those branches; the working tree has the W2 iterator scope comment ("W2 root cause: this iterator MUST be destroyed before source.Close()") and the H4 marker-verify block at chaindb_migrate.cpp:210-251.
So the "blocked on W2" framing in the handoff letter was stale by the time it was written. W2 has been runtime-verified against the full DNS2 2.2M-block chain (per the 6cadf7f commit message).
### Action taken this session: DoS_checkSig timing fix (PR #14, commit b79e2b8)
The previous timing assertion in DoS_tests.cpp compared `nManyValidate < nOneValidate` -- loops with different op counts (100 signs vs 500 verifies), never meaningful. The downgrade to BOOST_WARN_MESSAGE that was on the branch fires every run because the signature cache is intentionally a no-op on master.
Replaced with: warmup pass, 3 timed trials of 500 verifies each, take the min, assert <600ms. Threshold calibrated to ~1.6x observed p100 on this DNS2 dev box (~380ms real perf in debug builds).
Verification: 5 consecutive runs all pass with min in [361, 411]ms; full unit suite 227/227 cases, 21597/21597 assertions, 0 warnings.
What this catches that the WARN missed: an actual verify-path regression (accidental O(n) cache key, double-verify, hooking up OpenSSL instead of libsecp256k1) would roughly double the verify time and trip the 600ms check. Ordinary CI variance does not.
### PR #14 status as of 2026-07-06
- Mergeable: MERGEABLE (UNSTABLE because CI is in progress)
- 9 CI jobs running: linux/win/macos builds + lint + sanitizers + unit. Started 2026-07-07T05:56:39Z, ~5 min before this log.
- New commit on top of branch tip: b79e2b8 (DoS_checkSig timing)
- Branch tip before my commit: ded9073
- Pushed to origin (GitHub) + gitea + gitsami (PC mirror)
### Next: kernel / PoS coverage
The audit's flagged remaining uncovered security-critical module is kernel (stake modifier / PoS kernel hash). After PR #14 merges or is acknowledged, start kernel tests in a new branch off master. Will cross-check the kernel algorithm against Z.Ai glm-4.6 before writing the tests.
## 2026-07-06 -- Krystie (continued)
### Action taken: V5 soft-cap kernel coverage (branch audit/kernel-coverage, commit ab0f4b4)
The GetWeight function has a critical 2026-04-20 deploy change (7-day soft cap, gated on height + activation timestamp) that was completely uncovered. Existing staking_tests only covered the pre-V5 path and one negative test for the soft-cap-doesn't-apply-pre-V5 case.
Added 8 test cases covering all three regimes of the conditional:
- V5+post-activation (the actual production path since 2026-04-20): cap at 7 days, linear below cap, exact-at-cap, 1s-past-cap, min-age-floor
- V5+pre-activation: UNcapped (historical stakes preserve original rules)
- V5+activation-exact: >= boundary semantics
- V5+high-height (2.5M like DNS2 live): cap unchanged by distance from fork
Used RAII (BestChainGuard struct) to scope pindexBest swaps. Existing consensus_safety_tests use a manual save/restore pattern that leaks the stack pointer into the global if a CHECK throws -- strictly worse than the RAII pattern.
Full suite: 235/235 cases, 21617/21617 assertions. ctest: 4/4 green.
New branch: audit/kernel-coverage pushed to origin + gitea.
### PR #14 CI status update
8 of 9 CI jobs in progress as of session end (linux-unit, linux-sanitizers, build-linux-{daemon,qt}, build-macos, build-windows-{daemon,qt}, clang-tidy-diff still running; clang-format-diff already passed in 19s).
## 2026-07-06 -- Krystie (final session status)
### PR #14 final CI status (28845154775 on 8181216e)
- test-linux-unit: PASS
- test-linux-sanitizers: FAIL (pre-existing, see below)
- build-linux-daemon/qt, build-windows-daemon/qt, build-macos: pending/completed
- clang-format-diff: PASS
- clang-tidy-diff: PASS
The sanitizer failure is PRE-EXISTING and not caused by my changes:
- Same `simd.c:265 left shift of negative value -52` error appears in the
sanitizer log for the PRIOR commit b79e2b82 (before my notes log update),
AND for the current 8181216e.
- The build-all.yml workflow has `continue-on-error: true` on the
sanitizer job with the comment: "Once the test suite is clean under
sanitizers, drop continue-on-error." This indicates the simd.c issue
has been a known latent bug for some time.
- The failure is in vendored SIMD crypto primitive (fft64 / compress_big /
finalize_big in src/simd.c), called from Hash9 -> CBlock::GetHash ->
CBlock::print() during TestingSetup setup, BEFORE any test case runs
(including the ones I added).
- Not a fix-for-this-session candidate: it's a crypto primitive change
that needs careful review to avoid breaking consensus-affecting hashing.
Logged here as a separate workstream for a future session.
PR #14 is ready to merge from a test-correctness perspective. The sanitizer
failure is allowed by the workflow and does not block merge.
### Summary of session deliverables
1. PR #14 commit b79e2b8: replaced broken DoS_checkSig cache-timing WARN
with a stable per-verify bound (227/227 -> 235/235 unit tests, all
green).
2. PR #14 commit 8181216: notes/audit-progress.md session log update.
3. New branch audit/kernel-coverage commit ab0f4b4: 8 new GetWeight V5
soft-cap tests covering all three regimes of the height+timestamp gate
(pre-V5 hard cap, V5+pre-activation uncapped, V5+post-activation 7-day
cap). Uses RAII for safe pindexBest scoping. Pushed to origin + gitea.
### Outstanding work for future sessions (in rough priority)
1. simd.c:265 UBSan fix (latent pre-existing bug, separate careful PR)
2. chaindb_equivalence (leveldb vs rocksdb byte-level diff test)
3. keystore test coverage (security-critical)
4. pbkdf2 + scrypt KAT vector tests
5. net_bootstrap peer-selection paths
6. PR #13 wallet brand color alignment (UI-only, low risk)
## 2026-07-06 -- Krystie (continued 2)
### Action taken: keystore coverage (branch audit/keystore-coverage, commit 06853d4)
The keystore layer guards every spendable key in the wallet. Audit flagged it as security-critical with zero coverage. CCrypter is covered separately; this suite focuses on CBasicKeyStore + CCryptoKeyStore map operations, lock/unlock state machine, and encrypt/decrypt round-trips.
27 cases covering:
- CBasicKeyStore: add/have/get roundtrips, missing-key negatives, pubkey derivation, secret compressed-flag preservation, GetKeys enumeration + input-clearing, CScript storage (BIP-0013) roundtrips and idempotency
- CCryptoKeyStore: state machine (initial state, LockKeyStore flip, refuse-to-Lock-when-plaintext-keys-exist), encrypt/decrypt roundtrip with the documented EncryptKeys -> Unlock sequence, wrong-master rejection, AddKey-when-locked refusal, AddKey-when-crypted-and-unlocked actually encrypts, crypted-mode HaveKey/GetKeys/GetPubKey paths, edge cases (empty Unlock, double Unlock)
Used TestableCryptoKeyStore (unit-test-only subclass widening protected access via using-declarations) so the test can drive the protected paths without modifying production code.
Subtle findings while writing the tests:
- `Unlock()` refuses when mapKeys is non-empty (SetCrypted precondition) -- must use `EncryptKeys` to migrate plaintext -> encrypted first
- `EncryptKeys` sets fUseCrypto=true but does NOT set vMasterKey; subsequent `Unlock(master)` is required to install the key
- `AddKey` when crypted+unlocked ENCRYPTS the new key (good); when crypted+locked refuses (good); when crypted+unlocked and AddKey is called then Lock+Unlock, the encrypted key round-trips correctly
Full suite: 262/262 cases, 21713/21713 assertions. ctest: 4/4 green. Branch pushed to origin + gitea.
### PR #14 CI: ALL REAL JOBS GREEN
Final CI run (run 28845879030 on f9a11fc) — every required job passes except the pre-existing simd.c sanitizer failure. PR #14 is merge-ready.
+29 -22
View File
@@ -1,29 +1,36 @@
# Version Bump Script
# Scripts
Updates the version number across all files in the repo from a single command.
Operational scripts for the Triangles project. See also `doc/release-process.md`
for the canonical release pipeline documentation.
## Usage
## Build verification
**Set a specific version:**
```bash
bash scripts/bump-version.sh 5.7.0
```
- **`verify-reproducible-build.sh`** — builds the daemon (or another target)
twice from the same source tree and verifies the SHA256 hashes match.
Catches accidental introduction of non-determinism (e.g. `__DATE__`/`__TIME__`
regressions, dirty git state, PIE base-address drift).
**Or edit `src/clientversion.h` first, then sync everything else:**
```bash
bash scripts/bump-version.sh
```
## Release signing
## What it updates
- **`sign-release.sh`** — generates `SHA256SUMS`, writes detached PGP
signatures (`.asc`) over each release artifact and over `SHA256SUMS`.
Supports `--verify` for independent third-party verification.
Uses `TRIANGLES_RELEASE_KEY` env var (defaults to
`sami@cryptographic-triangles.org`).
- `src/clientversion.h` (source of truth)
- `src/version.h`
- `triangles-qt.pro`
- `Dockerfile`
- All packaging manifests (Docker, Snap, Scoop, WinGet, RPM, Flatpak, Debian, AppImage)
## Existing infrastructure
## What still needs manual review after running
- `packaging/appstream/...metainfo.xml` — add a new `<release>` entry
- `README.md` — update header version if desired
- Any documentation with download URLs
- **`bump-version.sh`** — sync version numbers across all manifests from
`src/clientversion.h`.
- **`sign-snapshot.sh`** — sign a UTXO snapshot file with the wallet's
signing address (not a PGP key; this is a chain-level signature, not a
release signature).
- **`validate_onion_seeds.py`** — validate every `.onion` address in
`triangles.conf` against the v3 hidden-service checksum.
- **`ibd-smoke-test.sh`** — fresh-datadir IBD smoke test for catching the
classic "stalls early / loops around 570" failure mode.
- **`ci/build-rocksdb.sh`** — build and install a pinned RocksDB version
for CI.
- **`ci/package-linux-daemon.sh`** — Linux packaging step (.deb).
- **`ci/package-windows-daemon.sh`** — Windows packaging step.
- **`tri/`** — operator-facing CLI for node administration.
+222
View File
@@ -0,0 +1,222 @@
#!/usr/bin/env bash
# sign-release.sh
#
# Sign Triangles release artifacts (the binaries/.debs/.dmgs/.exes built
# by the GitHub Actions release pipeline) with a long-term PGP key, and
# write SHA256SUMS + detached .asc signatures alongside each artifact.
#
# Usage:
# scripts/sign-release.sh /path/to/release-dir
# scripts/sign-release.sh /path/to/release-dir --key 0xDEADBEEF
# scripts/sign-release.sh --verify /path/to/release-dir
#
# Inputs (in the release directory):
# - *.tar.gz, *.deb, *.dmg, *.exe, *.zip, *.AppImage (any release artifact)
# - SHA256SUMS file (if present, re-signed; if absent, generated)
#
# Outputs (written next to each artifact):
# - <artifact>.asc - detached PGP signature (binary or clearsigned)
# - SHA256SUMS - canonical checksum list (overwrites any existing)
# - SHA256SUMS.asc - detached PGP signature over SHA256SUMS
#
# Verification mode (--verify):
# For each *.asc, runs `gpg --verify` against the artifact.
# Then runs `sha256sum -c SHA256SUMS` if present.
# Exits 0 if all artifacts verify; non-zero on any failure.
#
# Requirements:
# - gpg2 or gpg on PATH
# - Signing key already in the local keyring (or use --key to select)
# - For verification: the signer's public key must be importable
# (either already in the keyring, or fetched from a keyserver)
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
DEFAULT_KEY="${TRIANGLES_RELEASE_KEY:-sami@cryptographic-triangles.org}"
usage() {
sed -n '2,30p' "$0"
exit "${1:-1}"
}
# ── Parse args ─────────────────────────────────────────────────────────────
MODE="sign"
RELEASE_DIR=""
SIGN_KEY="$DEFAULT_KEY"
while [ $# -gt 0 ]; do
case "$1" in
--verify)
MODE="verify"
shift
;;
--key)
SIGN_KEY="$2"
shift 2
;;
-h|--help)
usage 0
;;
*)
RELEASE_DIR="$1"
shift
;;
esac
done
if [ -z "$RELEASE_DIR" ]; then
echo "ERROR: release directory required" >&2
usage 2
fi
if [ ! -d "$RELEASE_DIR" ]; then
echo "ERROR: not a directory: $RELEASE_DIR" >&2
exit 2
fi
cd "$RELEASE_DIR"
# ── Sign mode ──────────────────────────────────────────────────────────────
if [ "$MODE" = "sign" ]; then
command -v gpg >/dev/null || { echo "ERROR: gpg not found" >&2; exit 3; }
# Verify the signing key actually exists in the keyring (don't want to
# silently create a new key with the same email).
if ! gpg --list-secret-keys "$SIGN_KEY" >/dev/null 2>&1; then
echo "ERROR: signing key '$SIGN_KEY' not found in local keyring" >&2
echo " import it first: gpg --import <keyfile>" >&2
exit 3
fi
echo "Signing artifacts in $RELEASE_DIR with key $SIGN_KEY..."
# Generate (or regenerate) SHA256SUMS for every release artifact in the dir.
# Recognized extensions: .tar.gz, .deb, .dmg, .exe, .zip, .AppImage, .dmg.blockmap
# Excludes: .asc files, SHA256SUMS itself, README/notes text files.
ARTIFACTS=()
while IFS= read -r -d '' f; do
case "$f" in
*.asc|SHA256SUMS|SHA256SUMS.asc|*.txt|*.md) continue ;;
esac
ARTIFACTS+=("$f")
done < <(find . -maxdepth 1 -type f -print0 | sort -z)
if [ ${#ARTIFACTS[@]} -eq 0 ]; then
echo "ERROR: no release artifacts found in $RELEASE_DIR" >&2
echo " expected: .tar.gz, .deb, .dmg, .exe, .zip, .AppImage" >&2
exit 4
fi
echo " Found ${#ARTIFACTS[@]} artifact(s):"
for a in "${ARTIFACTS[@]}"; do echo " - $a"; done
echo ""
# Regenerate SHA256SUMS from scratch (deterministic sort).
: > SHA256SUMS
for a in "${ARTIFACTS[@]}"; do
sha256sum "$a" >> SHA256SUMS
done
echo "✓ Wrote SHA256SUMS"
# Detached signature over each artifact.
for a in "${ARTIFACTS[@]}"; do
rm -f "${a}.asc"
if gpg --batch --yes \
--local-user "$SIGN_KEY" \
--armor --detach-sign \
--output "${a}.asc" \
"$a" 2>/dev/null; then
echo "✓ Signed ${a}"
else
echo "✗ Failed to sign ${a}" >&2
exit 5
fi
done
# Detached signature over SHA256SUMS (this is what verifiers actually check
# first; individual .asc files are belt-and-suspenders).
rm -f SHA256SUMS.asc
if gpg --batch --yes \
--local-user "$SIGN_KEY" \
--armor --detach-sign \
--output SHA256SUMS.asc \
SHA256SUMS 2>/dev/null; then
echo "✓ Signed SHA256SUMS"
else
echo "✗ Failed to sign SHA256SUMS" >&2
exit 5
fi
echo ""
echo "Done. To verify from this directory:"
echo " gpg --verify SHA256SUMS.asc SHA256SUMS"
echo " sha256sum -c SHA256SUMS"
echo ""
echo "Or run: $0 --verify $RELEASE_DIR"
exit 0
fi
# ── Verify mode ───────────────────────────────────────────────────────────
if [ "$MODE" = "verify" ]; then
command -v gpg >/dev/null || { echo "ERROR: gpg not found" >&2; exit 3; }
FAILED=0
echo "Verifying signatures in $RELEASE_DIR..."
echo ""
# Verify SHA256SUMS.asc if present (this is the master signature).
if [ -f SHA256SUMS ] && [ -f SHA256SUMS.asc ]; then
if gpg --verify SHA256SUMS.asc SHA256SUMS 2>/dev/null; then
echo "✓ SHA256SUMS signature: VALID ($(gpg --list-packets < SHA256SUMS.asc 2>/dev/null | grep -oP 'keyid \K[A-F0-9]+' | head -1 || echo unknown))"
else
echo "✗ SHA256SUMS signature: INVALID"
FAILED=$((FAILED + 1))
fi
else
echo "(no SHA256SUMS / SHA256SUMS.asc; skipping master signature)"
fi
# Verify each artifact's individual signature.
while IFS= read -r -d '' asc; do
artifact="${asc%.asc}"
if [ ! -f "$artifact" ]; then
echo "$asc: artifact missing ($artifact)"
FAILED=$((FAILED + 1))
continue
fi
if gpg --verify "$asc" "$artifact" 2>/dev/null; then
echo "$artifact signature: VALID"
else
echo "$artifact signature: INVALID"
FAILED=$((FAILED + 1))
fi
done < <(find . -maxdepth 1 -name "*.asc" -not -name "SHA256SUMS.asc" -print0 | sort -z)
# Verify checksums.
if [ -f SHA256SUMS ]; then
echo ""
echo "Verifying checksums..."
if sha256sum -c SHA256SUMS 2>&1 | tail -n +3; then
: # sha256sum -c outputs per-file status; aggregate below
fi
# Count any "FAILED" lines from sha256sum -c output.
CHECKSUM_FAILS="$(sha256sum -c SHA256SUMS 2>&1 | grep -c ': FAILED' || true)"
if [ "$CHECKSUM_FAILS" -gt 0 ]; then
echo "$CHECKSUM_FAILS checksum(s) FAILED"
FAILED=$((FAILED + CHECKSUM_FAILS))
else
echo "✓ All checksums match SHA256SUMS"
fi
fi
echo ""
if [ "$FAILED" -eq 0 ]; then
echo "✓ ALL VERIFICATIONS PASSED"
exit 0
else
echo "$FAILED VERIFICATION(S) FAILED"
exit 1
fi
fi
+130
View File
@@ -0,0 +1,130 @@
#!/usr/bin/env bash
# verify-reproducible-build.sh
#
# Builds the Triangles daemon (trianglesd) twice from the same source tree
# into two separate build directories, then compares the resulting
# SHA256 hashes. Exits 0 if the two builds produce byte-identical binaries,
# non-zero otherwise.
#
# Usage:
# scripts/verify-reproducible-build.sh # default: trianglesd, Release
# BUILD_TYPE=Debug scripts/verify-reproducible-build.sh # override build type
# TARGET=triangles-qt scripts/verify-reproducible-build.sh # build Qt wallet instead
#
# What "reproducible" means here:
# Given identical source tree, identical compiler toolchain, identical
# build flags, identical SOURCE_DATE_EPOCH (if set) -- the resulting
# binary must hash identically across separate build directories.
#
# This script does NOT enforce compiler version pinning. Two different
# GCC versions will legitimately produce different binaries even with
# identical flags. The verification is "same source + same toolchain =
# same binary."
#
# Pass criteria:
# 1. Both builds succeed
# 2. Both binaries exist
# 3. SHA256 of the two binaries is equal
#
# On failure: prints the two SHA256s and the diff in size so a reviewer
# can investigate. Common causes of non-determinism:
# - __DATE__/__TIME__ embedded (we eliminate this in CMakeLists.txt)
# - absolute paths in __FILE__ (mitigated by -ffile-prefix-map)
# - uninitialized stack/heap contents (should not affect final binary)
# - linker adds random base addresses (PIE; deterministic if compiled
# with -fno-pie)
set -euo pipefail
# ── Config ─────────────────────────────────────────────────────────────────
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SOURCE_DIR="${SOURCE_DIR:-$(cd "$SCRIPT_DIR/.." && pwd)}"
BUILD_TYPE="${BUILD_TYPE:-Release}"
TARGET="${TARGET:-trianglesd}"
# Skip Qt by default -- it's slow and adds CI noise. Override with TARGET=triangles-qt
: "${BUILD_QT:=OFF}"
BUILD_DIR_A="${BUILD_DIR_A:-/tmp/triangles-repro-A}"
BUILD_DIR_B="${BUILD_DIR_B:-/tmp/triangles-repro-B}"
LOG_A="${LOG_A:-/tmp/triangles-repro-A.log}"
LOG_B="${LOG_B:-/tmp/triangles-repro-B.log}"
# ── Preflight ──────────────────────────────────────────────────────────────
command -v cmake >/dev/null || { echo "ERROR: cmake not found" >&2; exit 2; }
command -v ninja >/dev/null || { echo "ERROR: ninja not found (apt install ninja-build)" >&2; exit 2; }
command -v sha256sum >/dev/null || { echo "ERROR: sha256sum not found" >&2; exit 2; }
if [ ! -d "$SOURCE_DIR" ]; then
echo "ERROR: source dir not found: $SOURCE_DIR" >&2
exit 2
fi
# Refuse to run if the working tree is dirty -- dirty tree = non-deterministic
# git describe output = non-deterministic binary. Run on a clean checkout
# or a release tag.
if [ -n "$(cd "$SOURCE_DIR" && git status --porcelain 2>/dev/null)" ]; then
echo "WARNING: working tree has uncommitted changes." >&2
echo " build.h will include '-dirty' suffix and the binary will NOT be" >&2
echo " reproducible. Commit/stash your changes first, or accept that the" >&2
echo " hashes below prove your dirty-tree build is at least internally consistent." >&2
fi
# ── Helpers ────────────────────────────────────────────────────────────────
build_one() {
local dir="$1" log="$2"
rm -rf "$dir"
mkdir -p "$dir"
echo " configuring in $dir (BUILD_TYPE=$BUILD_TYPE BUILD_QT=$BUILD_QT)..." >&2
cmake -S "$SOURCE_DIR" -B "$dir" \
-DCMAKE_BUILD_TYPE="$BUILD_TYPE" \
-DBUILD_QT="$BUILD_QT" \
> "$log" 2>&1 || { echo " configure failed; see $log" >&2; tail -30 "$log" >&2; exit 3; }
echo " building target $TARGET..." >&2
cmake --build "$dir" --target "$TARGET" -j "$(nproc)" \
>> "$log" 2>&1 || { echo " build failed; see $log" >&2; tail -30 "$log" >&2; exit 3; }
# ONLY stdout of the find goes to the caller. Progress logs above
# were redirected to stderr so they don't pollute the captured path.
find "$dir" -name "$TARGET" -type f -executable | head -1
}
# ── Build twice ────────────────────────────────────────────────────────────
echo "Building $TARGET ($BUILD_TYPE) twice from $SOURCE_DIR..."
echo ""
BIN_A="$(build_one "$BUILD_DIR_A" "$LOG_A")"
BIN_B="$(build_one "$BUILD_DIR_B" "$LOG_B")"
if [ -z "$BIN_A" ] || [ -z "$BIN_B" ]; then
echo "ERROR: could not find built binary" >&2
echo " A: '$BIN_A'" >&2
echo " B: '$BIN_B'" >&2
exit 4
fi
# ── Compare ────────────────────────────────────────────────────────────────
HASH_A="$(sha256sum "$BIN_A" | awk '{print $1}')"
HASH_B="$(sha256sum "$BIN_B" | awk '{print $1}')"
SIZE_A="$(stat -c%s "$BIN_A" 2>/dev/null || stat -f%z "$BIN_A")"
SIZE_B="$(stat -c%s "$BIN_B" 2>/dev/null || stat -f%z "$BIN_B")"
echo ""
echo "Binary A: $BIN_A"
echo " sha256: $HASH_A"
echo " size: $SIZE_A bytes"
echo "Binary B: $BIN_B"
echo " sha256: $HASH_B"
echo " size: $SIZE_B bytes"
echo ""
if [ "$HASH_A" = "$HASH_B" ]; then
echo "✓ REPRODUCIBLE: both builds produced identical SHA256"
exit 0
else
echo "✗ NOT REPRODUCIBLE: hashes differ"
echo ""
echo "Likely causes:"
echo " - __DATE__/__TIME__ embedded (check src/version.cpp)"
echo " - absolute build paths in __FILE__ (check CMakeLists.txt for -ffile-prefix-map)"
echo " - dirty git tree (commit/stash and rerun)"
echo " - PIE base randomization (compile with -fno-pie -no-pie for testing)"
echo " - non-deterministic linker output (linker version mismatch)"
exit 1
fi