#!/usr/bin/env python3 """Recreate the exact original .npz trial-map inputs from Hexagon-compatible JSON. Usage (from the downloaded/extracted project directory): python3 anc/restore_inputs.py python3 anc/verify_b2.py anc/trial_c_exact.npz 16 8 0 2 python3 anc/verify_b2.py anc/trial_h0_exact.npz 16 8 0 1 python3 anc/step_cert.py 104 0.004 0.025 0.025 0.1 0.04 1e-5 3000 1e9 6 0 Requires Python 3 and numpy. All four original proof scripts are untouched. The JSON decimal numbers decode to exactly the same IEEE-754 binary64 bits as in the supplied .npz files (verified during packaging and on restoration). """ from pathlib import Path import json import hashlib import numpy as np HERE = Path(__file__).resolve().parent def main(): for stem in ('trial_c_exact', 'trial_h0_exact'): inp = HERE / (stem + '.json') raw = json.loads(inp.read_text(encoding='utf-8')) data = {} for key in ('r','t','phi','gam'): arr = np.asarray(raw['arrays'][key], dtype=np.float64) actual = hashlib.sha256(arr.tobytes(order='C')).hexdigest() expected = raw['sha256_float64_C_order'][key] if actual != expected: raise ValueError(f'{stem} {key}: float64 data hash mismatch') data[key] = arr assert data['phi'].shape == data['gam'].shape == (len(data['r']), len(data['t'])) out = HERE / (stem + '.npz') np.savez(out, **data) print('Restored', out.name, 'with bit-identical float64 arrays') if __name__ == '__main__': main()