OpenTimestamps integration
OC Stamp uses OpenTimestamps (opens in a new tab) for block-anchored priority. We do not reimplement OTS. We compose with it.
Peter Todd built OTS correctly. Rebuilding it would be NIH. The right framing: OC Stamp uses OpenTimestamps for the anchoring layer and adds Bitcoin-address-bound authorship + optional stake context on top.
The flowLink to this section
1. SIGN — canonical message → id
2. SUBMIT — POST <id bytes> to OTS calendar(s)
3. PENDING — calendar returns a commitment to its internal Merkle tree
4. UPGRADE — hours later, calendar anchors its root to a Bitcoin block
5. VERIFY — parse proof, walk to block header, compare Merkle roots
Step 1–2: SubmissionLink to this section
@orangecheck/stamp-ots ships the calendar client:
import type { StampEnvelope } from '@orangecheck/stamp-core';
import { submitToCalendars, toStampOts } from '@orangecheck/stamp-ots';
declare const envelope: StampEnvelope; // signed in step 1
const proof = await submitToCalendars(envelope.id);
const anchored = { ...envelope, ots: toStampOts(proof) };
Defaults to three independently-operated calendars:
https://alice.btc.calendar.opentimestamps.orghttps://bob.btc.calendar.opentimestamps.orghttps://finney.calendar.eternitywall.com
Clients SHOULD submit to at least two independent calendars. Submitting to a
single calendar is a single point of failure for upgrade liveness. So
submitToCalendars needs two calendars to answer by default and throws if fewer
do; pass minSuccesses: 1 to accept one. The proof keeps the receipt of every
calendar that answered, and calendars lists them.
The digest goes as the raw 32-byte body of POST /digest with no Content-Type
header: a browser sends a CORS preflight for any other type, and the public
calendars refuse it.
Step 3: Pending proofLink to this section
Immediately after submission the calendar returns a pending proof — a commitment to its internal Merkle tree that has not yet been anchored to Bitcoin:
"ots": {
"status": "pending",
"proof": "<base64 bytes>",
"calendars": ["https://alice.btc.calendar.opentimestamps.org"],
"block_height": null,
"block_hash": null,
"upgraded_at": null
}
A pending proof proves authorship (via the BIP-322 signature) but not
priority. Verifiers with a policy that requires priority should reject with
E_NO_ANCHOR.
Step 4: UpgradeLink to this section
OTS calendars aggregate submissions and anchor the root to Bitcoin roughly once per hour. Once the root lands in a confirmed block, the calendar serves an upgraded proof containing the Merkle path from the original id up through the calendar root up to the Bitcoin block's Merkle root.
Any client (signer, verifier, archival crawler) can fetch the upgrade:
import type { StampEnvelope } from '@orangecheck/stamp-core';
import {
fromStampOts,
mempoolHeaderSource,
toStampOts,
upgradeProof,
} from '@orangecheck/stamp-ots';
declare const anchored: StampEnvelope; // the pending envelope from step 2
const current = fromStampOts(anchored.ots!);
const upgraded = await upgradeProof(current, anchored.id, {
headerSource: mempoolHeaderSource(), // or your own node's headers
});
const env = { ...anchored, ots: toStampOts(upgraded) };
While the calendars have not anchored the batch, upgradeProof() returns the
proof still pending; call it again later. headerSource is required: the proof
becomes confirmed only once the header at its attested height has the proof's
Merkle root, so nothing is confirmed on the proof's say-so.
The upgrade rewrites ots only. It does not touch id, sig, or any other
signed-domain field. The signature domain does not include ots, so the upgrade
is cryptographically independent of the BIP-322 commitment.
Step 5: Anchor verificationLink to this section
A verifier with ots.status === "confirmed":
- Parses
ots.proof. - Walks the proof from
idto a Bitcoin attestation atblock_height. - Fetches (or is supplied) the Bitcoin block header at
block_heightand checks that it hashes toblock_hash. - Compares the header's Merkle root to the one derived from the proof.
- Accepts iff both checks hold.
@orangecheck/stamp-ots does all five, given a source of block headers:
import type { StampEnvelope } from '@orangecheck/stamp-core';
import { verifySignature } from '@orangecheck/bip322';
import { verify } from '@orangecheck/stamp-core';
import {
makeAnchorVerifier,
mempoolHeaderSource,
} from '@orangecheck/stamp-ots';
declare const env: StampEnvelope; // the upgraded envelope from step 4
// Shaped as stamp-core's verifyOtsAnchor(proofB64, blockHeight, blockHash, envelopeId).
const verifyOtsAnchor = makeAnchorVerifier({
headerSource: mempoolHeaderSource(), // or a full node, SPV, or headers snapshot
});
const r = await verify({
envelope: env,
verifyOtsAnchor,
verifyBip322: async (msg, sig, addr) => verifySignature(addr, msg, sig),
});
The proof parserLink to this section
@orangecheck/stamp-ots parses the OTS proof format itself, with no dependency:
parseProof reads the bare timestamp carried in ots.proof and parseDetached
reads a detached .ots file. makeAnchorVerifier walks proofs with it. To use
another parser, pass it as walkProof.
AggregatorsLink to this section
An aggregator is an optional middleware that batches OTS submissions for multiple clients. An aggregator:
- Accepts draft envelopes, submits them to calendars, returns pending proofs.
- Watches for upgrades and republishes confirmed envelopes.
- Typically also republishes to Nostr directories.
Aggregators are liveness-scoped trust — they can refuse service, batch slowly, or lose a submission — but they cannot:
- Forge envelopes (no signer key).
- Backdate (OTS won't let them).
The stake field is outside the id and the signature, so an aggregator could
strip or change it. A verifier that cares about stake re-resolves the
attestation and checks it was signed by signer.address.
stamp.ochk.io runs no aggregator. Its /api/ots route forwards each id to
alice, bob or finney as the browser sends it, because the calendars do not allow
cross-origin requests; the verify page upgrades the proof in your browser when
you open the stamp there later. Nothing batches, watches or republishes. A
signer with their own Bitcoin node and OTS calendar has no need of an
aggregator.
Further readingLink to this section
- OpenTimestamps website (opens in a new tab)
@orangecheck/stamp-otson npm (opens in a new tab)javascript-opentimestamps(opens in a new tab) — the reference implementation of the format.- SPEC §6 (opens in a new tab) — normative rules.