"""Bind the Julia input table to the two byte-pinned public JSON files.""" from hashlib import sha256 import json from pathlib import Path inputs = Path(__file__).resolve().parent / "inputs" def load_public(name, digest): raw = (inputs / name).read_bytes() if sha256(raw).hexdigest() != digest: raise ValueError(name) return json.loads(raw) graph_hash = "40bc6a1d52efab3d75cf343e65ac06b314f9c9c375fc02bf6d45bf6bb21f9529" graph = load_public("graph-fixture.json", graph_hash) witness = load_public("witness-440.json", "cb2e2e39d0b1cf61781764d44812c8648d494031c69aea5834ed9c49887fa39a") assert witness["fixture_sha256"] == graph_hash bits = witness["label_bits"] assert len(bits) == len(graph["neighbors"]) == 120 # columns: public zero-based vertex, witness bit, twelve public neighbor IDs table = "".join("\t".join(map(str,[v, int(bits[v]), *row])) + "\n" for v, row in enumerate(graph["neighbors"])) if (inputs / "graph-witness.tsv").read_bytes() != table.encode("ascii"): raise ValueError("Julia table differs from the public inputs") print("PASS graph and witness hashes, vertex order, labels, and neighbor lists")