Skip to main content

Module wire

Module wire 

Source
Expand description

OpenTimestamps proof-file wire format — parse, serialize, replay.

Implements the op-stream format from python-opentimestamps (the reference implementation): a file header magic, then a recursive timestamp tree where each node holds attestations and op-edges, and every edge’s child is keyed by the operation’s result on the current message. Verification replays the ops from the stamped digest; attestations hang off terminal messages.

Wire details (pinned from the reference; see the audit ledger’s OTS item for the full table):

  • file magic: \\0OpenTimestamps\\0\\0Proof\\0 + 8 salt bytes (bf 89 e2 e8 84 e8 92 94 — the final two were dropped in the first transcription; caught by the gem’s cross-checked Ruby spec), then major version 0x01
  • 0xFF separators precede every tag except the last sibling
  • tag 0x00 introduces an attestation: 8-byte tag + payload
  • op tags: SHA256 0x08, APPEND 0xF0, PREPEND 0xF1, REVERSE 0xF2, HEXLIFY 0xF3 (unknown tags are rejected — extend the enum when a real proof needs them)
  • varuint is unsigned LEB128; varbytes is varuint-length + bytes

Structs§

OtsFile
A parsed OTS proof file: header + root timestamp node.
OtsWireVerification
Replay summary: every attestation paired with the terminal message it actually commits.
TimestampNode
One node of the timestamp tree: attestations plus op-edges.

Enums§

Attestation
An attestation on a terminal message of the proof tree.
Op
A timestamp operation.
WireError
Errors from the wire format layer.

Constants§

FILE_MAGIC
File header magic: \0OpenTimestamps\0\0Proof\0 + 8 salt bytes.
MAX_RESULT_LENGTH
Maximum op payload / message length accepted on deserialization — matches the reference implementation’s guard against maliciously large proofs.

Functions§

parse
Parse an OTS proof file for digest.
replay
Replay the proof tree from file.digest, yielding every (terminal_message, attestation) pair.
serialize
Serialize an OTS proof file (canonical ordering: attestations sorted, ops sorted by tag).
verify
Replay and classify: partition every attestation by kind, paired with the message the op-chain computed for it. A proof whose tree yields no attestations verifies nothing.