# Copyright (c) 2026 Tiago Pinto # SPDX-License-Identifier: MIT # # Independent producer-side implementation of # draft-fassbender-scitt-time-anchor-03, written from the published # Internet-Draft alone. See README.md and CONSTRUCTION.md. """verify_run.py: VERIFY-ANCHOR (Section 3.1) against a self-operated node. Usage: python3 verify_run.py Returns valid / invalid / unverifiable, with the block height (the normative binding, Section 2.6.1) and the RWCP (informative, Section 1.3) when valid. Inline comments below are in Portuguese, the implementer's working language. """ import hashlib, sys from datetime import datetime, timezone import verify from node_rpc import BitcoinRPC def main(): art_path, ots_path = sys.argv[1], sys.argv[2] art = open(art_path, 'rb').read() ots = open(ots_path, 'rb').read() bundle = {'ots_proof': ots, 'claimed_hash': 'sha256:' + hashlib.sha256(art).hexdigest()} r = verify.verify_anchor(art, bundle, BitcoinRPC()) print("resultado:", r['result']) if r['result'] == 'valid': t = datetime.fromtimestamp(r['block_time_RWCP'], tz=timezone.utc) print("block-height binding (normativo):", r['block_height_H']) print("RWCP block.time(H) (informativa):", t.strftime('%Y-%m-%dT%H:%M:%SZ')) print("confirmações:", r['confirmations']) else: print("detalhe:", {k: v for k, v in r.items() if k != 'result'}) if __name__ == '__main__': main()