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 / qualification / om2 / fixtures / oracle / kiv.bc

42 lines · 884 bytes Raw Blame History
1/* SHA-256 constants by exact integer arithmetic: K[i] = floor(cbrt(p_i) * 2^32) mod 2^32
2 = icbrt(p_i * 2^96) mod 2^32 and H[i] = isqrt(p_i * 2^64) mod 2^32, p_i the i-th prime. */
3define icbrt(n) {
4 auto x, y
5 x = n
6 y = (2*x + n/(x*x))/3
7 while (y < x) {
8 x = y
9 y = (2*x + n/(x*x))/3
10 }
11 return (x)
12}
13define isqrt(n) {
14 auto x, y
15 x = n
16 y = (x + n/x)/2
17 while (y < x) {
18 x = y
19 y = (x + n/x)/2
20 }
21 return (x)
22}
23define isprime(n) {
24 auto d
25 if (n < 2) return (0)
26 for (d = 2; d*d <= n; d++) {
27 if (n % d == 0) return (0)
28 }
29 return (1)
30}
31scale = 0
32c = 0
33for (p = 2; c < 64; p++) {
34 if (isprime(p)) {
35 k[c] = icbrt(p * 2^96) % 2^32
36 if (c < 8) h[c] = isqrt(p * 2^64) % 2^32
37 q[c] = p
38 c = c + 1
39 }
40}
41for (i = 0; i < 64; i++) print "K ", i, " ", q[i], " ", k[i], "\n"
42for (i = 0; i < 8; i++) print "H ", i, " ", q[i], " ", h[i], "\n"