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/om/sha256/om2-evidence/s4/harness.py # 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 / om / sha256 / om2-evidence / s4 / harness.py` 32 lines ยท 1478 bytes Raw Blame History 1 #!/usr/bin/env python3 2 # TEMPORARY harness (L838, oracle side, outside the delivered closure): feeds every row of the L836 3 # fixture fixtures/sha256-vectors.txt to a program on stdin and compares its hex output with the 4 # fixture digest. Generators as in fixtures/PROVENANCE.txt section 2. 5 import sys, subprocess 6 M = (1 << 64) - 1 7 def gen(spec): 8 if spec == '-': return b'' 9 k, *a = spec.split(':') 10 if k == 'file': return open('fx/msg/' + a[0].rsplit('/', 1)[1], 'rb').read() 11 if k == 'seq': return bytes(i % 251 for i in range(int(a[0]))) 12 if k == 'rep': return bytes([int(a[0])]) * int(a[1]) 13 if k == 'rnd': 14 s, n, out = int(a[0]), int(a[1]), bytearray() 15 while len(out) < n: 16 s = (s + 0x9E3779B97F4A7C15) & M; z = s 17 z = ((z ^ (z >> 30)) * 0xBF58476D1CE4E5B9) & M 18 z = ((z ^ (z >> 27)) * 0x94D049BB133111EB) & M 19 z ^= z >> 31; out += z.to_bytes(8, 'little') 20 return bytes(out[:n]) 21 raise ValueError(spec) 22 ok = bad = 0 23 for line in open('fx/sha256-vectors.txt'): 24 if not line.strip() or line.startswith('#'): continue 25 name, spec, n, dig = line.split() 26 msg = gen(spec); assert len(msg) == int(n), name 27 r = subprocess.run(sys.argv[1:], input=msg, capture_output=True) 28 got = r.stdout.decode().strip() 29 if r.returncode == 0 and got == dig: ok += 1 30 else: bad += 1; print('FAIL', name, r.returncode, got) 31 print(f'vectors pass={ok} fail={bad}') 32 sys.exit(1 if bad else 0)