interplane.Get Omega
Read in your language

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

branch main Branches Tags History

omega-mv / seed / ng / gpu / pinsum.om

47 lines · 1313 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0
2note seed/ng/gpu/pinsum.om: SHA-256 of standard input, printed as 64 lowercase hex digits and a newline.
3note It is the filter of gate.cases' lock-* cases, which enforce seed/ng/cudapp.lock: STDIN is the raw
4note file, STDOUT the line the lock pins. Program mode, no om2 line, prefix ps_.
5note Compiled after the plain-function form of om/sha256/sha256-om2.om (FIPS 180-4, the bridge's
6note sha256 unit), exactly as seed/semhash builds: gate.cases joins five pack: segments of that file
7note that skip the four "export " prefixes (bytes 7196, 8356, 8545 and 9149, 7 bytes each), then this file.
8note Exit 0 with the digest; a read error writes one stderr line and exits 93; an output error exits 93.
9text ps_erd "pinsum: read failed\n"
10
11fn ps_hx x ulong to uchar
12if lt x 10
13ret uchar add x 48
14end
15ret uchar add x 87
16end
17
18fn main to int
19c = new uchar 104 0
20sha256_init c
21k = new uchar 65536 0
22for a ulong 1000000000
23r = read 0 k 0 65536
24if lt r 0
25w = write 2 ps_erd 0 len ps_erd
26exit 93
27end
28if eq r 0
29break
30end
31sha256_update c part k 0 ulong r
32end
33h = new uchar 32 0
34sha256_final c h
35o = new uchar 65 0
36for i ulong 32
37v = ulong get h i
38put o mul i 2 ps_hx shr v 4
39put o add mul i 2 1 ps_hx and v 15
40end
41put o 64 uchar 10
42q = write 1 o 0 65
43if ne q 65
44exit 93
45end
46ret 0
47end