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
omega-mv / spec / one-layer-receipts.md
| 1 | # One-layer receipts v1: signed Omega realization receipts (normative) |
| 2 | |
| 3 | Stage 3 of the one-layer plan (omega#446). Code: `src/checker2/` (receipts `c2_receipt.{h,c}`, |
| 4 | IR decoder `c2_ir.{h,c}`, acceptance rules `c2_check.c`, LRAT checker `c2_lrat.{h,c}`, bit-blaster |
| 5 | `c2_blast.{h,c}`, command line `checker2_main.c`). Tests: `make test-checker2` (section 12). |
| 6 | Pairs with aienos#383 (OSC unit admission), which must verify exactly these bytes. |
| 7 | |
| 8 | ## 1. What a receipt says, and what it does not |
| 9 | |
| 10 | A receipt records that **checker2** (the independent checker in `src/checker2/`) judged one |
| 11 | exact set of bytes and accepted them, and that a key of a stated signer class vouches for that |
| 12 | record. The signature establishes provenance only. It never establishes correctness, and a |
| 13 | receipt grants no capability: aienos grants stay separate, revocable authority. |
| 14 | |
| 15 | A receipt is minted only by `checker2 receipt issue`, which runs checker2 on the program bytes |
| 16 | itself and refuses to sign when checker2 rejects. Nothing else in Omega writes receipts. |
| 17 | |
| 18 | ## 2. Byte layout (416 bytes, little-endian, no padding, no text, no timestamps) |
| 19 | |
| 20 | | offset | size | field | |
| 21 | |---:|---:|---| |
| 22 | | 0 | 8 | magic `O M R C P T 1 \0` | |
| 23 | | 8 | 2 | format version, = 1 | |
| 24 | | 10 | 2 | signer class: 1 TEST, 2 OWNER (same numbers as aienos `OSC_SIGNER_TEST`/`OSC_SIGNER_OWNER`) | |
| 25 | | 12 | 2 | signature algorithm, = 1 (pure Ed25519, RFC 8032 section 5.1) | |
| 26 | | 14 | 2 | evidence class (section 4) | |
| 27 | | 16 | 32 | requirements: SHA-256 of the requirements object bytes (all zero: none supplied) | |
| 28 | | 48 | 32 | program: SHA-256 of the canonical program bytes (OSC IR; equals `oscc` `ir_sha256`) | |
| 29 | | 80 | 32 | executable: SHA-256 of the realized executable bytes (equals `oscc` `code_sha256`) | |
| 30 | | 112 | 32 | dependencies: SHA-256(`"OMEGA-RECEIPT-DEPS-V1\0"` ‖ u32 count ‖ receipt ids, strictly ascending) | |
| 31 | | 144 | 32 | checker: identity of the checker2 build (section 5) | |
| 32 | | 176 | 32 | producer checker: SHA-256 of the `oscc` binary that produced the bytes | |
| 33 | | 208 | 32 | target: SHA-256(`"OMEGA-TARGET-V1\0"` ‖ target name), e.g. `aarch64-linux-host` | |
| 34 | | 240 | 32 | firmware: SHA-256 of the firmware image; all zero = none (host) | |
| 35 | | 272 | 32 | input: SHA-256 of the input or dataset identity; all zero = none | |
| 36 | | 304 | 8 | policy epoch the receipt was issued under | |
| 37 | | 312 | 8 | expiry epoch: last epoch at which it is fresh; must be >= policy epoch | |
| 38 | | 320 | 32 | key fingerprint: SHA-256 of the signer's 32-byte Ed25519 public key | |
| 39 | | 352 | 64 | Ed25519 signature | |
| 40 | |
| 41 | "\0" is one zero byte, included in the hash. Receipt id = SHA-256 of all 416 bytes. Ed25519 |
| 42 | signatures are deterministic, so the same inputs and key always give the same receipt and id. |
| 43 | |
| 44 | ## 3. Signature |
| 45 | |
| 46 | Signed message (65 bytes) = `"OMEGA-REALIZATION-RECEIPT-SIG-V1\0"` ‖ |
| 47 | SHA-256(`"OMEGA-REALIZATION-RECEIPT-V1\0"` ‖ bytes [0, 352)). |
| 48 | |
| 49 | The verifier takes the public key from its own anchor set for the receipt's class, matched by |
| 50 | fingerprint, never from the receipt (same rule as aienos `osc_unit_admit` step 13). |
| 51 | |
| 52 | ### Keys |
| 53 | |
| 54 | - **OWNER** (class 2): Drake's owner root from the aienos#380 ceremony, |
| 55 | `578ada3cb0c2d154623ac089191023c8ad4bc5e63b8ccd1a38db2d679b8c9e76`, generated on a YubiKey |
| 56 | (PIV slot 9c). Compiled in as `c2r_owner_root_pk`. Omega never holds the private key: |
| 57 | `checker2 receipt tbs` writes the 65-byte message, the YubiKey signs it, and |
| 58 | `checker2 receipt attach` verifies and attaches the signature. The test suite proves the |
| 59 | constant is the ceremony key by verifying the real ceremony signature |
| 60 | (`tests/checker2/fixtures/owner/`, public data). |
| 61 | - **TEST** (class 1): seed = SHA-256(`"OMEGA-CHECKER2-TEST-KEY-v1 NOT FOR PRODUCTION"`), public |
| 62 | on purpose. `c2r_sign_test` signs with this key only and only TEST class. |
| 63 | |
| 64 | ## 4. Evidence class |
| 65 | |
| 66 | | value | name | meaning | |
| 67 | |---:|---|---| |
| 68 | | 1 | IR_CHECKED | checker2 decoded the canonical program bytes and accepted them. The executable is bound by hash only; it is **not** translation-validated against the program. | |
| 69 | | 2 | IR_CHECKED_LRAT | as 1, plus a declared property proved by an LRAT certificate that checker2's own LRAT checker accepted | |
| 70 | |
| 71 | Any other value is refused. |
| 72 | |
| 73 | ## 5. Checker identity |
| 74 | |
| 75 | `checker` = SHA-256(`C2_CHECKER_VERSION` including its terminating NUL ‖ the 64 lowercase hex |
| 76 | characters of SHA-256 over the concatenation of the checker2 sources in the fixed order of |
| 77 | `C2_ID_SRCS` in `mk/checker2.mk`). The sources include the IR decoder, the acceptance rules, the |
| 78 | LRAT checker, the bit-blaster, the receipt code and the command line; the untrusted solver |
| 79 | (`src/checker2/untrusted/`) is deliberately outside. `checker2 version` prints the version, |
| 80 | `sources_sha256` and `checker_id`. A changed checker gives a new identity. The verifier holds a list of |
| 81 | accepted checker identities in its policy (`C2ReceiptPolicy.checkers`); the list is required and an |
| 82 | empty list refuses every receipt. `checker2 receipt verify` accepts its own identity plus any given |
| 83 | with `--accept-checker`. |
| 84 | |
| 85 | ## 6. Verification order and named reasons |
| 86 | |
| 87 | The verifier stops at the first failure and returns its reason. Codes are stable. |
| 88 | |
| 89 | 1. Structure: `SIZE` (1, not exactly 416 bytes), `MAGIC` (2), `VERSION` (3), |
| 90 | `SIGNATURE_ALGORITHM` (4), `SIGNER_CLASS` (5), `EVIDENCE_CLASS` (6), `EPOCH_ORDER` (7). |
| 91 | Code 8 is unassigned. |
| 92 | 2. Class policy: in production mode any class other than OWNER is `TEST_SIGNER_IN_PRODUCTION` |
| 93 | (9). The key must be in the anchor set of the receipt's class, else `UNTRUSTED_SIGNER` (10); |
| 94 | in production the only owner anchor honoured is the compiled-in owner root; a key anchored in |
| 95 | both classes is refused (`UNTRUSTED_SIGNER`). |
| 96 | 3. Signature: `BAD_SIGNATURE` (11). |
| 97 | 4. Revocation: receipt id, then signer key fingerprint, in the verifier's revocation lists: |
| 98 | `REVOKED` (12). |
| 99 | 5. Freshness (epochs, no clock): policy epoch below the verifier's floor is a replay of a |
| 100 | superseded receipt, `STALE_EPOCH` (13); current epoch above expiry `EXPIRED` (14); current |
| 101 | epoch below the policy epoch `NOT_YET_VALID` (15). The window is inclusive at both ends. |
| 102 | 6. Checker identity: the receipt's `checker` must be in the verifier's list of accepted checker |
| 103 | identities (section 5), else `UNTRUSTED_CHECKER` (22). The list is part of the policy and is |
| 104 | checked with or without expectations. |
| 105 | 7. Binding to what is being admitted: `WRONG_TARGET` (16), `WRONG_FIRMWARE` (17), |
| 106 | `PROGRAM_MISMATCH` (18), `EXECUTABLE_MISMATCH` (19), `WRONG_PRODUCER` (23, producer checker |
| 107 | identity), `DEPENDENCIES_MISMATCH` (24, dependency digest). The dependency digest binds the |
| 108 | dependency receipt ids only: v1 does not fetch, resolve or verify the dependency receipts |
| 109 | themselves (section 11). |
| 110 | |
| 111 | `ARGUMENT` (20) and `KEY_CLASS` (21, signing refused) are tool and signing errors. |
| 112 | |
| 113 | The revocation lists, the epoch floor and the current epoch come from the admitting side's |
| 114 | policy (for aienos: its own authority), never from the receipt. |
| 115 | |
| 116 | ## 7. Storage: content-addressed, never rewritten |
| 117 | |
| 118 | `checker2 receipt issue --out-dir D` writes `D/<id hex>.rcpt` with exclusive create. If the file |
| 119 | already exists with identical bytes the write is a no-op; any other existing content is an error, |
| 120 | never an overwrite. |
| 121 | |
| 122 | ## 8. Command line |
| 123 | |
| 124 | checker2 check <unit.ir> |
| 125 | checker2 version |
| 126 | checker2 receipt issue <unit.ir> <exe> --target T --epoch E --expiry X |
| 127 | (--out-dir D | --owner-draft PATH) |
| 128 | [--firmware F] [--requirements R | --lrat FUNC=PROOF ...] |
| 129 | [--input I] [--producer P] [--dep ID ...] |
| 130 | checker2 receipt tbs <receipt> <out65> |
| 131 | checker2 receipt attach <receipt> <sig64> --out-dir D |
| 132 | checker2 receipt verify <receipt> <unit.ir> <exe> --target T --epoch E |
| 133 | [--allow-test-key | --production] [--floor N] [--firmware F] |
| 134 | [--revoked-id ID ...] [--revoked-key FP ...] [--lrat FUNC=PROOF ...] |
| 135 | [--producer P] [--dep ID ...] [--accept-checker ID ...] |
| 136 | checker2 prove-cnf <unit.ir> <func> <out.cnf> |
| 137 | checker2 prove-check <unit.ir> <func> <proof.lrat> |
| 138 | |
| 139 | Exit 0 accept or done, 1 reject or refused, 2 usage or I/O error. `issue` refuses to sign bytes |
| 140 | checker2 rejects. `verify` applies the production policy by default (fail closed): a TEST-class |
| 141 | receipt is refused as `TEST_SIGNER_IN_PRODUCTION` unless `--allow-test-key` is given, which only |
| 142 | qualification and test runs may do; `--production` states the default, and giving both is a usage |
| 143 | error. `--dep` ids must be strictly ascending (their digest is order-sensitive). `verify` always |
| 144 | compares the producer and dependency digests: no `--producer` means an all-zero producer and no |
| 145 | `--dep` means an empty dependency list, exactly what `issue` writes without them. |
| 146 | |
| 147 | Owner signing, without Omega ever holding the private key: `issue --owner-draft PATH` writes an |
| 148 | OWNER-class receipt with the owner root fingerprint and an all-zero signature; `tbs` writes the |
| 149 | 65-byte message of section 3; Drake signs it on the YubiKey (PIV slot 9c); `attach` verifies the |
| 150 | signature against the compiled-in owner root and stores the signed receipt by id (section 7). |
| 151 | |
| 152 | ## 9. What checker2 accepts, and what it was written from |
| 153 | |
| 154 | checker2 decodes the canonical OSC IR bytes itself and applies its own acceptance rules. It links |
| 155 | no file of `src/compiler/` and shares no parser, evaluator or instruction table with the producer |
| 156 | (oscc). Its sources were written from these inputs only; no existing checker implementation |
| 157 | (`src/compiler/osc_check.*` or any other) was read: |
| 158 | |
| 159 | - `src/compiler/osc_ir.h`: the IR data structures, opcodes, scalar kinds and trap codes |
| 160 | (lines 152 to 176); the encoder part of `src/compiler/osc_ir.c` (lines 537 to 729), read for the |
| 161 | exact byte layout only, as the IR format has no separate written specification; |
| 162 | - `src/compiler/osc_front.h` (front-end interface, used by the test producer only); |
| 163 | - `docs/osc/` (OSC-1 design, including the semantics in section 5 of `OSC-1-DESIGN.md`); |
| 164 | - `src/omega_receipt.h`, `src/omega_vc_bridge.h`, `src/searchtrace/sig/*.h`, `src/sha256.h`; |
| 165 | - aienos `osc_unit.c` (the admission side's receipt rules, step 13); |
| 166 | - the build files under `mk/`. |
| 167 | |
| 168 | Every rejection names a stable rule (`C2-*`, listed in `c2_check.c`). Acceptance requires, per |
| 169 | function: valid types and operands; well-formed control flow; every use defined on every path; |
| 170 | ownership, arena, pool and handle discipline (a may-set analysis: use-after-release, double release |
| 171 | and double close are rejected when they hold on every path; a heap owner or pool still live at a |
| 172 | return, or overwritten while live, is rejected when that holds on some path (omega#465), with |
| 173 | drop-flag branches followed by the flag's value so a conditional release is not a false leak; arena |
| 174 | objects keep the every-path rule because `ADESTROY` reclaims them); mutable-borrow exclusivity |
| 175 | (`C2-BORROW-MUT-ALIAS`, omega#465: a register is not used while a mutable borrow taken from it, |
| 176 | directly or through a copy, is still live, on some path; a shared borrow used while a mutable borrow |
| 177 | of the same object is live, and a mutable borrow whose owner was moved to another register, are outside |
| 178 | this rule); |
| 179 | every loop reducible and bounded by a guarded counter with a constant limit of at most 10^6. |
| 180 | |
| 181 | ## 10. Evidence class 2: LRAT proofs |
| 182 | |
| 183 | Property `no-trap-except-requires` of a function F: for every argument value, a run of F that |
| 184 | passes its `requires` clauses ends without any trap (overflow, division, shift, cast, loop bound, |
| 185 | `ensures`, or an explicit trap). checker2 builds the CNF of "some argument reaches a trap" itself, |
| 186 | from the IR bytes (`c2_blast.h`: scalar functions only; calls, memory, division and signed right |
| 187 | shift are refused, never approximated). The solver (`src/checker2/untrusted/c2sat.om`, pure seeded OM-2) is |
| 188 | untrusted and outside the checker identity. An UNSAT answer counts only when checker2's own LRAT |
| 189 | checker (`c2_lrat.h`: RUP steps only, RAT hints refused, the empty clause required, |
| 190 | clause ids at most input clauses plus proof lines so a huge id cannot size its tables) accepts the |
| 191 | proof against the CNF checker2 rebuilt. |
| 192 | |
| 193 | With `--lrat FUNC=PROOF` (functions strictly ascending), `issue` checks every proof and sets |
| 194 | evidence class 2 with `requirements` = SHA-256 of the requirements object: |
| 195 | |
| 196 | OMEGA-REQUIREMENTS-V1\n |
| 197 | no-trap-except-requires <FUNC> proof_sha256=<64 hex>\n (one line per proof) |
| 198 | |
| 199 | `verify` replays: a class 2 receipt is valid only when the same proofs are given, each checks |
| 200 | against the IR bytes, and the rebuilt object hashes to `requirements`. Reasons: `LRAT-PROOFS-REQUIRED`, |
| 201 | `LRAT-REPLAY-FAILED`, `LRAT-REQUIREMENTS-MISMATCH`, and `LRAT-NOT-CLAIMED` (proofs offered for a |
| 202 | class 1 receipt). Proofs are deterministic: the solver writes byte-identical proofs on every run. |
| 203 | |
| 204 | ## 11. Not covered (open) |
| 205 | |
| 206 | - Translation validation of the executable against the program (plan section 3) is not done; |
| 207 | evidence classes 1 and 2 say so in their definitions. |
| 208 | - Production acceptance of an OWNER receipt: VERIFIED for one positive case. Receipt a01 was signed |
| 209 | on Drake's YubiKey (serial 39017074, PIV slot 9c, owner root 578ada3c...9e76) on 2026-10-15T00:02:50Z; |
| 210 | `checker2 receipt verify --production` accepts it, openssl verifies the Ed25519 signature against the |
| 211 | ceremony public key, and six tampered controls are refused (`make test-checker2-owner-receipt`, |
| 212 | fixtures in tests/checker2/fixtures/owner-receipt). The aienos kernel verifier accepts it under an owner |
| 213 | policy; the shipped aienos release policy does not yet carry an owner receipt anchor, so it reports |
| 214 | UNTRUSTED_SIGNER there. Adding that anchor is aienos work and is UNVERIFIED. |
| 215 | - The admission side (aienos#383, merged in aienos#384) verifies exactly these bytes. |
| 216 | - Dependency receipts are not resolved in v1: the `dependencies` digest binds their ids, and a |
| 217 | verifier can require the expected ids (`DEPENDENCIES_MISMATCH`), but no verifier fetches the |
| 218 | dependency receipts or checks their validity, class or freshness. UNVERIFIED for any chain. |
| 219 | - `src/omega_vc_bridge.h` still self-mints HOST_TEST receipts. That route admits OmegaProgram |
| 220 | programs (`omega_program_ir.h`), not OSC IR, and records an aien-proof EvidenceReceiptV1 |
| 221 | (`src/omega_receipt.h`, contract owned by aien-protocols). Replacing it needs checker2 to judge |
| 222 | that IR (or those programs to arrive as OSC) and a change to that shared contract; neither is |
| 223 | in this change. |
| 224 | - A differential of the planted IR defects against the producer's checker needs an IR-bytes entry |
| 225 | point on the producer side (omega#444); until then those 96 defects are judged by checker2 only. |
| 226 | - Bit-blaster semantics are cross-checked against oscc's compiled AArch64 code (section 12, |
| 227 | `blast_native.sh`), not against an independent reference interpreter. Agreement shows checker2's |
| 228 | CNF and the producer's back end read section 5 of OSC-1-DESIGN the same way; a misreading shared |
| 229 | by both would pass. Operands wider than 16 bits are checked on edge values and samples, not |
| 230 | exhaustively; gate programs are compared on trap or no trap only, not on return values. UNVERIFIED |
| 231 | beyond those inputs. |
| 232 | |
| 233 | ## 12. Tests |
| 234 | |
| 235 | `make test-checker2` (CI job `checker2` in `.github/workflows/host-suites.yml`): |
| 236 | |
| 237 | - `test_c2_receipt` (plain and ASan/UBSan): signing, every named refusal, tampered bytes, wrong |
| 238 | key, TEST key in production mode, checker identity not in the policy list (and an empty list), |
| 239 | wrong producer and dependency digests, the real owner ceremony signature; |
| 240 | - `differential.sh`: every OSC unit in the repo plus 48 generated units, oscc run as a black box; |
| 241 | both must accept the same 107 units with identical bytes, and the known-bad units must be |
| 242 | refused (138 by the front end); |
| 243 | - `test_c2_ir` (plain and ASan/UBSan): 107 units re-encode identically, every truncation refused, |
| 244 | bit flips never crash, 96 planted defects each refused by its exact rule; |
| 245 | - `test_c2_lrat` (plain and ASan/UBSan): hand-written LRAT cases, each refusal by its exact rule |
| 246 | (including a huge clause id refused as `LRAT-ID-RANGE` without a large allocation), 20000 |
| 247 | corrupted proofs never verify a satisfiable formula; |
| 248 | - `lrat.sh`: 20 bounded programs proved and replayed, 9 trap programs found to trap, 56 receipt and |
| 249 | proof controls (corrupted, substituted or misapplied proofs and receipts refused, including a |
| 250 | TEST receipt under the default production policy, a receipt from another checker identity unless |
| 251 | accepted with `--accept-checker`, and a wrong producer or dependency digest); |
| 252 | - `test_c2_blast`: non-scalar functions refused; every gate program evaluated input by input |
| 253 | without a solver (exhaustive to 16 argument bits), agreeing with its expectation; |
| 254 | - `blast_native.sh` + `test_c2_blast_native` (AArch64 host): 180 one-operation programs (every |
| 255 | blastable operation, comparison, cast pair and unary operation on every integer type and bool) and |
| 256 | the 29 gate programs, compiled by oscc as a black box; for every input (exhaustive to 16 operand |
| 257 | bits, else edge values and 3000 samples) checker2's CNF must agree with the compiled code on the |
| 258 | trap and, through an `ensures result != c` probe, on the exact result value; 8 negative controls |
| 259 | (the CNF of one operation against the code of another) must disagree; |
| 260 | - `owner_receipt.sh`: the positive production case of section 11. The committed OWNER draft and its |
| 261 | 65-byte message (`tests/checker2/fixtures/owner-receipt`, PROVENANCE.txt) are rebuilt and must be |
| 262 | byte-identical; the receipt signed once on Drake's YubiKey must verify `--production`, and a changed |
| 263 | signature byte, a changed program hash, a wrong target, an expired epoch, a revoked owner key and a |
| 264 | wrong executable must each be refused. It fails `OWNER-RECEIPT PENDING` until that signature is committed; |
| 265 | - `mutants.sh`: each line tagged `GUARD:<name>` in the receipt code, decoder, acceptance rules, |
| 266 | LRAT checker and bit-blaster is removed in turn; a test must fail every time (104 of 104); the script also refuses a tag count that differs |
| 267 | from the mutant count. |