This is the documentation for version 0.5. Read this page for version 0.6, the latest.

Architecture#

Grantstamp is built so that nobody has to trust a server.

Owners sign their own stamps. The registry puts them in order in a public log and signs it. Witnesses cosign that log. Mirrors copy it. An agent can read from any of them and check every byte.

Who holds what Owner signs every stamp with a key only the owner holds stamp Registry puts writes in order in one public log, and signs it Witnesses cosign the log only when it extends what they saw before log head out, cosignature back Mirrors copy the log, the public records and the check map. Any plain web host will do. copy Agent, or you reads from any mirror and checks every byte data proof one, run by the project many, run by anyone A mirror can go silent. It cannot change, hide or add anything without being caught. The registry cannot show two histories. The witnesses would refuse to cosign.

Who does what#

Role Run by Holds Trusted for
Owner Each owner Their own signing key Their own claims
Registry The project All records, private data, the log key Putting writes in order. A lie is caught by the witnesses.
Witnesses The project today (two GitHub jobs), then others The last log head they cosigned Not helping the registry show two histories
Mirrors Anyone Copies of the log, the public records and the check map Nothing, except being reachable
Agent, or any reader Everyone The log's public key and the list of witnesses Itself

Three things follow from this.

The full design, with what each party could try and what catches it, is in Mirrors and witnesses.

What runs today#

The design lets anyone run a witness or a mirror. Who runs each part today, and what is not done yet, is kept in one place: the status page.

The software#

One Python package holds the client. A second holds the registry server. The website is static.

The software, and where it runs Owner's machine grantstamp command line tool Fingerprint engine Agent's machine MCP server for AI clients Claude Code hook Check page in the browser Fingerprint engine content never leaves Registry API signatures, rate limits Matching bands: exact to none Policies and licence tokens Transparency log tiles, checkpoints, receipts Check map blinded tokens for mirrors Alerts SQLite or PostgreSQL Outside the registry Witnesses cosign the log Daily witness Bitcoin timestamps Mirrors any static web host Owner's channel Slack, Discord, webhook signed stamp digests copy
Component Code Runs where Talks to
Fingerprint engine src/grantstamp/fingerprint/ wherever the content is nothing (offline)
CLI src/grantstamp/cli.py owner and agent machines registry, mirrors
MCP server src/grantstamp/mcp_server.py agent's machine, started by the AI client registry
Claude Code hook src/grantstamp/hook.py agent's machine, started by Claude Code registry
Log and proofs src/grantstamp/tlog.py, note.py every machine that verifies nothing (offline)
Mirror src/grantstamp/mirror.py any machine, then any static web host registry, or another mirror
Witness src/grantstamp/witness.py a scheduled job or a small server registry
Registry API server/src/grantstamp_server/app.py (AGPL-3.0) your server (Render, VPS, Docker) database, webhooks, DNS over HTTPS
Matching grantstamp_server/matching.py registry database
Log tree grantstamp_server/logtree.py registry database, witnesses
Check map grantstamp_server/nodemap.py, nodecheck.py registry builds it, clients read it mirrors
Storage grantstamp_server/db.py, store.py registry SQLite (default) or PostgreSQL
Website src/grantstamp/site/ GitHub Pages, and the registry itself registry API

A check at the registry#

This is the usual path. POST /v1/check does these steps in order.

  1. Authenticate. The caller is anonymous, or signs as an agent or an owner. Unknown keys can be found through Signature-Agent.
  2. Rate-limit by caller class. Anonymous callers can add quota with a proof-of-work header.
  3. Parse the bundle and drop background features: common runtime strings and chunks.
  4. Look up exact SHA-256 hashes, and each similarity layer's hashes in the inverted index.
  5. Suppress features shared by three or more different owners.
  6. Grade each pair of query file and registered file. Aggregate per stamp. Apply marker and manifest claims.
  7. Apply the policy. For medium and above, evaluate the owner's policy for the use, purpose and licence tokens. Medium turns deny into ask.
  8. Record events and raise alerts for matches and probing. Webhooks go out in the background.
  9. Answer with the bands, decisions, guidance text and a receipt signed by the registry.

A check through a mirror#

This path is experimental and off by default. It lets a mirror answer a check without being trusted, and without learning anything about the file.

A check through a mirror Agent your machine Mirror trusted for nothing Token service at the registry 1 the log checkpoint signed by the registry, cosigned by witnesses 2 the check map's notice and lists must match what the log committed to 3 tokens for this file's features counted against a rate limit, names the current map 4 the map pieces where the tokens would be each token is proven present, or proven absent 5 Grade the evidence and apply the owner's policy with the registry's own matching code: allow, ask or deny A mirror that fails any check, or does not answer, is skipped.

A mirror that fails any check, lacks a file or does not answer is skipped. The registry is the last resort.

One limit remains. The token service runs at the registry, so a check through mirrors still needs the registry awake. Auditing a mirror does not: grantstamp audit --from <mirror> works with the registry switched off.

Data model#

Security boundaries#

Scaling path#

Stage Change
Prototype (now) 1 registry instance, SQLite or PostgreSQL, in-memory rate limits. The log is a Merkle tree served as static tiles, so reads can already move to mirrors. Measured with 3,000 registered files on a 2-CPU machine: 12 ms median check, about 65 checks a second, about 76 KB of database per executable (bench/LOAD.md).
More readers More mirrors on static hosts and CDNs. The token service on an always-on host, apart from the registry.
Thousands of stamps PostgreSQL, a connection pool, Redis rate limits, a CDN in front of the API
Millions of files Fixed-size sketches per file in place of one index row per feature. Tables partitioned by hash. Batch upload via object storage. Check maps built incrementally.
Billions of files Move the feats index to a key-value store such as ScyllaDB or RocksDB, sharded by hash prefix
Function-level similarity Add an approximate-nearest-neighbour index such as pgvector or FAISS for code embeddings
Speed Port the fingerprint core to Rust with the same protocol constants. Ship it as a wheel, and as WebAssembly for the browser.

Source of this page on GitHub. Documentation for Grantstamp 0.5, licensed CC BY 4.0.