From fe9cc975cf5ef8737b1d5e6cd747f3beac0dd1bb Mon Sep 17 00:00:00 2001 From: Aleksey Safonov <55020240+safal207@users.noreply.github.com> Date: Wed, 22 Jul 2026 07:39:41 +0300 Subject: [PATCH 1/6] feat: add fail-closed OTS verifier adapter --- scripts/verify_ots_anchor.py | 269 +++++++++++++++++++++++++++++++++++ 1 file changed, 269 insertions(+) create mode 100644 scripts/verify_ots_anchor.py diff --git a/scripts/verify_ots_anchor.py b/scripts/verify_ots_anchor.py new file mode 100644 index 0000000..38f7d15 --- /dev/null +++ b/scripts/verify_ots_anchor.py @@ -0,0 +1,269 @@ +#!/usr/bin/env python3 +"""Verify a Bitcoin OpenTimestamps sidecar for exact target bytes. + +This adapter invokes the official ``ots`` CLI. It deliberately fails closed: +a URL, a proof filename, exit code 0, or a success-looking string alone is not +enough. The result is promoted to TEMPORALLY_ANCHORED only when the verifier +exits successfully and reports exactly one Bitcoin block attestation. +""" + +from __future__ import annotations + +import argparse +import hashlib +import json +import re +import shutil +import subprocess +import sys +import tempfile +from dataclasses import asdict, dataclass +from datetime import datetime, timezone +from pathlib import Path +from typing import Sequence + +SUCCESS_RE = re.compile( + r"Success!\s+Bitcoin block\s+(?P[1-9][0-9]*)\s+" + r"attests existence as of\s+(?P