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/protocol/uor-gpu/verify.om # 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 / protocol / uor-gpu / verify.om` 331 lines ยท 10377 bytes Raw Blame History 1 note SPDX-License-Identifier: Apache-2.0 2 note protocol/uor-gpu/verify.om: Pure seeded OM-2 Prism policy verifier, RFC 8032 3 note Ed25519 attestation checker, replay checker, and prism/verdict/1 emitter. 4 note Compose after protocol/omnet/om/sha512/sha512.om, protocol/omnet/om/`ed25519`/`ed25519`.om, 5 note and protocol/uor-gpu/canonical.om. 6 7 text uor_hex_tbl "`0123456789abcdef`" 8 text uor_v_pre "{\"schema\":\"prism/verdict/1\",\"world\":\"hologram:gpu/omega-om2@1\",\"verdict\":\"" 9 text uor_v_pass "PASS" 10 text uor_v_fail "FAIL" 11 text uor_v_lvl "\",\"policy_level\":\"P" 12 text uor_v_rsn "\",\"reason_code\":" 13 text uor_v_uor ",\"uor_sha256\":\"sha256:" 14 text uor_v_b3 "\",\"holo_blake3\":\"blake3:" 15 text uor_v_end "\"}\n" 16 17 text uor_i_pre "{\"schema\":\"prism/inspect/1\",\"world\":\"hologram:gpu/omega-om2@1\",\"isa\":\"" 18 text uor_i_sm121 "SM121" 19 text uor_i_spirv "SPIRV" 20 text uor_i_lvl "\",\"claimed_level\":\"P" 21 text uor_i_sig "\",\"has_signature\":" 22 text uor_i_true "true" 23 text uor_i_false "false" 24 text uor_i_pk ",\"signer_pubkey\":\"" 25 text uor_i_lean "\",\"lean_proof_sha256\":\"sha256:" 26 27 note Local trust anchors (the verifier's own offline policy file, no central authority): 28 note [0..8) magic "UORTRST1" 29 note [8..40) omc_sha256 pin (seed/out/omc digest the verifier accepts) 30 note [40..72) lean_proof_sha256 pin (UorGpuWorld.lean digest the verifier accepts) 31 note [72..104) capability authority Ed25519 key (all-zero = admission disabled) 32 note [104..) 1..16 trusted bundle signer Ed25519 keys, 32 bytes each, non-zero, none equal to 33 note the authority key (a bundle signer can never grant itself a capability) 34 const UOR_ANCH_OMC ulong 8 35 const UOR_ANCH_LEAN ulong 40 36 const UOR_ANCH_AUTH ulong 72 37 const UOR_ANCH_KEYS ulong 104 38 const UOR_ANCH_MAX ulong 616 39 text uor_anch_magic "UORTRST1" 40 41 note Returns the number of trusted signer keys (1..16) if the anchors are well formed, else 0. 42 fn uor_anchors_nkeys anchors view uchar * to ulong 43 n = len anchors 44 if or lt n add UOR_ANCH_KEYS 32 gt n UOR_ANCH_MAX 45 ret 0 46 end 47 if ne rem sub n UOR_ANCH_KEYS 32 0 48 ret 0 49 end 50 for i ulong 8 51 if ne get anchors i get uor_anch_magic i 52 ret 0 53 end 54 end 55 if or ne uor_is_zero32 anchors UOR_ANCH_OMC 0 ne uor_is_zero32 anchors UOR_ANCH_LEAN 0 56 ret 0 57 end 58 nk = div sub n UOR_ANCH_KEYS 32 59 auth = new uchar 32 0 60 for i ulong 32 61 put auth i get anchors add UOR_ANCH_AUTH i 62 end 63 for k ulong nk bound 16 64 off = add UOR_ANCH_KEYS mul k 32 65 if ne uor_is_zero32 anchors off 0 66 ret 0 67 end 68 if ne uor_eq32 anchors off auth 0 0 69 ret 0 70 end 71 end 72 ret nk 73 end 74 75 note 1 iff signer_pubkey hdr[288..320) is one of the nk trusted signer keys. 76 fn uor_signer_trusted hdr view uchar 384 anchors view uchar * nk ulong to ulong 77 hit = ulong 0 78 for k ulong nk bound 16 79 if ne uor_eq32 hdr 288 anchors add UOR_ANCH_KEYS mul k 32 0 80 hit = ulong 1 81 end 82 end 83 ret hit 84 end 85 text uor_i_mlbom "\",\"mlbom_sha256\":\"sha256:" 86 text uor_i_uor "\",\"uor_sha256\":\"sha256:" 87 text uor_i_b3 "\",\"holo_blake3\":\"blake3:" 88 text uor_i_end "\"}\n" 89 90 note Verify Ed25519 signature over hdr[224..287] (uor_id_sha256 || holo_blake3). 91 note Returns 1 iff signed AND strict RFC 8032 Ed25519 signature is valid; 0 otherwise. 92 fn uor_verify_`ed25519`_strict hdr view uchar 384 to ulong 93 if ne uor_is_zero32 hdr 288 0 94 ret 0 95 end 96 pk = new uchar 32 0 97 sig = new uchar 64 0 98 msg = new uchar 65536 0 99 for i ulong 32 100 put pk i get hdr add 288 i 101 end 102 for i ulong 64 103 put sig i get hdr add 320 i 104 put msg i get hdr add 224 i 105 end 106 ret edverify pk msg 64 sig 0 107 end 108 109 note Evidence rules: P2+ needs the Lean 4 proof digest to equal the verifier's pinned digest; 110 note P3 needs a non-zero replay digest (the replay command also compares it to the oracle). 111 fn uor_policy_evidence hdr view uchar 384 anchors view uchar * min_level ulong to ulong 112 if ge min_level UOR_LVL_P2 113 if ne uor_is_zero32 hdr 128 0 114 ret UOR_ERR_NO_LEAN_PROOF 115 end 116 if eq uor_eq32 hdr 128 anchors UOR_ANCH_LEAN 0 117 ret UOR_ERR_LEAN_UNPINNED 118 end 119 end 120 if ge min_level UOR_LVL_P3 121 if ne uor_is_zero32 hdr 160 0 122 ret UOR_ERR_NO_REPLAY 123 end 124 end 125 ret UOR_VERDICT_PASS 126 end 127 128 note Signature rules ("Nothing raises a level except signing"): 129 note unsigned (zero signer_pubkey): only min_level P0, only a header that claims P0, and the 130 note signature slot must be all-zero; 131 note signed: signer_pubkey must be a locally trusted key AND the RFC 8032 signature must verify. 132 fn uor_policy_sig hdr view uchar 384 anchors view uchar * nk ulong min_level ulong to ulong 133 if ne uor_is_zero32 hdr 288 0 134 if ge min_level UOR_LVL_P1 135 ret UOR_ERR_BAD_SIG 136 end 137 if ne uor_get_u32 hdr 20 UOR_LVL_P0 138 ret UOR_ERR_UNSIGNED_LEVEL 139 end 140 if or eq uor_is_zero32 hdr 320 0 eq uor_is_zero32 hdr 352 0 141 ret UOR_ERR_BAD_SIG 142 end 143 ret UOR_VERDICT_PASS 144 end 145 if eq uor_signer_trusted hdr anchors nk 0 146 ret UOR_ERR_UNTRUSTED_SIGNER 147 end 148 if eq uor_verify_`ed25519`_strict hdr 0 149 ret UOR_ERR_BAD_SIG 150 end 151 ret UOR_VERDICT_PASS 152 end 153 154 note Verify a UOR-GPU-1 bundle against the verifier's local trust anchors at a minimum level. 155 note P0: digests intact + target payload structure valid (SM121 QMD v5 or SPIR-V 1.0 OpenCL); 156 note unsigned allowed only as a P0 claim with an all-zero signature slot 157 note P1+: signed by a locally trusted key with a valid RFC 8032 Ed25519 signature 158 note P2+ (default): also the pinned Lean 4 proof digest 159 note P3: also a non-zero golden replay digest (checked by real kernel replay via uor_verify_replay_real) 160 fn uor_verify_policy hdr view uchar 384 pay view uchar * anchors view uchar * min_level ulong to ulong 161 nk = uor_anchors_nkeys anchors 162 if eq nk 0 163 ret UOR_ERR_BAD_ANCHORS 164 end 165 rc = uor_hdr_check hdr pay 166 if ne rc UOR_VERDICT_PASS 167 ret rc 168 end 169 rc = uvm_check_payload hdr pay 170 if ne rc UOR_VERDICT_PASS 171 ret rc 172 end 173 if eq uor_eq32 hdr 32 anchors UOR_ANCH_OMC 0 174 ret UOR_ERR_OMC_PIN 175 end 176 if lt uor_get_u32 hdr 20 min_level 177 ret UOR_ERR_LEVEL_LOW 178 end 179 rc = uor_policy_evidence hdr anchors min_level 180 if ne rc UOR_VERDICT_PASS 181 ret rc 182 end 183 ret uor_policy_sig hdr anchors nk min_level 184 end 185 186 note Verify bundle's replay_sha256 matches expected digest. 187 fn uor_verify_replay hdr view uchar 384 expected view uchar 32 to ulong 188 if ne uor_is_zero32 hdr 160 0 189 ret UOR_ERR_NO_REPLAY 190 end 191 if eq uor_eq32 hdr 160 expected 0 0 192 ret UOR_ERR_REPLAY_MISMATCH 193 end 194 ret UOR_VERDICT_PASS 195 end 196 197 note Real kernel replay: decode and execute the bundle's actual SM121 SASS+QMD v5 or SPIR-V 198 note payload bytes in pure seeded OM-2, and verify the executed output digest matches both 199 note hdr.replay_sha256 and the world's golden vecadd vector digest. 200 fn uor_verify_replay_real hdr view uchar 384 pay view uchar * to ulong 201 actual = new uchar 32 0 202 expect = new uchar 32 0 203 if ne uor_is_zero32 hdr 160 0 204 ret UOR_ERR_NO_REPLAY 205 end 206 rc = uvm_replay_payload hdr pay actual 207 if ne rc UOR_VERDICT_PASS 208 ret rc 209 end 210 if eq uor_eq32 hdr 160 actual 0 0 211 ret UOR_ERR_REPLAY_MISMATCH 212 end 213 uvm_expected_digest uor_get_u32 hdr 12 expect 214 if eq uor_eq32 actual 0 expect 0 0 215 ret UOR_ERR_REPLAY_MISMATCH 216 end 217 ret UOR_VERDICT_PASS 218 end 219 220 fn uor_write_all fd int buf view uchar * n ulong to void 221 off = ulong 0 222 while lt off n bound 4096 223 k = write fd buf off sub n off 224 if le k 0 225 ret 226 end 227 off = add off ulong k 228 end 229 end 230 231 fn uor_write_hex32 fd int src view uchar * soff ulong to void 232 hx = new uchar 64 0 233 for i ulong 32 234 b = ulong get src add soff i 235 put hx mul i 2 get uor_hex_tbl shr b 4 236 put hx add mul i 2 1 get uor_hex_tbl and b 15 237 end 238 uor_write_all fd hx 64 239 end 240 241 fn uor_write_digit fd int d ulong to void 242 ch = new uchar 1 0 243 v = d 244 if gt v 99 245 v = ulong 99 246 end 247 if lt v 10 248 put ch 0 uchar add 48 v 249 uor_write_all fd ch 1 250 else 251 put ch 0 uchar add 48 div v 10 252 uor_write_all fd ch 1 253 put ch 0 uchar add 48 rem v 10 254 uor_write_all fd ch 1 255 end 256 end 257 258 note Emit canonical prism/verdict/1 JSON line to stdout (fd 1). policy_level is the level the 259 note verifier checked (plvl), never the level the header claims. 260 fn uor_emit_verdict hdr view uchar 384 code ulong plvl ulong to void 261 lvl = plvl 262 if gt lvl UOR_LVL_P3 263 lvl = ulong 0 264 end 265 uor_write_all 1 uor_v_pre len uor_v_pre 266 if eq code UOR_VERDICT_PASS 267 uor_write_all 1 uor_v_pass len uor_v_pass 268 else 269 uor_write_all 1 uor_v_fail len uor_v_fail 270 end 271 uor_write_all 1 uor_v_lvl len uor_v_lvl 272 uor_write_digit 1 lvl 273 uor_write_all 1 uor_v_rsn len uor_v_rsn 274 uor_write_digit 1 code 275 uor_write_all 1 uor_v_uor len uor_v_uor 276 uor_write_hex32 1 hdr 224 277 uor_write_all 1 uor_v_b3 len uor_v_b3 278 uor_write_hex32 1 hdr 256 279 uor_write_all 1 uor_v_end len uor_v_end 280 end 281 282 note Emit prism/inspect/1 JSON summary to stdout (fd 1): the header's CLAIMS, nothing verified 283 note (no digest, trust or signature check). Returns 1 on valid magic/ISA/level, 0 on corrupt header. 284 fn uor_emit_inspect hdr view uchar 384 to ulong 285 if or ne get hdr 0 uchar 85 ne get hdr 1 uchar 79 286 ret 0 287 end 288 if or ne get hdr 2 uchar 82 ne get hdr 3 uchar 71 289 ret 0 290 end 291 if or ne get hdr 4 uchar 80 ne get hdr 5 uchar 85 292 ret 0 293 end 294 if or ne get hdr 6 uchar 49 ne get hdr 7 uchar 0 295 ret 0 296 end 297 isa = uor_get_u32 hdr 12 298 if and ne isa UOR_GPU_ISA_SM121 ne isa UOR_GPU_ISA_SPIRV 299 ret 0 300 end 301 lvl = uor_get_u32 hdr 20 302 if gt lvl UOR_LVL_P3 303 ret 0 304 end 305 uor_write_all 1 uor_i_pre len uor_i_pre 306 if eq isa UOR_GPU_ISA_SM121 307 uor_write_all 1 uor_i_sm121 len uor_i_sm121 308 else 309 uor_write_all 1 uor_i_spirv len uor_i_spirv 310 end 311 uor_write_all 1 uor_i_lvl len uor_i_lvl 312 uor_write_digit 1 lvl 313 uor_write_all 1 uor_i_sig len uor_i_sig 314 if eq uor_is_zero32 hdr 288 0 315 uor_write_all 1 uor_i_true len uor_i_true 316 else 317 uor_write_all 1 uor_i_false len uor_i_false 318 end 319 uor_write_all 1 uor_i_pk len uor_i_pk 320 uor_write_hex32 1 hdr 288 321 uor_write_all 1 uor_i_lean len uor_i_lean 322 uor_write_hex32 1 hdr 128 323 uor_write_all 1 uor_i_mlbom len uor_i_mlbom 324 uor_write_hex32 1 hdr 192 325 uor_write_all 1 uor_i_uor len uor_i_uor 326 uor_write_hex32 1 hdr 224 327 uor_write_all 1 uor_i_b3 len uor_i_b3 328 uor_write_hex32 1 hdr 256 329 uor_write_all 1 uor_i_end len uor_i_end 330 ret 1 331 end