interplane.Get Omega
Read in your language

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

branch main Branches Tags History

omega-mv / protocol / uor-gpu / gate.om

95 lines · 3205 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0
2note protocol/uor-gpu/gate.om: Pure seeded OM-2 pre-dispatch GPU admission gate.
3note Requires ALL of:
4note 1. uor_verify_policy(..., min_level P2) == PASS (pinned Lean 4 proof, trusted Ed25519 signer,
5note intact digests) against the verifier's local trust anchors;
6note 2. a capability grant record signed (RFC 8032 Ed25519) by the anchors' authority key, which
7note can never equal a bundle signer key (checked in uor_anchors_nkeys);
8note 3. the grant is live, has a non-zero generation equal to the expected one, the current
9note epoch, a non-zero lease expiry later than the current clock, the subject and GPU
10note resource of the request, and RX_RIGHT_EFFECT (4), matching seed/authority/caproot.om.
11note Offline limit: generation-based revocation needs the live caproot table; an offline caller
12note supplies the expected generation, so offline revocation rests on the signed lease expiry.
13note Compose after verify.om.
14
15const UOR_CAP_LIVE ulong 1
16const UOR_RIGHT_EFFECT ulong 4
17
18note cap_entry[8]: 0=state, 1=generation, 2=epoch, 3=lease_expiry,
19note 4=subject, 5=resource, 6=rights, 7=reserved
20note cap_req[5]: 0=expected_gen, 1=cur_epoch, 2=cur_clock, 3=subject, 4=resource
21fn uor_cap_admit cap_entry view ulong 8 cap_req view ulong 5 to ulong
22 if ne get cap_entry 0 UOR_CAP_LIVE
23 ret 0
24 end
25 if or eq get cap_entry 1 0 ne get cap_entry 1 get cap_req 0
26 ret 0
27 end
28 if ne get cap_entry 2 get cap_req 1
29 ret 0
30 end
31 exp = get cap_entry 3
32 if ne exp 0
33 if ge get cap_req 2 exp
34 ret 0
35 end
36 end
37 if ne get cap_entry 4 get cap_req 3
38 ret 0
39 end
40 if ne get cap_entry 5 get cap_req 4
41 ret 0
42 end
43 if eq and get cap_entry 6 UOR_RIGHT_EFFECT 0
44 ret 0
45 end
46 ret 1
47end
48
49note 1 iff gctx[64..128) is a valid RFC 8032 Ed25519 signature of gctx[0..64) by the anchors'
50note non-zero authority key.
51fn uor_grant_sig_ok gctx view uchar 168 anchors view uchar * to ulong
52 if ne uor_is_zero32 anchors UOR_ANCH_AUTH 0
53 ret 0
54 end
55 pk = new uchar 32 0
56 sg = new uchar 64 0
57 msg = new uchar 65536 0
58 for i ulong 32
59 put pk i get anchors add UOR_ANCH_AUTH i
60 end
61 for i ulong 64
62 put sg i get gctx add 64 i
63 put msg i get gctx i
64 end
65 ret edverify pk msg 64 sg 0
66end
67
68note gctx[168]: 0..63 grant record, 8 x u64 LE in cap_entry order
69note 64..127 Ed25519 signature of gctx[0..64) by the anchors' authority key
70note 128..167 request, 5 x u64 LE in cap_req order
71note Fail-closed GPU dispatch admission: verified bundle AND authority-signed live grant.
72fn uor_gpu_admit hdr view uchar 384 pay view uchar * anchors view uchar * gctx view uchar 168 to ulong
73 rc = uor_verify_policy hdr pay anchors UOR_LVL_P2
74 if ne rc UOR_VERDICT_PASS
75 ret rc
76 end
77 if eq uor_grant_sig_ok gctx anchors 0
78 ret UOR_ERR_BAD_GRANT
79 end
80 ent = new ulong 8 0
81 req = new ulong 5 0
82 for i ulong 8
83 put ent i uor_get_u64 gctx mul i 8
84 end
85 for i ulong 5
86 put req i uor_get_u64 gctx add 128 mul i 8
87 end
88 if eq get ent 3 0
89 ret UOR_ERR_CAP_DENIED
90 end
91 if eq uor_cap_admit ent req 0
92 ret UOR_ERR_CAP_DENIED
93 end
94 ret UOR_VERDICT_PASS
95end