Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/tests/checker2/owner_receipt.sh # omega-mv Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance. Brought by drakestapleton Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / tests / checker2 / owner_receipt.sh` 84 lines ยท 5377 bytes Raw Blame History 1 #!/bin/sh 2 # SPDX-License-Identifier: Apache-2.0 3 # Copyright 2026 Drake Stapleton (AIEN / aien-dev) 4 # 5 # Licensed under the Apache License, Version 2.0 (the "License"); 6 # you may not use this file except in compliance with the License. 7 # You may obtain a copy of the License at 8 # 9 # http://www.apache.org/licenses/LICENSE-2.0 10 # 11 # Unless required by applicable law or agreed to in writing, software 12 # distributed under the License is distributed on an "AS IS" BASIS, 13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 # See the License for the specific language governing permissions and 15 # limitations under the License. 16 17 # Positive production case for OWNER receipts (spec/one-layer-receipts.md section 11, omega#446): 18 # one receipt signed on Drake's YubiKey (owner root, PIV slot 9c) must be accepted by 19 # `checker2 receipt verify --production`, and its tampered copies refused. 20 # 21 # Fixtures (tests/checker2/fixtures/owner-receipt, PROVENANCE.txt): 22 # a01.ir, a01.code program and executable bytes of aienos osc_unit/vectors/a01_valid_min.unit 23 # a01.owner-draft.rcpt `receipt issue --owner-draft` output: OWNER class, all-zero signature 24 # a01.owner-draft.tbs `receipt tbs` output: the 65 bytes the YubiKey signs 25 # a01.owner.sig the 64-byte Ed25519 signature made on the YubiKey (Drake) 26 # a01.owner.rcpt `receipt attach` output: the signed receipt 27 # Checks: the draft and the message are rebuilt by this checker2 and must be byte-identical (a changed 28 # checker identity changes them, and the signed receipt must then be made again); the signed receipt is 29 # the draft with exactly the committed signature in bytes [352, 416); production verify says VALID; 30 # controls: a changed signature byte, a changed program hash, a wrong target, an expired epoch, a 31 # revoked owner key and a wrong executable are each refused with their named reason. 32 # Until the signature is committed the test FAILS with OWNER-RECEIPT PENDING: the gap stays visible. 33 # Usage: owner_receipt.sh 34 set -u 35 C2=$1 F=$2 W=$3 36 TARGET=aienos-ck-aarch64-el0 EPOCH=20 EXPIRY=100 FLOOR=10 37 OWNER_FP=$(od -An -tx1 -j320 -N32 "$F/a01.owner-draft.rcpt" | tr -d ' \n') # key fingerprint written by issue 38 rm -rf "$W" && mkdir -p "$W" || exit 2 39 fail=0 ctl=0 40 bad() { echo "owner_receipt: FAIL $*"; fail=$((fail + 1)); } 41 42 "$C2" receipt issue "$F/a01.ir" "$F/a01.code" --target $TARGET --epoch $EPOCH --expiry $EXPIRY \ 43 --owner-draft "$W/draft.rcpt" || bad "issue --owner-draft" 44 cmp -s "$W/draft.rcpt" "$F/a01.owner-draft.rcpt" || bad "owner draft is not byte-identical to the committed draft" 45 "$C2" receipt tbs "$F/a01.owner-draft.rcpt" "$W/tbs" || bad "tbs" 46 cmp -s "$W/tbs" "$F/a01.owner-draft.tbs" || bad "signed message is not byte-identical to the committed one" 47 48 if [ ! -f "$F/a01.owner.rcpt" ] || [ ! -f "$F/a01.owner.sig" ]; then 49 echo "owner_receipt: OWNER-RECEIPT PENDING: no YubiKey-signed receipt committed yet (~/bin/owner-sign-receipt-test.sh)" 50 exit 1 51 fi 52 [ "$(wc -c <"$F/a01.owner.rcpt")" = 416 ] || bad "signed receipt is not 416 bytes" 53 [ "$(wc -c <"$F/a01.owner.sig")" = 64 ] || bad "signature is not 64 bytes" 54 head -c 352 "$F/a01.owner.rcpt" >"$W/head.signed" 55 head -c 352 "$F/a01.owner-draft.rcpt" >"$W/head.draft" 56 cmp -s "$W/head.signed" "$W/head.draft" || bad "signed receipt differs from the draft in the signed bytes" 57 tail -c 64 "$F/a01.owner.rcpt" | cmp -s - "$F/a01.owner.sig" || bad "signed receipt does not carry the committed signature" 58 # attach again from the committed draft and signature: verifies against the compiled-in owner root 59 mkdir -p "$W/store" 60 "$C2" receipt attach "$F/a01.owner-draft.rcpt" "$F/a01.owner.sig" --out-dir "$W/store" >"$W/attach.out" || bad "attach refuses the committed signature" 61 cmp -s "$(sed -n 's/^receipt=//p' "$W/attach.out" | cut -d' ' -f1)" "$F/a01.owner.rcpt" || bad "attach does not rebuild the committed receipt" 62 63 v() { "$C2" receipt verify "$1" "$F/a01.ir" "${2:-$F/a01.code}" --target "${3:-$TARGET}" --epoch "${4:-$EPOCH}" --floor $FLOOR $5; } 64 out=$(v "$F/a01.owner.rcpt" "" "" "" --production) 65 [ "$out" = receipt=VALID ] || bad "production verify: $out" 66 out=$(v "$F/a01.owner.rcpt" "" "" "" "") 67 [ "$out" = receipt=VALID ] || bad "default (production) verify: $out" 68 69 # expect NAME WANT RECEIPT EXE TARGET EPOCH EXTRA (empty: the default) 70 expect() { 71 n=$1 want=$2; shift 2 72 got=$(v "$@") 73 if [ "$got" = "receipt=$want" ]; then ctl=$((ctl + 1)); else bad "control $n: want $want, got $got"; fi 74 } 75 flip() { cat "$F/a01.owner.rcpt" >"$2"; printf '\377' | dd of="$2" bs=1 seek="$1" conv=notrunc status=none; } 76 flip 400 "$W/sig.flip"; expect signature-byte BAD_SIGNATURE "$W/sig.flip" "" "" "" --production 77 flip 48 "$W/prog.flip"; expect program-hash BAD_SIGNATURE "$W/prog.flip" "" "" "" --production 78 expect wrong-target WRONG_TARGET "$F/a01.owner.rcpt" "" aarch64-linux-host "" --production 79 expect expired EXPIRED "$F/a01.owner.rcpt" "" "" $((EXPIRY + 1)) --production 80 expect revoked-key REVOKED "$F/a01.owner.rcpt" "" "" "" "--production --revoked-key $OWNER_FP" 81 expect wrong-executable EXECUTABLE_MISMATCH "$F/a01.owner.rcpt" "$F/a01.ir" "" "" --production 82 83 if [ "$fail" -ne 0 ]; then echo "owner_receipt: FAIL ($fail)"; exit 1; fi 84 echo "owner_receipt: PASS owner-signed receipt VALID in production, $ctl controls refused"