aien-receipts
Append-only AIEN verification receipts, indexed by repository and exact source commit. Read verdicts, signatures and retained logs before making a claim.
Brought by drakestapleton
aien-receipts / docs / verify-one-bundle.md
| 1 | # Verify one published bundle without the Spark |
| 2 | |
| 3 | This lesson uses an unchanged, public `aien-architecture` bundle. It does not run |
| 4 | its gates, sign anything, or need a model, GPU, Spark login, or private key. |
| 5 | **The official verifier recipe below is not yet reproduced in the documentation |
| 6 | review environment (Cargo is unavailable).** The separate, narrower OpenSSL |
| 7 | exercise was reproduced; it is not a substitute for `aien-test verify-bundle`. |
| 8 | |
| 9 | **Choose a route:** for full bundle verification follow steps 1 and 2. For the |
| 10 | signature-only exercise without Cargo, follow step 1 and then jump directly to |
| 11 | step 3, skipping every step 2 block (including its tampered-bundle commands). |
| 12 | The shell uses `set -e`, so a missing Cargo command otherwise stops the recipe. |
| 13 | |
| 14 | ## What was built, and why |
| 15 | |
| 16 | [ADR 0033, context and decisions 6/9/11](https://github.com/aien-dev/aien-architecture/blob/efbba982f5c095e3ae71c057b22faaafc11ed84d/docs/adr/0033-aien-verification-pipeline.md) |
| 17 | records the original problem: repeated hosted setup and tests that could not run |
| 18 | without Spark hardware, with no inbound path from GitHub to Spark. The chosen |
| 19 | mechanism publishes a signed bundle from the worker and lets an independent |
| 20 | consumer check it. This is the ADR's account, not a claim that this tutorial |
| 21 | reproduced that performance baseline. The ADR contains proposals as well as |
| 22 | implementation history; the pinned code below establishes what this lesson uses. |
| 23 | |
| 24 | The bundle names the repository, exact commit, executor, checks and verdict. The |
| 25 | Ed25519 signature covers the upstream canonical JSON with only the top-level |
| 26 | `signature` member removed. Reading the key and required gate list from the base |
| 27 | ref prevents a candidate change from authorizing its own key or dropping its own |
| 28 | requirements. A signature authenticates a statement under a trusted key; it does |
| 29 | not prove that the tests are sufficient, their implementation is correct, or that |
| 30 | hardware has been independently re-tested. A hosted bridge check going green is |
| 31 | not the Spark verdict of record, `AIEN Verification (Spark)`. |
| 32 | |
| 33 | Upstream implementation is AIEN's `aien-test` in `aien-sovereign-core` (copyright |
| 34 | Drake Stapleton / AIEN), using `ed25519-dalek` for strict signature verification, |
| 35 | `serde_json` for parsing and `sha2` for digests: |
| 36 | |
| 37 | - [`signed_bytes`, `verify`, CLI and refusal tests](https://github.com/aien-dev/aien-sovereign-core/blob/c26f4d7ac3156088469b27462390f5b08ef4f436/tools/aien-test/src/bundle.rs): |
| 38 | `verify` validates shape, trusted key, signature, repository, commit, executor |
| 39 | fingerprint, required checks and derived verdict, in that order. |
| 40 | - [`evidence::canonical` and golden encoding tests](https://github.com/aien-dev/aien-sovereign-core/blob/c26f4d7ac3156088469b27462390f5b08ef4f436/tools/aien-test/src/evidence.rs). |
| 41 | - [Base workflow, including its verifier pin and trust-anchor extraction](https://github.com/aien-dev/aien-architecture/blob/efbba982f5c095e3ae71c057b22faaafc11ed84d/.github/workflows/aien-verification.yml). |
| 42 | - [Existing pipeline explanation](https://github.com/aien-dev/aien-architecture/blob/efbba982f5c095e3ae71c057b22faaafc11ed84d/docs/PIPELINE.md). |
| 43 | |
| 44 | ## 1. Fetch exact inputs (network required) |
| 45 | |
| 46 | Use Bash on Linux, Git, Python 3, and standard `grep`, `paste`, `sha256sum` tools. |
| 47 | The official build additionally needs Cargo/Rust **1.98.1**, the pinned upstream |
| 48 | `rust-toolchain.toml` requirement, a native linker and the locked Cargo dependencies. |
| 49 | Obtain those through your normal trusted development setup; this lesson does not |
| 50 | install toolchains or download an executable. The optional signature exercise |
| 51 | needs OpenSSL 3 with Ed25519 support. No model weights or hardware setup is needed. |
| 52 | |
| 53 | Run all blocks in the same Bash shell. These are public HTTPS clones, with no |
| 54 | credential required. Stop on a failed checkout or fingerprint check. |
| 55 | |
| 56 | ```bash |
| 57 | set -eu |
| 58 | work=$(mktemp -d) |
| 59 | cd "$work" |
| 60 | SHELF=adac8533c922b676bfb12fbc83b047f19e28c0b9 |
| 61 | COMMIT=1a3594340c70969c245554b07062efd8ead8a026 |
| 62 | BASE=efbba982f5c095e3ae71c057b22faaafc11ed84d |
| 63 | VERIFIER=c26f4d7ac3156088469b27462390f5b08ef4f436 |
| 64 | |
| 65 | git clone https://github.com/aien-dev/aien-receipts.git shelf |
| 66 | git -C shelf checkout --detach "$SHELF" |
| 67 | git clone https://github.com/aien-dev/aien-architecture.git source |
| 68 | git -C source checkout --detach "$COMMIT" |
| 69 | git clone https://github.com/aien-dev/aien-sovereign-core.git verifier |
| 70 | git -C verifier checkout --detach "$VERIFIER" |
| 71 | |
| 72 | test "$(git -C source rev-parse HEAD^)" = "$BASE" |
| 73 | git -C source show "$BASE:.aien/verify.pub" > verify.pub |
| 74 | git -C source show "$BASE:.aien/always" > always |
| 75 | cp "shelf/aien-architecture/$COMMIT/bundle.json" bundle.json |
| 76 | printf '%s bundle.json\n' \ |
| 77 | cac84aa17376d4349e13d16ba935e349a24db421eaf44cb2bb6be2be5263612a \ |
| 78 | | sha256sum -c - |
| 79 | required=$(grep -v '^#' always | grep -v '^$' | paste -sd, -) |
| 80 | printf '%s\n' "$required" |
| 81 | cat verify.pub |
| 82 | ``` |
| 83 | |
| 84 | Expected output includes `bundle.json: OK`, then: |
| 85 | |
| 86 | ```text |
| 87 | CRUMB-VERIFY,ARCH-DOCTRINE,ARCH-QUALIFICATION-STATUS |
| 88 | 01368e0b02dc1113ae7425ad6ab00fdf5aa7dd97e0690745918a52f051d5cf68 |
| 89 | ``` |
| 90 | |
| 91 | Here `BASE` is the tested commit's parent on the source history, not a moving |
| 92 | `main` and not the candidate's key. This is an explicitly pinned historical trust |
| 93 | snapshot; it does not establish current key authorization or recreate every |
| 94 | historical branch-protection setting. For a new candidate use its actual trusted |
| 95 | base anchors. The shelf pin fixes the published file bytes, independently of the |
| 96 | source commit pin. Never use a key supplied only inside a bundle as a trust anchor. |
| 97 | |
| 98 | ## 2. Build the existing verifier, then verify offline |
| 99 | |
| 100 | The initial build may download locked dependencies. Review the pinned source and |
| 101 | its `Cargo.lock` as usual. `--locked` prevents silently updating dependency pins. |
| 102 | Once built, the verification and negative case below require no network. Build |
| 103 | from inside `verifier/` so Rust tooling selects its pinned `rust-toolchain.toml`. |
| 104 | |
| 105 | ```bash |
| 106 | (cd verifier && cargo build --locked --release -p aien-test) |
| 107 | AIEN_TEST="$work/verifier/target/release/aien-test" |
| 108 | "$AIEN_TEST" verify-bundle bundle.json \ |
| 109 | --repo github.com/aien-dev/aien-architecture --commit "$COMMIT" \ |
| 110 | --pubkey verify.pub --require "$required" |
| 111 | ``` |
| 112 | |
| 113 | Expected (from the pinned CLI and fixture; **not observed here**) is exit 0: |
| 114 | |
| 115 | ```text |
| 116 | AIEN Verification: PASS (3 checks, 3 required, 0 from cache) bundle cac84aa17376d4349e13d16ba935e349a24db421eaf44cb2bb6be2be5263612a |
| 117 | ``` |
| 118 | |
| 119 | The three declared checks are ARCH-DOCTRINE, ARCH-QUALIFICATION-STATUS and |
| 120 | CRUMB-VERIFY, all `run`, `EXACT`, required and PASS. These are signed declarations, |
| 121 | not new gate executions. Exit 1 means a verified FAIL verdict; exit 2 means NOT_RUN |
| 122 | (or usage/input error); exit 3 means REJECTED. Never interpret nonzero as PASS. |
| 123 | |
| 124 | ### Tamper refusal in a disposable copy |
| 125 | |
| 126 | This mirrors upstream `t11_tampered_verdict_is_rejected`. It changes only a scratch |
| 127 | copy, preserves the existing signature, and never writes into `shelf/`. |
| 128 | |
| 129 | ```bash |
| 130 | python3 - <<'PY' |
| 131 | import json |
| 132 | from pathlib import Path |
| 133 | b = json.loads(Path('bundle.json').read_bytes()) |
| 134 | b['checks'][0]['verdict'] = 'FAIL' |
| 135 | b['verdict'] = 'FAIL' |
| 136 | Path('tampered.json').write_text(json.dumps(b), encoding='utf-8') |
| 137 | PY |
| 138 | rc=0 |
| 139 | "$AIEN_TEST" verify-bundle tampered.json \ |
| 140 | --repo github.com/aien-dev/aien-architecture --commit "$COMMIT" \ |
| 141 | --pubkey verify.pub --require "$required" || rc=$? |
| 142 | printf 'tampered exit=%s\n' "$rc" |
| 143 | test "$rc" -eq 3 |
| 144 | ``` |
| 145 | |
| 146 | Expected (not observed here): `AIEN Verification: REJECTED BAD_SIGNATURE: signature |
| 147 | does not verify over the canonical bytes`, `tampered exit=3`. A refusal is the |
| 148 | success condition for this negative test. Do not sign the edited file or replace |
| 149 | the published receipt. The ordinary unit suite passing would not establish that |
| 150 | this real-bundle recipe was reproduced. |
| 151 | |
| 152 | ## 3. Optional: an observed signature-only experiment |
| 153 | |
| 154 | This small exercise works with the installed OpenSSL/Python tools when Cargo is |
| 155 | unavailable. It **does not implement a general JSON canonicalizer or bundle |
| 156 | verifier**, and must not be used as an admission gate. It checks only this exact |
| 157 | fixture's Ed25519 signature and one tampered byte sequence. It does not implement |
| 158 | `ed25519-dalek::verify_strict`'s full rejection behavior, schema validation, |
| 159 | required-gate checks, executor binding or verdict algebra. |
| 160 | |
| 161 | The fixture is already compact, sorted canonical JSON. After enforcing its exact |
| 162 | file SHA-256, remove the known top-level signature member's byte span, retaining |
| 163 | all other bytes unchanged as prescribed by upstream `signed_bytes`. The fixed |
| 164 | DER prefix below is the Ed25519 SubjectPublicKeyInfo wrapper for the 32-byte public |
| 165 | key; the key comes from `verify.pub`, not from the signature block. |
| 166 | |
| 167 | ```bash |
| 168 | python3 - <<'PY' |
| 169 | import hashlib, json |
| 170 | from pathlib import Path |
| 171 | raw = Path('bundle.json').read_bytes() |
| 172 | assert hashlib.sha256(raw).hexdigest() == ( |
| 173 | 'cac84aa17376d4349e13d16ba935e349a24db421eaf44cb2bb6be2be5263612a') |
| 174 | b = json.loads(raw) |
| 175 | key = Path('verify.pub').read_text().strip() |
| 176 | assert key == '01368e0b02dc1113ae7425ad6ab00fdf5aa7dd97e0690745918a52f051d5cf68' |
| 177 | assert b['signature']['pubkey'] == key |
| 178 | start = raw.index(b',"signature":') |
| 179 | end = raw.index(b',"started_utc":', start) |
| 180 | message = raw[:start] + raw[end:] |
| 181 | Path('message.bin').write_bytes(message) |
| 182 | Path('signature.bin').write_bytes(bytes.fromhex(b['signature']['sig'])) |
| 183 | Path('public.der').write_bytes(bytes.fromhex('302a300506032b6570032100' + key)) |
| 184 | assert b'"verdict":"PASS"' in message |
| 185 | Path('tampered-message.bin').write_bytes( |
| 186 | message.replace(b'"verdict":"PASS"', b'"verdict":"FAIL"', 1)) |
| 187 | PY |
| 188 | openssl pkeyutl -verify -pubin -keyform DER -inkey public.der \ |
| 189 | -rawin -in message.bin -sigfile signature.bin |
| 190 | rc=0 |
| 191 | openssl pkeyutl -verify -pubin -keyform DER -inkey public.der \ |
| 192 | -rawin -in tampered-message.bin -sigfile signature.bin || rc=$? |
| 193 | printf 'tampered signature exit=%s\n' "$rc" |
| 194 | test "$rc" -eq 1 |
| 195 | ``` |
| 196 | |
| 197 | Observed with Python 3.12.14 and OpenSSL 3.5.7 on Linux: original signature |
| 198 | `Signature Verified Successfully`, exit 0; tampered message `Signature Verification |
| 199 | Failure`, exit 1 (OpenSSL also emits a provider error diagnostic). This establishes |
| 200 | signature verification for those fixed bytes only. The official verifier's PASS |
| 201 | and BAD_SIGNATURE outputs above remain expected, not reproduced results. |
| 202 | |
| 203 | ## Review checklist |
| 204 | |
| 205 | Record OS/tool versions, pins, commands, output and exit codes in the PR. Keep |
| 206 | fetch/hash checks, the OpenSSL exercise, the official verifier and actual Spark |
| 207 | gate execution separate. If Rust or dependencies are unavailable, report that |
| 208 | blocker and leave full reproduction outstanding. No workflows run in this data |
| 209 | repository; do not add one to manufacture a green check. Remove the temporary |
| 210 | workspace when finished, never published receipts. |