Skip to content
On this page

How OC Stamp works

Two steps. First you sign. Then you anchor.

1. SignLink to this section

TypeScript
import { stamp } from '@orangecheck/stamp-core';

declare function walletSignBIP322(message: string): Promise<string>; // your wallet's BIP-322 signer

const contentBytes = new TextEncoder().encode(
    'release: v1.2.3 signed by Alice'
);
const env = await stamp({
    content: contentBytes,
    mime: 'text/plain',
    signer: {
        address: 'bc1qalice...',
        signMessage: async (m) => walletSignBIP322(m), // your wallet; see Quickstart
    },
});

An optional stake field points at an OC Attest attestation. It is self-declared and outside the signature, so a verifier that cares re-resolves it; see envelope.

stamp() builds a canonical message: the oc-stamp:v1 header, the signer's address, the SHA-256 of content, its length, its MIME type and the signing time. The envelope id is the SHA-256 of those bytes, and the wallet signs the id's hex form via BIP-322, so the signature covers every line.

The envelope is a JSON blob (every field):

JSON
{
    "v": 1,
    "kind": "stamp",
    "id": "<sha256 of the canonical message, 64 lowercase hex>",
    "content": {
        "hash": "sha256:<64 hex>",
        "length": 31,
        "mime": "text/plain",
        "ref": null
    },
    "signer": { "address": "bc1qalice...", "alg": "bip322" },
    "signed_at": "2026-04-24T06:47:29Z",
    "stake": null,
    "ots": null,
    "sig": { "alg": "bip322", "pubkey": "bc1qalice...", "value": "<base64>" }
}

The content itself is NOT included in the envelope — only its hash. You ship the envelope alongside the content (archive, filesystem, HTTP, whatever). A verifier re-hashes the content and checks against content.hash to prove the envelope commits to the same bytes.

This is intentional: envelopes stay small (~500 bytes) regardless of content size. A 4 GB video gets the same envelope a 40-byte string does.

2. AnchorLink to this section

TypeScript
import type { StampEnvelope } from '@orangecheck/stamp-core';

import { submitToCalendars, toStampOts } from '@orangecheck/stamp-ots';

declare const env: StampEnvelope; // the envelope from step 1

// Submit the envelope id to OpenTimestamps calendars
const anchored = { ...env, ots: toStampOts(await submitToCalendars(env.id)) };
// anchored.ots.status is "pending"

submitToCalendars() POSTs the envelope's id bytes to the three default OTS calendars (alice.btc.calendar.opentimestamps.org, bob.btc.calendar.opentimestamps.org and finney.calendar.eternitywall.com) and needs two of them to answer. The calendars batch many digests into a Merkle tree and publish the tree root to Bitcoin. At this point the proof is pending — you have a receipt that says "your digest is in a batch" but the batch hasn't hit the chain yet.

Once a Bitcoin block confirms, the proof can be upgraded:

TypeScript
import type { StampEnvelope } from '@orangecheck/stamp-core';

import {
    fromStampOts,
    mempoolHeaderSource,
    toStampOts,
    upgradeProof,
} from '@orangecheck/stamp-ots';

declare const anchored: StampEnvelope; // the pending envelope from above

// An hour or more later. Returns the proof unchanged while it is still pending.
const proof = await upgradeProof(fromStampOts(anchored.ots!), anchored.id, {
    headerSource: mempoolHeaderSource(), // checks the block header it lands in
});
const upgraded = { ...anchored, ots: toStampOts(proof) };
// upgraded.ots.status is "confirmed" once the batch is in a block

The upgraded proof contains the Merkle path from your digest to the Merkle root of a Bitcoin block. Anyone holding the envelope, the proof and that block's header (from any Bitcoin node) can verify:

  • The envelope was signed by the holder of the Bitcoin address (via BIP-322).
  • The envelope's id was included in a specific Bitcoin block at a specific height, so it cannot have been fabricated after that block.

VerifyLink to this section

TypeScript
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 upgraded: StampEnvelope; // the upgraded envelope from above
declare const contentBytes: Uint8Array; // the content you stamped

const result = await verify({
    envelope: upgraded,
    content: contentBytes, // optional: the raw bytes the envelope commits to
    verifyBip322: async (msg, sig, addr) => verifySignature(addr, msg, sig),
    verifyOtsAnchor: makeAnchorVerifier({
        headerSource: mempoolHeaderSource(),
    }),
});

if (!result.ok) throw new Error(`${result.code}: ${result.message}`);
console.log('Author:', result.envelope.signer.address);
if (result.anchor.status === 'confirmed') {
    console.log('Anchored in Bitcoin block:', result.anchor.blockHeight);
} else {
    console.log('Anchor:', result.anchor.status); // "pending", "none", or "unchecked" if headers did not load
}

verify() fails with E_BAD_CONTENT if the bytes do not match, and with E_BAD_ANCHOR if a confirmed proof does not check out against the header. verify() is pure — it does the crypto and delegates network calls (BIP-322 verification, block headers) to plug-in functions you provide. This keeps the core verifier offline-capable and lets you choose any block-header source: mempoolHeaderSource() asks mempool.space, and your own node removes that trust.

Without the anchorLink to this section

A stamp without ots is still useful — you have a signed statement binding content to an address. You just don't have a time-anchor. Anchor later, or skip it entirely if your use case doesn't need priority.

Publishing optionalLink to this section

Envelopes can be published to Nostr kind-30083 with d tag oc-stamp:<id> for durable public discovery, but it's optional. A stamp is a self-contained JSON blob; email it, embed it in a git commit message, put it in S3 — it verifies the same way.

See alsoLink to this section