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/aien-protocols/specs/latent-payload/validator.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 / aien-protocols / specs / latent-payload / validator.om` 268 lines ยท 4062 bytes Raw Blame History 1 note SPDX-License-Identifier: Apache-2.0 2 note LTP0 pure admission-template validator. No main, effects or authority. 3 note Compose after om2 debug and before pinned om/tls/sha2.om. 4 fn lpbe64 a view uchar * off ulong to ulong 5 v = ulong 0 6 for i ulong 8 7 v = or shl v 8 ulong get a add off i 8 end 9 ret v 10 end 11 fn lpbe32 a view uchar * off ulong to ulong 12 v = ulong 0 13 for i ulong 4 14 v = or shl v 8 ulong get a add off i 15 end 16 ret v 17 end 18 fn lpeq a view uchar * c view uchar * off ulong n ulong to bool 19 for i ulong n 20 p = add off i 21 if ne get a p get c p 22 ret false 23 end 24 end 25 ret true 26 end 27 fn lpnonzero a view uchar * off ulong n ulong to bool 28 v = uchar 0 29 for i ulong n 30 v = or v get a add off i 31 end 32 ret ne v 0 33 end 34 fn lpenums a view uchar * to bool 35 if or lt get a 5 1 gt get a 5 2 36 ret false 37 end 38 if or ne get a 6 1 ne get a 7 1 39 ret false 40 end 41 if or ne get a 14 1 ne get a 15 0 42 ret false 43 end 44 if or lt get a 100 1 gt get a 100 3 45 ret false 46 end 47 if gt get a 101 2 48 ret false 49 end 50 if or lt get a 102 2 gt get a 102 3 51 ret false 52 end 53 ret true 54 end 55 fn lpquant a view uchar * to bool 56 scale = lpbe32 a 56 57 zero = lpbe32 a 60 58 if eq get a 10 1 59 if or ne get a 12 1 ne get a 13 0 60 ret false 61 end 62 ret and eq scale 0x3f800000 eq zero 0 63 end 64 if eq get a 10 2 65 if or ne get a 12 5 ne get a 13 1 66 ret false 67 end 68 if or eq scale 0 ge scale 0x7f800000 69 ret false 70 end 71 ret or le zero 127 ge zero 0xffffff80 72 end 73 ret false 74 end 75 fn lpshape a view uchar * to bool 76 rank = ulong get a 11 77 srank = ulong get a 103 78 if or lt rank 1 gt rank 4 79 ret false 80 end 81 if or lt srank 1 gt srank 4 82 ret false 83 end 84 for i ulong 4 85 sdim = lpbe32 a add 112 mul i 4 86 if lt i srank 87 if eq sdim 0 88 ret false 89 end 90 else 91 if ne sdim 0 92 ret false 93 end 94 end 95 end 96 width = ulong 1 97 if eq get a 10 1 98 width = 4 99 end 100 prod = ulong 1 101 stride = width 102 for k ulong 4 103 i = sub 3 k 104 dim = lpbe32 a add 24 mul i 4 105 st = lpbe32 a add 40 mul i 4 106 if ge i rank 107 if or ne dim 0 ne st 0 108 ret false 109 end 110 else 111 if or eq dim 0 gt dim 4096 112 ret false 113 end 114 if gt prod div ulong 4096 dim 115 ret false 116 end 117 if ne st stride 118 ret false 119 end 120 prod = mul prod dim 121 stride = mul prod width 122 end 123 end 124 ret eq prod lpbe32 a 20 125 end 126 fn lpsize a view uchar * to bool 127 n = lpbe32 a 16 128 cap = lpbe32 a 108 129 if or eq n 0 gt n 4096 130 ret false 131 end 132 if or eq cap 0 gt cap 4096 133 ret false 134 end 135 if gt n cap 136 ret false 137 end 138 if ne len a add 1024 n 139 ret false 140 end 141 width = ulong 1 142 if eq get a 10 1 143 width = 4 144 end 145 ret eq n mul lpbe32 a 20 width 146 end 147 fn lpids a view uchar * to bool 148 if or eq lpbe32 a 88 0 eq lpbe32 a 96 0 149 ret false 150 end 151 if eq lpbe32 a 104 0 152 ret false 153 end 154 for i ulong 2 155 if not lpnonzero a add 128 mul i 16 16 156 ret false 157 end 158 end 159 for i ulong 18 160 if not lpnonzero a add 160 mul i 32 32 161 ret false 162 end 163 end 164 for i ulong 2 165 if not lpnonzero a add 736 mul i 16 16 166 ret false 167 end 168 end 169 for i ulong 3 170 if not lpnonzero a add 768 mul i 32 32 171 ret false 172 end 173 end 174 ret true 175 end 176 fn lpfinite a view uchar * to bool 177 if eq get a 10 1 178 n = lpbe32 a 20 179 for i ulong n 180 bits = lpbe32 a add 1024 mul i 4 181 if eq and bits 0x7f800000 0x7f800000 182 ret false 183 end 184 end 185 end 186 ret true 187 end 188 fn lphash a view uchar * to bool 189 state = new ulong 40 0 190 digest = new uchar 32 0 191 sha256_init state 192 sha256_update state part a 0 992 193 sha256_update state part a 1024 sub len a 1024 194 sha256_final state digest 195 for i ulong 32 196 if ne get digest i get a add 992 i 197 ret false 198 end 199 end 200 ret true 201 end 202 fn lpvalid a view uchar * c view uchar * now ulong lastseq ulong to int 203 if or lt len a 1024 gt len a 5120 204 ret 10 205 end 206 if ne len c 1024 207 ret 10 208 end 209 if ne lpbe32 a 0 0x4c545030 210 ret 11 211 end 212 if or ne get a 4 0 ne get a 8 4 213 ret 11 214 end 215 if ne get a 9 0 216 ret 11 217 end 218 if not lpenums a 219 ret 12 220 end 221 if not lpquant a 222 ret 13 223 end 224 if not lpshape a 225 ret 14 226 end 227 if not lpsize a 228 ret 15 229 end 230 for i ulong 128 231 if ne get a add 864 i 0 232 ret 16 233 end 234 end 235 if not lpids a 236 ret 17 237 end 238 issued = lpbe64 a 64 239 expiry = lpbe64 a 72 240 if or eq issued 0 gt issued now 241 ret 18 242 end 243 if or le expiry now le expiry issued 244 ret 18 245 end 246 if gt expiry lpbe64 c 72 247 ret 18 248 end 249 if le lpbe64 a 80 lastseq 250 ret 19 251 end 252 if not lpeq a c 0 16 253 ret 20 254 end 255 if not lpeq a c 24 40 256 ret 20 257 end 258 if not lpeq a c 88 776 259 ret 20 260 end 261 if not lpfinite a 262 ret 21 263 end 264 if not lphash a 265 ret 22 266 end 267 ret 0 268 end