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/src/checker2/c2_receipt.h # 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 / src / checker2 / c2_receipt.h` 161 lines ยท 9033 bytes Raw Blame History 1 /* SPDX-License-Identifier: Apache-2.0 2 * Copyright 2026 Drake Stapleton (AIEN / aien-dev) 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 /* c2_receipt: signed Omega realization receipts, format v1 (spec/one-layer-receipts.md, normative). 18 * 19 * A receipt is 416 bytes, fixed layout, little-endian, no text, no timestamps. It binds one 20 * checker2 verdict to the exact bytes it judged (requirements, canonical program bytes, executable 21 * bytes, dependencies, checker identities, evidence class, target, firmware, input identity) and a 22 * policy-epoch window, and carries a pure Ed25519 signature (RFC 8032 section 5.1) made by a key of 23 * one signer class: TEST (class 1, automated tests only) or OWNER (class 2, Drake's owner root, held 24 * on a YubiKey; this code never sees that private key). The class numbers equal aienos 25 * native/kernel/artifact/osc_unit.h OSC_SIGNER_TEST / OSC_SIGNER_OWNER. 26 * 27 * A signature establishes provenance (who vouched), never correctness. A receipt grants no 28 * capability. Receipt identity = SHA-256 of all 416 bytes; a receipt is never rewritten. 29 * 30 * No heap, no clock, no I/O in this file (the store and the tool live in c2_receipt_tool.c). */ 31 #ifndef C2_RECEIPT_H 32 #define C2_RECEIPT_H 33 34 #include 35 #include 36 37 #define C2R_SIZE 416u 38 #define C2R_SIGNED_LEN 352u /* bytes [0, 352) are covered by the signature */ 39 #define C2R_FORMAT_VERSION 1u 40 #define C2R_ALG_ED25519 1u 41 42 enum { C2R_CLASS_TEST = 1, C2R_CLASS_OWNER = 2 }; 43 44 /* Evidence class: what checker2 actually did before the receipt was signed. */ 45 enum { 46 C2R_EV_IR_CHECKED = 1, /* checker2 decoded the canonical bytes and accepted them; 47 the executable is bound by hash, NOT translation-validated */ 48 C2R_EV_IR_CHECKED_LRAT = 2 /* as 1, plus an LRAT-checked proof of the declared property */ 49 }; 50 51 typedef struct { 52 uint16_t version; /* C2R_FORMAT_VERSION */ 53 uint16_t signer_class; /* C2R_CLASS_* */ 54 uint16_t alg; /* C2R_ALG_ED25519 */ 55 uint16_t evidence_class; /* C2R_EV_* */ 56 uint8_t requirements[32]; /* SHA-256 of the requirements object bytes */ 57 uint8_t program[32]; /* SHA-256 of the canonical program bytes (OSC IR) */ 58 uint8_t executable[32]; /* SHA-256 of the realized executable bytes */ 59 uint8_t dependencies[32]; /* c2r_deps_digest over the dependency receipt ids */ 60 uint8_t checker[32]; /* identity of the checker2 build that judged */ 61 uint8_t producer_checker[32]; /* identity of the producer's checker (oscc binary hash) */ 62 uint8_t target[32]; /* c2r_target_id(target name) */ 63 uint8_t firmware[32]; /* SHA-256 of the firmware image, all zero = none (host) */ 64 uint8_t input[32]; /* SHA-256 of the input / dataset identity, zero = none */ 65 uint64_t policy_epoch; /* epoch the receipt was issued under */ 66 uint64_t expiry_epoch; /* last epoch at which it is fresh (>= policy_epoch) */ 67 uint8_t key_fp[32]; /* SHA-256 of the signer's 32-byte Ed25519 public key */ 68 uint8_t sig[64]; 69 } C2Receipt; 70 71 /* Named verdicts. 0 is the only acceptance. Values are part of the spec; never renumbered. */ 72 enum { 73 C2R_OK = 0, 74 C2R_E_SIZE = 1, /* not exactly 416 bytes */ 75 C2R_E_MAGIC = 2, 76 C2R_E_VERSION = 3, 77 C2R_E_ALG = 4, 78 C2R_E_CLASS = 5, /* signer class not TEST or OWNER */ 79 C2R_E_EVIDENCE = 6, /* unknown evidence class */ 80 C2R_E_EPOCH_ORDER = 7, /* expiry_epoch < policy_epoch */ 81 /* 8 is unassigned (format v1 has no reserved bytes) */ 82 C2R_E_TEST_IN_PRODUCTION = 9, 83 C2R_E_UNTRUSTED_SIGNER = 10, /* key fingerprint not in the anchor set of its class */ 84 C2R_E_BAD_SIGNATURE = 11, 85 C2R_E_REVOKED = 12, /* receipt id or signer key fingerprint is revoked */ 86 C2R_E_STALE = 13, /* policy_epoch below the verifier's floor: replay of a superseded receipt */ 87 C2R_E_EXPIRED = 14, /* current epoch past expiry_epoch */ 88 C2R_E_NOT_YET_VALID = 15, /* current epoch before policy_epoch */ 89 C2R_E_WRONG_TARGET = 16, 90 C2R_E_WRONG_FIRMWARE = 17, 91 C2R_E_PROGRAM_MISMATCH = 18, 92 C2R_E_EXECUTABLE_MISMATCH = 19, 93 C2R_E_ARG = 20, 94 C2R_E_KEY_CLASS = 21, /* signing: key not allowed for the requested class */ 95 C2R_E_UNTRUSTED_CHECKER = 22, /* checker identity not in the verifier's checker list */ 96 C2R_E_WRONG_PRODUCER = 23, /* producer checker identity differs from the expected one */ 97 C2R_E_DEPS_MISMATCH = 24 /* dependency digest differs from the expected one */ 98 }; 99 const char *c2r_reason(int code); 100 101 /* Verifier policy. Anchors are raw 32-byte Ed25519 public keys; the key used is always taken from 102 * the anchor set of the receipt's class, never from the receipt. production = 1 refuses TEST class 103 * outright and accepts only the anchors in owner_anchors. */ 104 typedef struct { 105 int production; 106 const uint8_t (*test_anchors)[32]; unsigned n_test; 107 const uint8_t (*owner_anchors)[32]; unsigned n_owner; 108 const uint8_t (*revoked_ids)[32]; unsigned n_revoked_ids; /* receipt ids */ 109 const uint8_t (*revoked_keys)[32]; unsigned n_revoked_keys; /* key fingerprints */ 110 /* checker2 identities (section 5) whose verdicts this verifier accepts. Required: an empty or 111 * NULL list refuses every receipt (C2R_E_UNTRUSTED_CHECKER), so a policy cannot forget it. */ 112 const uint8_t (*checkers)[32]; unsigned n_checkers; 113 uint64_t epoch_floor; /* receipts issued under an older epoch are refused (C2R_E_STALE) */ 114 uint64_t current_epoch; 115 } C2ReceiptPolicy; 116 117 /* What the admitting side expects the receipt to be about. NULL fields are not checked. */ 118 typedef struct { 119 const uint8_t *target; /* 32 bytes: c2r_target_id of the launching target */ 120 const uint8_t *firmware; /* 32 bytes */ 121 const uint8_t *program; /* 32 bytes: SHA-256 of the program bytes being admitted */ 122 const uint8_t *executable; /* 32 bytes: SHA-256 of the executable bytes being admitted */ 123 const uint8_t *producer_checker; /* 32 bytes: identity of the producer's checker (oscc hash) */ 124 const uint8_t *dependencies; /* 32 bytes: c2r_deps_digest of the expected dependency receipt ids. 125 Format v1 binds the ids only: the dependency receipts themselves 126 are NOT fetched, resolved or verified here. */ 127 } C2ReceiptExpect; 128 129 /* Drake's owner root public key (aienos#380 ceremony, YubiKey PIV slot 9c). */ 130 extern const uint8_t c2r_owner_root_pk[32]; 131 /* The TEST-tier key: secret seed = SHA-256("OMEGA-CHECKER2-TEST-KEY-v1 NOT FOR PRODUCTION"). 132 * Public on purpose: anything it signs is TEST class and refused in production. */ 133 void c2r_test_seed(uint8_t seed[32]); 134 extern const uint8_t c2r_test_pk[32]; 135 136 void c2r_target_id(const char *target_name, uint8_t out[32]); 137 /* SHA-256("OMEGA-RECEIPT-DEPS-V1\0" || u32 count || ids in ascending byte order). ids must be 138 * strictly ascending (sorted, unique); returns -1 otherwise. count 0 is allowed. */ 139 int c2r_deps_digest(const uint8_t (*ids)[32], unsigned n, uint8_t out[32]); 140 141 void c2r_encode(const C2Receipt *r, uint8_t out[C2R_SIZE]); 142 /* Structural decode only (size, magic, version, alg, class, evidence, epoch order). */ 143 int c2r_decode(const uint8_t *buf, size_t len, C2Receipt *r); 144 void c2r_id(const uint8_t buf[C2R_SIZE], uint8_t out[32]); 145 /* The exact bytes the Ed25519 signature covers (65 bytes): 146 * "OMEGA-REALIZATION-RECEIPT-SIG-V1\0" || SHA-256("OMEGA-REALIZATION-RECEIPT-V1\0" || buf[0,352)). */ 147 #define C2R_SIGNED_MSG_LEN 65u 148 void c2r_signed_message(const uint8_t buf[C2R_SIZE], uint8_t msg[C2R_SIGNED_MSG_LEN]); 149 150 /* Sign r (fills key_fp and sig, then encodes into out). TEST class only takes the TEST key; 151 * OWNER class is refused here (the owner key never leaves the YubiKey: use c2r_attach). */ 152 int c2r_sign_test(C2Receipt *r, const uint8_t seed[32], uint8_t out[C2R_SIZE]); 153 /* Attach a signature made elsewhere (YubiKey) over c2r_signed_message for public key pk. 154 * Verifies it before returning 0. */ 155 int c2r_attach(C2Receipt *r, const uint8_t pk[32], const uint8_t sig[64], uint8_t out[C2R_SIZE]); 156 157 /* Full admission check, in spec order. Returns C2R_OK or the first failing named reason. */ 158 int c2r_verify(const uint8_t *buf, size_t len, const C2ReceiptPolicy *pol, const C2ReceiptExpect *ex, 159 C2Receipt *out); 160 161 #endif /* C2_RECEIPT_H */