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/gpu/runtime/zsha.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 / gpu / runtime / zsha.om` 81 lines ยท 1724 bytes Raw Blame History 1 note SPDX-License-Identifier: Apache-2.0 2 note gpu/runtime/zsha.om: streaming SHA-256 over seed/ng/sha256.om's block buffer sh_dat, so a stream of any 3 note length hashes (sh_all alone stops at len sh_dat). Composed after seed/ng/sha256.om (OM-2 program mode) by 4 note gpu/runtime/inventory.om and gpu/runtime/gate.om. zbeg, then zbyte / zfd any number of times, then zend 5 note leaves the digest in sh_dig. zs_n 0 is the bytes held in sh_dat, zs_n 1 the stream length. 6 global zs_n ulong 2 7 fn zbeg to void 8 sh_init 9 for j ulong 8 10 put sh_h j get sh_k add j 64 11 end 12 put zs_n 0 0 13 put zs_n 1 0 14 end 15 note hash every whole block held, keep the tail at the front of sh_dat 16 fn zdrain to void 17 f = get zs_n 0 18 nb = div f 64 19 for b ulong nb bound `9223372036854775807` 20 sh_blk 0 mul b 64 21 end 22 o = mul nb 64 23 for j ulong sub f o bound 64 24 put sh_dat j get sh_dat add o j 25 end 26 put zs_n 0 sub f o 27 end 28 fn zbyte c ulong to void 29 f = get zs_n 0 30 put sh_dat f uchar c 31 put zs_n 0 add f 1 32 put zs_n 1 add get zs_n 1 1 33 if ge add f 1 len sh_dat 34 zdrain 35 end 36 end 37 note hash everything readable from fd into the stream; false on a read error (fd stays open) 38 fn zfd fd int to bool 39 while true bound `9223372036854775807` 40 f = get zs_n 0 41 if ge f len sh_dat 42 zdrain 43 f = get zs_n 0 44 end 45 x = read fd sh_dat f sub len sh_dat f 46 if lt x 0 47 ret false 48 end 49 if eq x 0 50 ret true 51 end 52 put zs_n 0 add f ulong x 53 put zs_n 1 add get zs_n 1 ulong x 54 end 55 ret true 56 end 57 fn zend to void 58 zdrain 59 r = get zs_n 0 60 n = get zs_n 1 61 for j ulong 128 62 put sh_pad j 0 63 end 64 for j ulong r bound 64 65 put sh_pad j get sh_dat j 66 end 67 put sh_pad r 128 68 e = ulong 64 69 if ge r 56 70 e = 128 71 end 72 bits = mul n 8 73 for j ulong 8 74 put sh_pad sub sub e 1 j uchar and shr bits mul j 8 255 75 end 76 sh_blk 1 0 77 if eq e 128 78 sh_blk 1 64 79 end 80 sh_out 81 end