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/src/source-aware/vendor/sha256.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 / src / source-aware / vendor / sha256.om` 175 lines ยท 3200 bytes Raw Blame History 1 note SPDX-License-Identifier: AGPL-3.0-or-later 2 note Exact native TRN1 SHA256 functions; see NOTICE. Buffer declarations bounded for this caller. 3 global Buf uchar 8192 4 global H uint 8 5 global Vv uint 8 6 global W uint 64 7 global K uint 64 8 global Hb uchar 64 9 global Hs ulong 2 10 global Hash uchar 32 11 fn rotate x uint n uint to uint 12 ret or shr x n shl x sub 32 n 13 end 14 15 fn round i ulong to void 16 e = get Vv 4 17 a = get Vv 0 18 s = xor xor rotate e 6 rotate e 11 rotate e 25 19 c = xor and e get Vv 5 and not e get Vv 6 20 t = add add get Vv 7 s add c add get K i get W i 21 s = xor xor rotate a 2 rotate a 13 rotate a 22 22 c = and a get Vv 1 23 c = xor c and a get Vv 2 24 c = xor c and get Vv 1 get Vv 2 25 u = add s c 26 put Vv 7 get Vv 6 27 put Vv 6 get Vv 5 28 put Vv 5 e 29 put Vv 4 add get Vv 3 t 30 put Vv 3 get Vv 2 31 put Vv 2 get Vv 1 32 put Vv 1 a 33 put Vv 0 add t u 34 end 35 36 fn block to void 37 for i ulong 16 38 x = uint 0 39 for j ulong 4 40 x = or shl x 8 uint get Hb add mul i 4 j 41 end 42 put W i x 43 end 44 for j ulong 48 45 i = add j 16 46 x = get W sub i 15 47 y = get W sub i 2 48 s = xor xor rotate x 7 rotate x 18 shr x 3 49 t = xor xor rotate y 17 rotate y 19 shr y 10 50 put W i add add get W sub i 16 s add get W sub i 7 t 51 end 52 for i ulong 8 53 put Vv i get H i 54 end 55 for i ulong 64 56 round i 57 end 58 for i ulong 8 59 put H i add get H i get Vv i 60 end 61 end 62 63 fn hinit to void 64 put H 0 `1779033703` 65 put H 1 `3144134277` 66 put H 2 `1013904242` 67 put H 3 `2773480762` 68 put H 4 `1359893119` 69 put H 5 `2600822924` 70 put H 6 `528734635` 71 put H 7 `1541459225` 72 put Hs 0 0 73 put Hs 1 0 74 end 75 76 fn hbyte c uchar to void 77 p = get Hs 0 78 put Hb p c 79 p = add p 1 80 put Hs 1 add get Hs 1 1 81 if eq p 64 82 block 83 p = 0 84 end 85 put Hs 0 p 86 end 87 88 fn update off ulong count ulong to void 89 for i ulong count 90 hbyte get Buf add off i 91 end 92 end 93 94 fn finish to void 95 bits = mul get Hs 1 8 96 hbyte 128 97 while ne get Hs 0 56 98 hbyte 0 99 end 100 for i ulong 8 101 hbyte uchar and shr bits mul sub 7 i 8 255 102 end 103 for i ulong 32 104 x = get H div i 4 105 put Hash i uchar and shr x uint mul sub 3 rem i 4 8 255 106 end 107 end 108 109 fn constants to void 110 put K 0 `1116352408` 111 put K 1 `1899447441` 112 put K 2 `3049323471` 113 put K 3 `3921009573` 114 put K 4 `961987163` 115 put K 5 `1508970993` 116 put K 6 `2453635748` 117 put K 7 `2870763221` 118 put K 8 `3624381080` 119 put K 9 `310598401` 120 put K 10 `607225278` 121 put K 11 `1426881987` 122 put K 12 `1925078388` 123 put K 13 `2162078206` 124 put K 14 `2614888103` 125 put K 15 `3248222580` 126 put K 16 `3835390401` 127 put K 17 `4022224774` 128 put K 18 `264347078` 129 put K 19 `604807628` 130 put K 20 `770255983` 131 put K 21 `1249150122` 132 put K 22 `1555081692` 133 put K 23 `1996064986` 134 put K 24 `2554220882` 135 put K 25 `2821834349` 136 put K 26 `2952996808` 137 put K 27 `3210313671` 138 put K 28 `3336571891` 139 put K 29 `3584528711` 140 put K 30 `113926993` 141 put K 31 `338241895` 142 put K 32 `666307205` 143 put K 33 `773529912` 144 put K 34 `1294757372` 145 put K 35 `1396182291` 146 put K 36 `1695183700` 147 put K 37 `1986661051` 148 put K 38 `2177026350` 149 put K 39 `2456956037` 150 put K 40 `2730485921` 151 put K 41 `2820302411` 152 put K 42 `3259730800` 153 put K 43 `3345764771` 154 put K 44 `3516065817` 155 put K 45 `3600352804` 156 put K 46 `4094571909` 157 put K 47 `275423344` 158 put K 48 `430227734` 159 put K 49 `506948616` 160 put K 50 `659060556` 161 put K 51 `883997877` 162 put K 52 `958139571` 163 put K 53 `1322822218` 164 put K 54 `1537002063` 165 put K 55 `1747873779` 166 put K 56 `1955562222` 167 put K 57 `2024104815` 168 put K 58 `2227730452` 169 put K 59 `2361852424` 170 put K 60 `2428436474` 171 put K 61 `2756734187` 172 put K 62 `3204031479` 173 put K 63 `3329325298` 174 end 175