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/seed/omc/sites/found-arrarg-3.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 / seed / omc / sites / found-arrarg-3.om` 261 lines ยท 6449 bytes Raw Blame History 1 note sites: found by a one-token change of a tracked program (121 to 300 lines); reaches the omc error site in arrarg (code 20) 2 note SPDX-License-Identifier: Apache-2.0 3 note b3unit.om: BLAKE3 (default unkeyed hash, 32-byte output) as one function-mode unit, bound 4 note through the omega-bridge native call ABI and exported as omega_omb3. It replaces the algorithm of 5 note src/omega_blake3.c, which keeps only omega_blake3_hash: that cuts the input into 1024-byte chunks. 6 note The tree logic follows om/blake3/blake3.om (the program form, kept for files and stdin). 7 note 8 note omb3 st b n fin o: 9 note st caller state, zeroed before the first call: rows 0..53 of 8 words are the chaining-value 10 note stack, word 440 its depth, word 441 the number of chunks absorbed 11 note fin 0 b holds a whole chunk that is not the last one (n must be 1024): its chaining value is 12 note merged into the stack 13 note fin 1 b[0..n) is the last chunk (n 0..1024): the tree is finished and the root hash goes to o 14 note A wrong n traps 3. 15 note 16 note Working words w (one array because globals are program-mode only): 17 note 0..15 state s, 16..31 message m, 32..47 permute scratch, 48..55 input chaining value, 18 note 56..71 compression output, 72 block length, 73 counter, 74 flags, 75..82 node chaining value, 19 note 83..90 IV, 91..106 message permutation 20 21 fn initw w edit ulong 128 to void 22 put w 83 `1779033703` 23 put w 84 `3144134277` 24 put w 85 `1013904242` 25 put w 86 `2773480762` 26 put w 87 `1359893119` 27 put w 88 `2600822924` 28 put w 89 `528734635` 29 put w 90 `1541459225` 30 put w 91 2 31 put w 92 6 32 put w 93 3 33 put w 94 10 34 put w 95 7 35 put w 96 0 36 put w 97 4 37 put w 98 13 38 put w 99 1 39 put w 100 11 40 put w 101 12 41 put w 102 5 42 put w 103 9 43 put w 104 14 44 put w 105 15 45 put w 106 8 46 end 47 48 note the G mixing function on state words a b c d with message words 2j and 2j+1 49 fn g w edit ulong 128 a ulong b ulong c ulong d ulong j ulong to void 50 x = get w add 16 mul j 2 51 t = add get w a get w b 52 put w a and add t x `4294967295` 53 t = xor get w d get w a 54 put w d and or shr t 16 shl t 16 `4294967295` 55 put w c and add get w c get w d `4294967295` 56 t = xor get w b get w c 57 put w b and or shr t 12 shl t 20 `4294967295` 58 x = get w add 17 mul j 2 59 t = add get w a get w b 60 put w a and add t x `4294967295` 61 t = xor get w d get w a 62 put w d and or shr t 8 shl t 24 `4294967295` 63 put w c and add get w c get w d `4294967295` 64 t = xor get w b get w c 65 put w b and or shr t 7 shl t 25 `4294967295` 66 end 67 68 fn round w edit ulong 128 to void 69 g w 0 4 8 12 0 70 g w 1 5 9 13 1 71 g w 2 6 10 14 2 72 g w 3 7 11 15 3 73 g w 0 5 10 15 4 74 g w 1 6 11 12 5 75 g w 2 7 8 13 6 76 g w 3 4 9 14 7 77 end 78 79 fn permute w edit ulong 128 to void 80 for i ulong 16 81 put w add 32 i get w add 16 get w add 91 i 82 end 83 for i ulong 16 84 put w add 16 i get w add 32 i 85 end 86 end 87 88 note the 16 little-endian words of blk into m 89 fn loadm w edit ulong 128 blk edit uchar 64 to void 90 for i ulong 16 91 o = mul i 4 92 v = ulong get blk add o 3 93 v = or shl v 8 ulong get blk add o 2 94 v = or shl v 8 ulong get blk add o 1 95 v = or shl v 8 ulong get blk o 96 put w add 16 i v 97 end 98 end 99 100 note compress (input chaining value, blk, block length, counter, flags) into the output words 101 fn compress w edit ulong 128 blk edit uchar 64 to void 102 loadm w blk 103 for i ulong 8 104 put w i get w add 48 i 105 put w add i 8 get w add 83 i 106 end 107 put w 12 and get w 73 `4294967295` 108 put w 13 and shr get w 73 32 `4294967295` 109 put w 14 get w 72 110 put w 15 get w 74 111 for r ulong 7 112 round w 113 permute w 114 end 115 for i ulong 8 116 put w add 56 i xor get w i get w add i 8 117 put w add 64 i xor get w add i 8 get w add 48 i 118 end 119 end 120 121 note compress, then the node chaining value is the first 8 output words 122 fn nodecv w edit ulong 128 blk edit uchar 64 to void 123 compress view blk 124 for i ulong 8 125 put w add 75 i get w add 56 i 126 end 127 end 128 129 note copy cnt bytes of b from offset o into blk, zero the rest 130 fn loadblk blk edit uchar 64 b view uchar 1024 o ulong cnt ulong to void 131 for i ulong 64 132 if lt i cnt 133 put blk i get b add o i 134 else 135 put blk i 0 136 end 137 end 138 end 139 140 fn setnb w edit ulong 128 bl ulong ctr ulong fl ulong to void 141 put w 72 bl 142 put w 73 ctr 143 put w 74 fl 144 end 145 146 note chunk ctr holding b[0..cnt): every block but the last compressed, the last left set up 147 fn chunk w edit ulong 128 blk edit uchar 64 b view uchar 1024 cnt ulong ctr ulong to void 148 for i ulong 8 149 put w add 48 i get w add 83 i 150 end 151 nblk = ulong 1 152 if gt cnt 0 153 nblk = div add cnt 63 64 154 end 155 k = ulong 0 156 while lt add k 1 nblk bound 16 157 loadblk blk b mul k 64 64 158 fl = ulong 0 159 if eq k 0 160 fl = 1 161 end 162 setnb w 64 ctr fl 163 compress w blk 164 for i ulong 8 165 put w add 48 i get w add 56 i 166 end 167 k = add k 1 168 end 169 bo = mul sub nblk 1 64 170 loadblk blk b bo sub cnt bo 171 fl = ulong 2 172 if eq nblk 1 173 fl = 3 174 end 175 setnb w sub cnt bo ctr fl 176 end 177 178 note parent node of stack row r (left) and the node chaining value (right), set up to compress 179 fn parentn w edit ulong 128 blk edit uchar 64 st edit ulong 448 r ulong to void 180 for i ulong 8 181 put w add 48 i get w add 83 i 182 end 183 for i ulong 8 184 l = get st add mul r 8 i 185 v = get w add 75 i 186 for k ulong 4 187 sh = mul k 8 188 q = add mul i 4 k 189 put blk q uchar and shr l sh 255 190 put blk add 32 q uchar and shr v sh 255 191 end 192 end 193 setnb w 64 0 4 194 end 195 196 fn push w edit ulong 128 st edit ulong 448 to void 197 p = get st 440 198 for i ulong 8 199 put st add mul p 8 i get w add 75 i 200 end 201 put st 440 add p 1 202 end 203 204 note a whole chunk that is not the last: merge completed subtrees, then push its chaining value 205 fn midchk w edit ulong 128 blk edit uchar 64 st edit ulong 448 b view uchar 1024 to void 206 ctr = get st 441 207 chunk w blk b 1024 ctr 208 nodecv w blk 209 tot = add ctr 1 210 while eq and tot 1 0 bound 64 211 d = sub get st 440 1 212 put st 440 d 213 parentn w blk st d 214 nodecv w blk 215 tot = shr tot 1 216 end 217 push w st 218 put st 441 add ctr 1 219 end 220 221 note the last chunk: fold the stack into the root and write its 32 little-endian bytes into o 222 fn lastchk w edit ulong 128 blk edit uchar 64 st edit ulong 448 b view uchar 1024 n ulong o edit uchar 32 to void 223 chunk w blk b n get st 441 224 while gt get st 440 0 bound 64 225 nodecv w blk 226 d = sub get st 440 1 227 put st 440 d 228 parentn w blk st d 229 end 230 put w 74 or get w 74 8 231 compress w blk 232 outle w o 233 end 234 235 note the first 8 output words, little endian, into o 236 fn outle w edit ulong 128 o edit uchar 32 to void 237 for i ulong 8 238 v = get w add 56 i 239 for k ulong 4 240 q = add mul i 4 k 241 put o q uchar and shr v mul k 8 255 242 end 243 end 244 end 245 246 fn omb3 st edit ulong 448 b view uchar 1024 n ulong fin ulong o edit uchar 32 to void 247 w = new ulong 128 0 248 blk = new uchar 64 0 249 initw w 250 if gt n 1024 251 trap 3 252 end 253 if eq fin 0 254 if ne n 1024 255 trap 3 256 end 257 midchk w blk st b 258 ret 259 end 260 lastchk w blk st b n o 261 end