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 / interplane / v03 / conformance.om

124 lines · 3627 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0
2note protocol/interplane/v03/conformance.om: pure-Omega port of interplane-conformance (v0.3.0).
3note TRUST-DIGEST canonical SHA-256 over sorted corpus + negative-controls + protocol + translation,
4note T3/T4 adapter subset selection rule, and negative-control matrix verifier (V2, V4, V6).
5note Compose after si/directives/om2.om, om/tls/sha2.om, and protocol/interplane/v03/crossveil.om.
6
7const CF_ADAPTER_ODYSSEUS ulong 3
8const CF_ADAPTER_AIEN ulong 4
9
10text cf_hex "0123456789abcdef"
11text cf_sep " "
12text cf_nl "\n"
13
14fn cf_hex32 dig view uchar 32 dst edit uchar 64 to void
15for i ulong 32
16b = ulong get dig i
17put dst mul i ulong 2 get cf_hex shr b ulong 4
18put dst add mul i ulong 2 ulong 1 get cf_hex and b ulong 15
19end
20end
21
22fn cf_dig_eq a view uchar 32 b view uchar 32 to bool
23for i ulong 32
24if ne get a i get b i
25ret false
26end
27end
28ret true
29end
30
31note Append one canonical sha256sum line ("<hex64> <path>\n") into a running SHA-256 context.
32fn cf_trust_add_entry ctx edit ulong 40 path view uchar * body view uchar * to void
33d = new uchar 32 0
34hx = new uchar 64 0
35bctx = new ulong 40 0
36sha256_init bctx
37sha256_update bctx body
38sha256_final bctx d
39cf_hex32 d hx
40sha256_update ctx hx
41sha256_update ctx cf_sep
42sha256_update ctx path
43sha256_update ctx cf_nl
44end
45
46note T3/T4 subset rule (bench/PROTOCOL-0.3.md section 2):
47note Reads fixture capability requirement mask & adapter supported capability mask.
48note NEVER reads fixture results. Returns true iff every required cap bit is supported.
49fn cf_subset_admit req_caps ulong adapter_caps ulong to bool
50if eq req_caps ulong 0
51ret false
52end
53ret eq and req_caps adapter_caps req_caps
54end
55
56note Negative-control verifier:
57note Verifies that baseline (CV_CTL_NONE) refuses/requires-approval on injection, effect, and replay,
58note AND that V2, V4, V6 mutants each break their respective invariant (proving the check catches them).
59fn cf_verify_negctl_matrix to bool
60ledger = new ulong 32 0
61lcnt = new ulong 1 0
62ctx = new ulong 6 0
63res = new ulong 2 0
64
65note Case 1 (V2 target): untrusted request claiming approval, authority says REQUIRES_APPROVAL
66put ctx 0 ulong 101
67put ctx 1 ulong 1
68put ctx 2 CV_EXP_UNTRUSTED
69put ctx 3 ulong 1
70put ctx 4 CV_DEC_REQUIRES_APPROVAL
71put ctx 5 CV_CTL_NONE
72cv_pipeline_step ledger lcnt ctx res
73if ne get res 0 CV_DEC_REQUIRES_APPROVAL
74ret false
75end
76note Mutant V2 must bypass into AUTHORIZED (so test detects it)
77put ctx 0 ulong 102
78put ctx 5 CV_CTL_V2_CLAIMED_APPROVAL
79cv_pipeline_step ledger lcnt ctx res
80if ne get res 0 CV_DEC_AUTHORIZED
81ret false
82end
83
84note Case 2 (V4 target): effect capability denied by authority under baseline
85put ctx 0 ulong 201
86put ctx 1 ulong 1
87put ctx 2 CV_EXP_TRUSTED
88put ctx 3 ulong 0
89put ctx 4 CV_DEC_DENIED
90put ctx 5 CV_CTL_NONE
91cv_pipeline_step ledger lcnt ctx res
92if ne get res 0 CV_DEC_DENIED
93ret false
94end
95note Mutant V4 must bypass into AUTHORIZED
96put ctx 0 ulong 202
97put ctx 5 CV_CTL_V4_EFFECT_BYPASS
98cv_pipeline_step ledger lcnt ctx res
99if ne get res 0 CV_DEC_AUTHORIZED
100ret false
101end
102
103note Case 3 (V6 target): replay of req_id=101 must be DENIED (CV_ERR_DUPLICATE_REQ) under baseline
104put ctx 0 ulong 101
105put ctx 1 ulong 0
106put ctx 2 CV_EXP_TRUSTED
107put ctx 3 ulong 0
108put ctx 4 CV_DEC_AUTHORIZED
109put ctx 5 CV_CTL_NONE
110cv_pipeline_step ledger lcnt ctx res
111if ne get res 0 CV_DEC_DENIED
112ret false
113end
114if ne get res 1 CV_ERR_DUPLICATE_REQ
115ret false
116end
117note Mutant V6 resets ledger so replay of req_id=101 slips through as AUTHORIZED
118put ctx 5 CV_CTL_V6_NO_REPLAY_CHECK
119cv_pipeline_step ledger lcnt ctx res
120if ne get res 0 CV_DEC_AUTHORIZED
121ret false
122end
123ret true
124end