#!/usr/bin/env python3 """Conceptual Health — independent record verifier (public). Pure-Python RFC6962; no network, no trust in CH. Usage: python3 verify.py (a receipt CH issues for your record) Confirms your record is committed to CH's anchored ledger by recomputing the Merkle root from your record's leaf + proof path and matching it to the published root. If anything were altered, the math would not match.""" import sys, json, hashlib def _h256(b): return hashlib.sha3_256(b).digest() def verify(rec): leaf=bytes.fromhex(rec['leaf']); root=bytes.fromhex(rec['root']) h=_h256(b'\x00'+leaf) for sib,is_right in rec['inclusion_proof']: s=bytes.fromhex(sib); h=_h256(b'\x01'+(h+s if is_right else s+h)) ok = h==root bad = _h256(b'\x00'+_h256(b'TAMPERED')) # sanity: a different leaf must not match return {'record_in_anchored_ledger': ok, 'matches_published_root': rec.get('published_root')==rec['root'] if rec.get('published_root') else None, 'VERDICT': 'PASS — your record is provably in Conceptual Health\'s anchored ledger' if ok else 'FAIL — does not verify'} if __name__=='__main__': if len(sys.argv)<2: print(__doc__); sys.exit(2) print(json.dumps(verify(json.load(open(sys.argv[1]))), indent=2));