Repository navigation
feat(verify): bind an OTS proof to the ledger before claiming external time - #55
Merged
Merged
Conversation
…l time mirror-stack-verify checked an OTS proof's Bitcoin block without checking which file the proof stamped, so any valid proof passed, and it left ledger precedence UNVERIFIED by design. With --manifest it now checks proof -> manifest (file sha256 from ots info), manifest -> ledger prefix (locate_ledger) and proof -> Bitcoin, and only then reports the pinned lines and the preregistrations among them as existing before the block. verify() now uses the earliest attestation and pairs each merkle root with its own block; a real multi-calendar proof listed block 959655 before 959599. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Aq8kkjKAMDjSSK54hcWnuc
On Windows, opentimestamps-client crashes on import (python-bitcoinlib finds no OpenSSL library). _info() returned the empty stdout, which bind() then misreported as a proof that names no file. It now raises with the client's error. Also look for ots beside sys.executable when the venv is not active. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Aq8kkjKAMDjSSK54hcWnuc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by 범후연이 · project thread
Problem
mirror-stack-verify --ots PROOFchecked the proof's Bitcoin block, but it never checked which file the proof stamps. Any valid proof for any file passed. The tool said this itself: "ledger-to-proof binding is not checked here". So nothing in the stack let an outsider confirm the core claim, that a preregistration existed before a given time.locate_ledger()already existed but was only used in tests.Second, smaller issue:
verify()used the firstBitcoinBlockHeaderAttestationprinted byots info. A real proof stamped on three calendars, dated 2026-07-25, lists blocks 959655, 959599 and 959609 in that order.verify()reported 959655, which is 56 blocks later than the earliest. That understates the proof rather than overstating it, but it was still wrong.Change
New
ots_anchor.bind(ledger, manifest, proof). It reports external time only when all three checks hold:File sha256 hashinots infoequals the sha256 of the manifest.locate_ledger. Both format 1 and format 2 work, and appends after the stamp are fine.It returns the covered lines with their type and claim_id, and lists the lines appended after the stamp as uncovered.
New
mirror-stack-verify --manifestoption. With--ots, it prints[binding]and[EXTERNAL_TIME]lines, including the preregistrations that the proof covers.--manifestwithout--otsfails. With--otsalone, behaviour is unchanged and precedence is still reported as UNVERIFIED.verify()now picks the earliest attestation, pairs each merkle root with its own block, and also returnsattested_blocksandproof_file_sha256.Replaced the deprecated
datetime.utcnow()andutcfromtimestamp()calls. The output format is the same.Updated README, docs/ANCHORING.md and the CHANGELOG.
The MCP tool
mm_anchor_verifywas not changed and gets no binding option in this PR. That keeps the tool schema test (22 tools) as it is. Binding could be added to the MCP tool as a follow-up.Verification
tests/test_ots_binding.py(8 tests). It fakesots infowith the same layout as the real output, where each merkle root comment comes right after its attestation and the earliest block is not listed first, and it fakes the explorer. The tests cover:Generated by Claude Code