#!/usr/bin/env python3 """Independent oracle for cycle 02. Reads the 20-literal probe's stdout and checks every reported SHA-256 against Python's hashlib. The El runtime is the system under test; hashlib is the reference. Also counts how many literals hashed as the EMPTY STRING, which is the signature of el_input_len returning 0. """ import sys, hashlib EMPTY = hashlib.sha256(b"").hexdigest() ok = bad = empty = n = 0 for line in sys.stdin: line = line.strip() if not line: continue parts = dict(p.split("=", 1) for p in line.split(" ") if "=" in p) lit, got = parts["lit"], parts["sha"] n += 1 if got == EMPTY: empty += 1 exp = hashlib.sha256(lit.encode()).hexdigest() if got == exp: ok += 1 else: bad += 1 print("MISMATCH lit=%s got=%s expected=%s" % (lit, got, exp)) print("literals tested = %d" % n) print("correct vs hashlib.sha256 = %d" % ok) print("incorrect = %d" % bad) print("hashed as the EMPTY STRING = %d" % empty) print("failure rate = %.0f%%" % (100.0 * empty / n if n else 0))