Repository avatar
Other Tools
v0.1.1
active

btcnotar

io.github.yordank/btcnotar

Free Bitcoin timestamps: notarize texts and files, verify proofs. Only hashes are sent.

Documentation

๐Ÿš€ BTCNotar

Bitcoin Notarization Library

Batch document hashes into a Merkle tree, anchor the root on Bitcoin via OP_RETURN โ€” automatically, once a day โ€” and get back proofs verifiable against the live chain


๐Ÿ“ฆ Repository layout

  • packages/btcnotar โ€” the npm library. Install it with npm install btcnotar. See its README for the full API.
  • packages/btcnotar-mcp โ€” MCP server for AI agents (Claude, Cursor, VS Code): npx -y btcnotar-mcp. See its README.
  • packages/python โ€” the Python client (pip install btcnotar, no dependencies). Same proof format. See its README.
  • spec โ€” the format specification and test vectors for versions in other languages.
  • examples/webapp โ€” a demo Express app using the library: a paid single-hash instant anchor (via Lightning), plus the library's automatic daily batch notarization wired up as a set of /api/notary/* endpoints.

๐Ÿ”— Use case: every git commit on Bitcoin

This repository notarizes its own commits. The GitHub Action .github/workflows/notarize-commits.yml runs scripts/notarize-commits.mjs: for each commit it sends sha256(git cat-file commit <sha>) to the free server, and every hour it saves the proof files on the branch btcnotar-proofs.

# check a commit yourself (only the blockchain is needed)
git cat-file commit <sha> > commit.bin
npx btcnotar verify-file <sha>.btcnotar.json --doc commit.bin

To use it in your repo: copy the script and the workflow file, push, then run the workflow once by hand (Actions โ†’ notarize commits โ†’ Run workflow) to send the whole history.


๐Ÿง  Overview

BTCNotar allows anyone to prove that a document existed at a specific moment in time โ€” without uploading the document itself.

๐Ÿ‘‰ Only a hash (e.g. SHA-256) is ever sent to the library

๐Ÿ‘‰ Hashes are batched into a Merkle tree; only the root touches the blockchain

๐Ÿ‘‰ Every hash gets a small proof that is independently, unambiguously verifiable against the live chain โ€” down to the transaction id, block and date


โš™๏ธ How batch notarization works

  1. ๐Ÿ“ฅ App calls notary.addHash(hash) for each document as it comes in
  2. โฐ Once a day (configurable), the library builds a Merkle tree over everything queued
  3. โ›“๏ธ Only the Merkle root is written on-chain, in one OP_RETURN transaction
  4. ๐Ÿงพ Each hash gets an inclusion proof + the transaction id
  5. ๐Ÿ” notary.verify(hash) recomputes the root from the proof and checks it against the actual on-chain transaction โ€” reporting the block, date and confirmation status

๐Ÿ‘‰ This is fully reversible: with only a document's hash and its proof, anyone can prove whether โ€” and exactly when, in which transaction and block โ€” it was anchored, with no need to trust the notary's own records.


โœจ Features

  • ๐Ÿ“š Installable library (npm install btcnotar), usable from any Node.js app
  • ๐ŸŒณ Merkle-tree batching โ€” unlimited hashes per on-chain transaction
  • โฐ Automatic scheduled settlement (once a day by default, configurable)
  • ๐Ÿ” Reversible proofs โ€” cryptographic + live on-chain verification
  • ๐Ÿ”Œ Pluggable storage (in-memory, JSON file, or bring your own DB) and chain provider
  • ๐Ÿ–ฅ๏ธ CLI (btcnotar add/settle/proof/verify)
  • โšก Demo app: single-hash instant anchoring paid via Lightning (Breez SDK)
  • ๐Ÿ“ก Broadcast via mempool.space
  • ๐Ÿงพ No document storage (privacy-first) โ€” only hashes ever leave your app

๐Ÿงฑ Tech Stack

  • Node.js (library: zero framework dependency)
  • bitcoinjs-lib + tiny-secp256k1
  • mempool.space REST API (default chain provider)
  • Demo app: Express, Breez SDK (Lightning)

๐Ÿ› ๏ธ Setup

1. Clone & install (installs both workspaces)

git clone https://github.com/yordank/BTCNotar.git
cd BTCNotar
npm install

2. Use the library directly

npm install btcnotar   # in your own project

See packages/btcnotar/README.md for the full API and examples.

3. Or run the demo web app

cp examples/webapp/.env.example examples/webapp/.env
# fill in OPRETURN_WIF_MAINNET, BREEZ_API_KEY, BREEZ_MNEMONIC
npm start

๐ŸŒ Open: http://localhost:8787


๐Ÿ”Œ Demo app API

โšก Lightning

POST /api/ln/invoice
GET  /api/ln/status/:checkingId
GET  /api/balance

โ›“๏ธ Instant single-hash anchor (paid)

POST /api/opreturn          { hashHex }

๐ŸŒณ Batch notarization (library-backed, settles automatically once a day)

POST /api/notary/hash        { hashHex }   โ€” queue a hash
POST /api/notary/settle                    โ€” settle the current batch now
GET  /api/notary/proof/:hash               โ€” fetch the stored proof
GET  /api/notary/verify/:hash              โ€” verify against the live chain

๐Ÿ” Security (IMPORTANT)

โš ๏ธ Anchoring uses a real Bitcoin private key (WIF), and the demo app additionally uses a Breez (Lightning) mnemonic and API keys.

๐Ÿ‘‰ Never commit .env to GitHub

๐Ÿ‘‰ If exposed โ†’ rotate immediately

๐Ÿ‘‰ Use only hot wallets with small amounts


๐Ÿ’ก Use Cases

  • ๐Ÿ“„ Document timestamping
  • ๐Ÿง  Intellectual property protection
  • โš–๏ธ Legal proof of existence
  • ๐Ÿ’ป Source code verification
  • ๐Ÿงพ Digital evidence anchoring

โš ๏ธ Limitations

  • โ— Only a hash is stored, never the document
  • โ— Verification requires recomputing the hash of the original document
  • โ— Bitcoin fees vary; one settlement pays one fee for the whole batch
  • โ— Not a legal guarantee by itself (depends on jurisdiction)

๐Ÿš€ Roadmap

โœ… Done

  • Batch anchoring via Merkle tree โ€” only the root goes on-chain
  • Reversible, independently verifiable Merkle proofs
  • Automatic scheduled settlement (daily by default)
  • Installable library / SDK (btcnotar on npm)
  • CLI for add / settle / proof / verify

๐Ÿ” Next

  • Browser-side proof verification widget
  • Pluggable database-backed store (Postgres/SQLite) reference implementation
  • Webhooks on settlement
  • Docker deployment for the demo app
  • Rate limiting / multi-tenant support for the demo app

๐Ÿง  Vision

A lightweight, open-source Bitcoin notarization layer

Not just a website โ€” but:

  • A library / SDK
  • A reference API
  • Infrastructure for proof systems

๐Ÿ’ญ Philosophy

  • ๐Ÿ”— Minimal on-chain data
  • ๐Ÿ” Maximum verifiability
  • ๐Ÿ” Privacy-first
  • ๐Ÿงฉ Composable & open

โšก Support the project

BTC Notar is free. If you like it, you can send any amount of sats to this Lightning address:

trappedknight861@walletofsatoshi.com


๐Ÿ“„ License

MIT


โš ๏ธ Disclaimer

This software is provided for educational purposes.
Use at your own risk.

๐Ÿ‘‰ Always protect your private keys and funds.

No installation packages available.

Remote