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 / seed / authority / delegate-gate.om

268 lines · 4483 bytes Raw Blame History
1note SPDX-License-Identifier: AGPL-3.0-only
2note Attenuation predicate only. A trusted authority must verify the parent and issue the child.
3note Words 0..7: version,rights,memory,fuel,expiry,remaining-depth,reserved,reserved.
4note Words 8..23: exact resource scope,authority root,subject,grant identities, four words each.
5note This profile supports the same resource only. No wildcard, path or network-subnet inference.
6
7fn capvalid p view ulong 24 to ulong
8if ne get p 0 1
9ret 61
10end
11if gt get p 5 64
12ret 62
13end
14if or eq get p 4 0 or ne get p 6 0 ne get p 7 0
15ret 62
16end
17for g ulong 4
18bits = ulong 0
19for j ulong 4
20bits = or bits get p add 8 add mul g 4 j
21end
22if eq bits 0
23ret 62
24end
25end
26ret 0
27end
28
29fn capeq p view ulong 24 c view ulong 24 off ulong to bool
30diff = ulong 0
31for j ulong 4
32at = add off j
33diff = or diff xor get p at get c at
34end
35ret eq diff 0
36end
37
38fn capchild p view ulong 24 c view ulong 24 now ulong to ulong
39err = capvalid p
40if ne err 0
41ret err
42end
43err = capvalid c
44if ne err 0
45ret err
46end
47if ge now get p 4
48ret 64
49end
50if ge now get c 4
51ret 65
52end
53if ne and get c 1 get p 1 get c 1
54ret 66
55end
56if gt get c 2 get p 2
57ret 67
58end
59if gt get c 3 get p 3
60ret 68
61end
62if gt get c 4 get p 4
63ret 69
64end
65if not capeq p c 8
66ret 70
67end
68if not capeq p c 12
69ret 71
70end
71if eq get p 5 0
72ret 72
73end
74if ge get c 5 get p 5
75ret 73
76end
77if capeq p c 16
78ret 74
79end
80if capeq p c 20
81ret 75
82end
83ret 0
84end
85note SPDX-License-Identifier: AGPL-3.0-only
86global checks ulong 1
87global fails ulong 1
88global report uchar 64
89text title "delegate checks="
90fn check got ulong want ulong to void
91put checks 0 add get checks 0 1
92if ne got want
93put fails 0 add get fails 0 1
94end
95end
96fn parent p edit ulong 24 to void
97for i ulong 24
98put p i 0
99end
100put p 0 1
101put p 1 7
102put p 2 1024
103put p 3 200
104put p 4 100
105put p 5 4
106for i ulong 16
107put p add i 8 add i 100
108end
109end
110fn child c edit ulong 24 to void
111parent c
112put c 1 3
113put c 2 512
114put c 3 100
115put c 4 90
116put c 5 3
117put c 16 200
118put c 20 300
119end
120fn summary to int
121for i ulong len title
122put report i get title i
123end
124n = get checks 0
125at = len title
126put report at uchar add 48 div n 100
127put report add at 1 uchar add 48 rem div n 10 10
128put report add at 2 uchar add 48 rem n 10
129put report add at 3 32
130put report add at 4 uchar add 48 div get fails 0 100
131put report add at 5 uchar add 48 rem div get fails 0 10 10
132put report add at 6 uchar add 48 rem get fails 0 10
133put report add at 7 10
134w = write 1 report 0 add at 8
135if ne w long add at 8
136ret 2
137end
138if ne get fails 0 0
139ret 1
140end
141ret 0
142end
143fn main to int
144p = new ulong 24 0
145c = new ulong 24 0
146parent p
147child c
148check capchild p c 50 0
149put c 1 8
150check capchild p c 50 66
151child c
152put c 2 1025
153check capchild p c 50 67
154child c
155put c 3 201
156check capchild p c 50 68
157child c
158put c 4 101
159check capchild p c 50 69
160child c
161put c 5 4
162check capchild p c 50 73
163child c
164put p 5 0
165check capchild p c 50 72
166parent p
167child c
168put c 4 50
169check capchild p c 50 65
170child c
171check capchild p c 100 64
172child c
173put c 1 0
174put c 2 0
175put c 3 0
176put c 5 0
177check capchild p c 50 0
178put p 1 0
179put p 2 0
180put p 3 0
181check capchild p c 50 0
182put c 1 1
183check capchild p c 50 66
184
185for i ulong 8
186parent p
187child c
188put c add i 8 add get c add i 8 1
189check capchild p c 50 add 70 div i 4
190end
191parent p
192child c
193for i ulong 4
194put c add i 16 get p add i 16
195end
196check capchild p c 50 74
197child c
198for i ulong 4
199put c add i 20 get p add i 20
200end
201check capchild p c 50 75
202for group ulong 4
203parent p
204child c
205for j ulong 4
206put p add 8 add mul group 4 j 0
207end
208check capchild p c 50 62
209parent p
210for j ulong 4
211put c add 8 add mul group 4 j 0
212end
213check capchild p c 50 62
214end
215
216parent p
217child c
218put p 0 2
219check capchild p c 50 61
220parent p
221put c 0 2
222check capchild p c 50 61
223child c
224put c 1 512
225check capchild p c 50 66
226child c
227put c 6 1
228check capchild p c 50 62
229child c
230put c 7 1
231check capchild p c 50 62
232child c
233put c 5 18446744073709551615
234check capchild p c 50 62
235child c
236put p 5 65
237check capchild p c 50 62
238parent p
239child c
240put p 5 1
241put c 5 0
242check capchild p c 50 0
243put p 2 18446744073709551615
244put c 2 18446744073709551615
245check capchild p c 50 0
246put p 2 18446744073709551614
247check capchild p c 50 67
248parent p
249child c
250put p 1 9223372036854775808
251put c 1 9223372036854775808
252check capchild p c 50 0
253put c 1 9223372036854775809
254check capchild p c 50 66
255
256note Exhaust all subsets of the small rights profile, not only one happy case.
257for rights ulong 32
258parent p
259child c
260put c 1 rights
261want = ulong 66
262if lt rights 8
263want = 0
264end
265check capchild p c 50 want
266end
267ret summary
268end