interplane.Get Omega
Read in your language

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

branch main Branches Tags History

aien-receipts / docs / verify-one-bundle.md

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