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
omega-mv / seed / authority / delegate.om
| 1 | note SPDX-License-Identifier: AGPL-3.0-only |
| 2 | note Attenuation predicate only. A trusted authority must verify the parent and issue the child. |
| 3 | note Words 0..7: version,rights,memory,fuel,expiry,remaining-depth,reserved,reserved. |
| 4 | note Words 8..23: exact resource scope,authority root,subject,grant identities, four words each. |
| 5 | note This profile supports the same resource only. No wildcard, path or network-subnet inference. |
| 6 | |
| 7 | fn capvalid p view ulong 24 to ulong |
| 8 | if ne get p 0 1 |
| 9 | ret 61 |
| 10 | end |
| 11 | if gt get p 5 64 |
| 12 | ret 62 |
| 13 | end |
| 14 | if or eq get p 4 0 or ne get p 6 0 ne get p 7 0 |
| 15 | ret 62 |
| 16 | end |
| 17 | for g ulong 4 |
| 18 | bits = ulong 0 |
| 19 | for j ulong 4 |
| 20 | bits = or bits get p add 8 add mul g 4 j |
| 21 | end |
| 22 | if eq bits 0 |
| 23 | ret 62 |
| 24 | end |
| 25 | end |
| 26 | ret 0 |
| 27 | end |
| 28 | |
| 29 | fn capeq p view ulong 24 c view ulong 24 off ulong to bool |
| 30 | diff = ulong 0 |
| 31 | for j ulong 4 |
| 32 | at = add off j |
| 33 | diff = or diff xor get p at get c at |
| 34 | end |
| 35 | ret eq diff 0 |
| 36 | end |
| 37 | |
| 38 | fn capchild p view ulong 24 c view ulong 24 now ulong to ulong |
| 39 | err = capvalid p |
| 40 | if ne err 0 |
| 41 | ret err |
| 42 | end |
| 43 | err = capvalid c |
| 44 | if ne err 0 |
| 45 | ret err |
| 46 | end |
| 47 | if ge now get p 4 |
| 48 | ret 64 |
| 49 | end |
| 50 | if ge now get c 4 |
| 51 | ret 65 |
| 52 | end |
| 53 | if ne and get c 1 get p 1 get c 1 |
| 54 | ret 66 |
| 55 | end |
| 56 | if gt get c 2 get p 2 |
| 57 | ret 67 |
| 58 | end |
| 59 | if gt get c 3 get p 3 |
| 60 | ret 68 |
| 61 | end |
| 62 | if gt get c 4 get p 4 |
| 63 | ret 69 |
| 64 | end |
| 65 | if not capeq p c 8 |
| 66 | ret 70 |
| 67 | end |
| 68 | if not capeq p c 12 |
| 69 | ret 71 |
| 70 | end |
| 71 | if eq get p 5 0 |
| 72 | ret 72 |
| 73 | end |
| 74 | if ge get c 5 get p 5 |
| 75 | ret 73 |
| 76 | end |
| 77 | if capeq p c 16 |
| 78 | ret 74 |
| 79 | end |
| 80 | if capeq p c 20 |
| 81 | ret 75 |
| 82 | end |
| 83 | ret 0 |
| 84 | end |