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/aien-train/blob/main/evidence/OMEGALLM/wsp-patch-20261107/sha256.diff # aien-train AIEN training programme: language-model history, GB10 constraints and the route to training on the project engine. Plans and runnable checks are distinguished. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aien-train / evidence / OMEGALLM / wsp-patch-20261107 / sha256.diff` 237 lines ยท 7551 bytes Raw Blame History 1 --- /home/drakestapleton/work/wsp/wpatch-build/sha256-source.om 2026-11-07 00:14:57.`196092902` -0600 2 +++ /home/drakestapleton/work/wsp/wpatch-build/sha256-vendored.om 2026-11-07 00:14:57.`208093013` -0600 3 @@ -1,3 +1,9 @@ 4 +om2 5 +layout shactx 104 6 +field state uint 8 at 0 little 7 +field count ulong at 32 little 8 +field buf uchar 64 at 40 little 9 +end 10 note SPDX-License-Identifier: Apache-2.0 11 note sha256-om2.om: FIPS 180-4 SHA-256 in OM-2 (spec/omegese-om2.md, #747/#748, ledger L838). 12 note The four entries are the API of src/sha256.h, exported through omega-bridge ABI v2 as 13 @@ -18,17 +24,11 @@ 14 note bridge c-type shactx sha256_ctx 15 note bridge c-define SHA256_DIGEST_SIZE 32 16 note bridge c-define SHA256_BLOCK_SIZE 64 17 -om2 18 19 -layout shactx 104 20 -field state uint 8 at 0 little 21 -field count ulong at 32 little 22 -field buf uchar 64 at 40 little 23 -end 24 25 note K[0..63]: the first 32 bits of the fractional parts of the cube roots of the first 64 primes. 26 note Copied mechanically from seed/qualification/om2/fixtures/sha256-k.dec (tool-computed, never typed). 27 -fn kinit k edit uint 64 to void 28 +fn wskinit k edit uint 64 to void 29 put k 0 0x428a2f98 30 put k 1 0x71374491 31 put k 2 0xb5c0fbcf 32 @@ -97,7 +97,7 @@ 33 34 note H(0): the first 32 bits of the fractional parts of the square roots of the first 8 primes 35 note (fixtures/sha256-iv.dec). 36 -fn iv s edit uint 8 to void 37 +fn wsiv s edit uint 8 to void 38 put s 0 0x6a09e667 39 put s 1 0xbb67ae85 40 put s 2 0x3c6ef372 41 @@ -111,7 +111,7 @@ 42 note Message schedule of the block m[o .. o+64). w is fresh: its incoming contents are never read. 43 note The compiler proves that every get of w reads an element written earlier in this function 44 note (error 27 otherwise): w[0..16) are the block's big-endian words, w[16..64) the FIPS recurrence. 45 -fn sched w edit uint 64 fresh m view uchar * o ulong to void 46 +fn wssched w edit uint 64 fresh m view uchar * o ulong to void 47 q = ulong 0 48 x = uint 0 49 y = uint 0 50 @@ -137,7 +137,7 @@ 51 note identities. h first becomes T1, then T1 + T2, which is the next a; the names then shift by one. 52 note The sums are built a term per line and each Sigma in two lines through t: 12 names are live, and 53 note omc hands out 16 registers with no spilling (error 12 under compiler-s1/s2 for longer lines). 54 -fn rounds s edit uint 8 w view uint 64 kt view uint 64 to void 55 +fn wsround s edit uint 8 w view uint 64 kt view uint 64 to void 56 a = get s 0 57 b = get s 1 58 c = get s 2 59 @@ -182,15 +182,15 @@ 60 61 note One block m[o .. o+64) into s. sched and rounds stay calls: inlined, their names would share 62 note one 16-register frame with this function's parameters (no spilling, error 12). 63 -fn compress s edit uint 8 w edit uint 64 kt view uint 64 m view uchar * o ulong to void 64 -sched w m o 65 -rounds s w kt 66 +fn wscomp s edit uint 8 w edit uint 64 kt view uint 64 m view uchar * o ulong to void 67 +wssched w m o 68 +wsround s w kt 69 end 70 71 note The whole blocks of m (len m is a multiple of 64 and at most 2^25, so under 2^19 passes). 72 -fn run s edit uint 8 w edit uint 64 kt view uint 64 m view uchar * to void 73 +fn wsrun s edit uint 8 w edit uint 64 kt view uint 64 m view uchar * to void 74 for j ulong shr len m 6 75 -compress s w kt m shl j 6 76 +wscomp s w kt m shl j 6 77 end 78 end 79 80 @@ -198,24 +198,24 @@ 81 note (OMEGESE.md section 2; omc s_for), so m is cut into runs of 2^25 bytes (2^19 blocks): 82 note len m = top * 2^44 + mid * 2^25 + rest, and no loop passes 2^20 times. top reaches `1000000` 83 note only above 1.7e19 bytes, which no AArch64 address space holds. 84 -fn blocks s edit uint 8 w edit uint 64 kt view uint 64 m view uchar * to void 85 +fn wsblks s edit uint 8 w edit uint 64 kt view uint 64 m view uchar * to void 86 q = ulong 0 87 for a ulong shr len m 44 88 for b ulong 0x80000 89 -run s w kt part m q 0x2000000 90 +wsrun s w kt part m q 0x2000000 91 q = add q 0x2000000 92 end 93 end 94 for b ulong and shr len m 25 0x7ffff 95 -run s w kt part m q 0x2000000 96 +wsrun s w kt part m q 0x2000000 97 q = add q 0x2000000 98 end 99 -run s w kt part m q sub len m q 100 +wsrun s w kt part m q sub len m q 101 end 102 103 note Pad the k pending bytes already in p (k < 64; p was all zero past them): 0x80, zeros, and the 104 note 64-bit big-endian bit length of the n-byte message in the last 8 bytes of one or two blocks. 105 -fn finish s edit uint 8 w edit uint 64 kt view uint 64 p edit uchar 128 k ulong n ulong to void 106 +fn wsfin s edit uint 8 w edit uint 64 kt view uint 64 p edit uchar 128 k ulong n ulong to void 107 put p k 0x80 108 e = ulong 64 109 if ge k 56 110 @@ -225,15 +225,15 @@ 111 for i ulong 8 unroll 112 put p sub e add i 1 uchar and shr bits mul i 8 0xff 113 end 114 -compress s w kt view p 0 115 +wscomp s w kt view p 0 116 if eq e 128 117 -compress s w kt view p 64 118 +wscomp s w kt view p 64 119 end 120 end 121 122 -export fn sha256_init c edit shactx to void 123 +fn sha256_init c edit shactx to void 124 s = new uint 8 0 125 -iv s 126 +wsiv s 127 for i ulong 8 unroll 128 put c state i get s i 129 end 130 @@ -242,20 +242,20 @@ 131 132 note k bytes of d from o into the context's buffer at bi (bi + k <= 64). A function of its own: inside 133 note absorb the copy loop needs more than the 16 registers (error 12 under compiler-s4). 134 -fn tobuf c edit shactx bi ulong d view uchar * o ulong k ulong to void 135 +fn wstobuf c edit shactx bi ulong d view uchar * o ulong k ulong to void 136 for i ulong k 137 put c buf add bi i get d add o i 138 end 139 end 140 141 note Whole blocks are hashed straight from d; the bytes that complete a pending block go through blk. 142 -fn absorb c edit shactx d view uchar * bi ulong to void 143 +fn wsabsb c edit shactx d view uchar * bi ulong to void 144 n = len d 145 s = new uint 8 0 146 w = new uint 64 0 147 kt = new uint 64 0 148 blk = new uchar 64 0 149 -kinit kt 150 +wskinit kt 151 for i ulong 8 unroll 152 put s i get c state i 153 end 154 @@ -268,37 +268,37 @@ 155 for i ulong off 156 put blk add bi i get d i 157 end 158 -compress s w kt view blk 0 159 +wscomp s w kt view blk 0 160 end 161 nb = shr sub n off 6 162 -blocks s w kt part d off shl nb 6 163 +wsblks s w kt part d off shl nb 6 164 off = add off shl nb 6 165 -tobuf c 0 d off sub n off 166 +wstobuf c 0 d off sub n off 167 for i ulong 8 unroll 168 put c state i get s i 169 end 170 end 171 172 note Any length, including 0 and >= 2^32. lt n sub 64 bi cannot wrap (bi < 64); add bi n could. 173 -export fn sha256_update c edit shactx d view uchar * to void 174 +fn sha256_update c edit shactx d view uchar * to void 175 n = len d 176 cnt = get c count 177 bi = and cnt 63 178 put c count add cnt n 179 if lt n sub 64 bi 180 -tobuf c bi d 0 n 181 +wstobuf c bi d 0 n 182 ret 183 end 184 -absorb c d bi 185 +wsabsb c d bi 186 end 187 188 -export fn sha256_final c edit shactx o out uchar 32 to void 189 +fn sha256_final c edit shactx o out uchar 32 to void 190 s = new uint 8 0 191 w = new uint 64 0 192 kt = new uint 64 0 193 p = new uchar 128 0 194 v = ulong 0 195 -kinit kt 196 +wskinit kt 197 for i ulong 8 unroll 198 put s i get c state i 199 end 200 @@ -307,7 +307,7 @@ 201 for i ulong k 202 put p i get c buf i 203 end 204 -finish s w kt p k cnt 205 +wsfin s w kt p k cnt 206 for i ulong 8 unroll 207 v = ulong get s i 208 for j ulong 4 unroll 209 @@ -318,23 +318,23 @@ 210 211 note Equal to init, update(d), final on a fresh context (section 7), with the state in locals. o may 212 note overlap d: the binding copies o out only after the call returns status 0. 213 -export fn sha256_hash d view uchar * o out uchar 32 to void 214 +fn sha256_hash d view uchar * o out uchar 32 to void 215 s = new uint 8 0 216 w = new uint 64 0 217 kt = new uint 64 0 218 p = new uchar 128 0 219 v = ulong 0 220 -kinit kt 221 -iv s 222 +wskinit kt 223 +wsiv s 224 n = len d 225 nb = shr n 6 226 -blocks s w kt part d 0 shl nb 6 227 +wsblks s w kt part d 0 shl nb 6 228 off = shl nb 6 229 k = sub n off 230 for i ulong k 231 put p i get d add off i 232 end 233 -finish s w kt p k n 234 +wsfin s w kt p k n 235 for i ulong 8 unroll 236 v = ulong get s i 237 for j ulong 4 unroll