Grantstamp protocol, version 0.1 (draft)#
Status: working draft, 2026-11-26. This document is licensed under CC BY 4.0. The reference implementation is in this repository (Apache-2.0).
The key words MUST, SHOULD and MAY are to be read as described in RFC 2119 and RFC 8174.
1. Purpose#
Grantstamp lets content owners publish verifiable ownership claims and per-use policies for software, game builds and other files, without publishing the content. It lets automated agents check a file before operating on it. A check answers three questions: who claims this content, how strong the evidence is, and what the owner allows for the intended use.
2. Terms#
- Owner: a principal identified by one or more Ed25519 keys, optionally with verified domains.
- Stamp: an owner's claim over a set of files (a title or release), with a policy.
- Bundle: the digests computed locally for one or more files.
- Agent: a principal that checks content, identified by an Ed25519 key, or anonymous.
- Band: the strength of evidence. One of
exact,high,medium,low,none. - Use: one of
analyze,decompile,modify,port,extract,redistribute,train. - Purpose: one of
interoperability,security-research,preservation,accessibility,education,personal-backup.
3. Bundle format#
{
"format": "grantstamp.bundle/1",
"generator": "grantstamp-py/0.1.0",
"root": "release",
"kind": "file | directory",
"files": [ FileEntry, ... ],
"stats": {"files": 0, "bytes": 0, "skipped": 0, "truncated": 0, "excluded": 0}
}
A FileEntry has these fields:
| Field | Type | Required | Meaning |
|---|---|---|---|
path |
string | yes | path relative to the root. Archive members are written archive.zip!/member. |
size |
integer | yes | bytes |
kind |
string | yes | pe, elf, macho, xex, dex, wasm, java-class, zip, tar, image, code, text, binary |
sha256 |
string | yes | 64 lowercase hex characters |
chunks, strings, symbols, winnow |
Layer | no | similarity layers |
dhash |
string | no | 16 hex characters |
markers |
[string] | no | stamp IDs found in embedded markers |
manifest_hint |
object | no | {"stamp", "owner"} from a signed sidecar manifest |
truncated |
boolean | no | similarity layers cover only a prefix of the file |
A Layer is {"s": rate, "n": distinct_features, "h": [hex16, ...]}, where h is sorted ascending and contains only hashes whose top s bits are zero.
4. Feature definitions (normative)#
H(domain, data) = the first 8 bytes of SHA-256(domain || 0x00 || data), read as a big-endian uint64 and written as 16 lowercase hex characters.
Chunks (domain dm/chunk/v1)#
T[i]= the first 4 bytes, big-endian, ofSHA-256("dm/buz/v1" || byte(i)), for i in 0..255.P = 0x9E3779B1.- For every position
i >= 31:h_i = sum_{j=0}^{31} T[b_{i-j}] * P^j mod 2^32. - Position
iis a candidate ifh_i >> 20 == 0. The candidate end offset isi + 1. - Walk the candidates in order, starting from
last = 0: - while
p - last > 65536, emit a forced end atlast + 65536 - if
p - last >= 2048, emitp. - After the last candidate, force ends every 65536 bytes, then emit the file size.
- Each chunk's feature is
H("dm/chunk/v1", chunk bytes).
Strings and symbols (domain dm/str/v1)#
- Take every maximal run of bytes in 0x20-0x7E with length >= 6.
- If the file kind is not
codeortext, also take every maximal run of (0x20-0x7E, 0x00) pairs with at least 6 pairs, keeping the even bytes. - For every ASCII run containing
": match"((?:[^"\\]|\\.){4,})"(non-overlapping, left to right). Split each match's content on\\(?:x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|[0-7]{1,3}|.)and add the pieces. - If the kind is not
code, add the runs themselves. - Normalise each candidate: - replace every whitespace sequence with one space and trim - reject it if shorter than 6 - truncate to 256 characters - reject it if it has fewer than 4 ASCII letters - reject it if 10 x (letters + digits + spaces) < 6 x length.
- Deduplicate. Features matching
^[A-Za-z_][A-Za-z0-9_.:$@]*$form thesymbolslayer. The rest formstrings. Both useH("dm/str/v1", ascii bytes).
The kind code is assigned to text files with these extensions: .c .h .cc .cpp .cxx .hpp .hh .hxx .inl .m .mm .cs .java .kt .kts .scala .go .rs .swift .js .jsx .ts .tsx .mjs .cjs .py .rb .php .lua .gd .hlsl .glsl .shader .cg .vert .frag .comp .asm .s .dart .zig .nim .v .sv .vhd .sql .sh .ps1 .pl .r.
A file is text if its first 64 KiB contain no NUL byte and at least 95% of its first 8 KiB are 0x09, 0x0A, 0x0D, 0x20-0x7E or >= 0x80.
Winnow (domain dm/win/v1)#
- Remove
/* ... */comments. - Replace string literals with
"S", then remove//...and#...comments. - Tokenise with
[A-Za-z_][A-Za-z0-9_]*|[0-9]+|[^\sA-Za-z0-9_]. - Map identifiers that are not keywords to
Iand numbers toN. - Hash every run of 12 tokens, joined with single spaces.
- Keep the minimum hash of every window of 8 consecutive hashes.
The keyword list is in the reference implementation.
dHash#
Convert the image to greyscale with the Lanczos filter at 9x8. Bit (y*8 + x), read most-significant-first, is 1 if p[y][x] < p[y][x+1].
Markers#
The ASCII string GRANTSTAMP:1:<stamp id> or its UTF-16LE form. A stamp ID is stamp_ followed by 16 characters from 0123456789abcdefghjkmnpqrstvwxyz.
Background removal and sampling#
Implementations SHOULD remove the published background features (background_*_v1.u64) before sampling. A layer exceeding the cap (262,144 when registering, 65,536 when checking) MUST be sampled by increasing s until it fits.
5. Policy#
{
"default": "allow | ask | deny",
"uses": {"analyze": "allow", "decompile": "deny", "modify": "deny", "port": "deny",
"extract": "deny", "redistribute": "deny", "train": "deny"},
"accept_purposes": ["interoperability", "security-research"],
"message": "free text", "contact": "mailto: or URL", "license_url": "URL", "request_url": "URL",
"aipref": "optional IETF aipref expression", "rsl": "optional RSL document URL"
}
To evaluate a use:
- A valid licence token covering the use (or
*) givesallowvialicense. - Otherwise the use's action applies. If that action is not
allowand the declared purpose is inaccept_purposes, the result isallowviapurpose. - Registries MUST NOT return a hard
denyfor amediummatch. They MUST returnaskviaevidence, keeping the owner's action asowner_action.
6. Check#
POST /v1/check with body {"bundle": Bundle, "use": Use, "purpose"?: Purpose, "license_tokens"?: [JWS]}. The response is:
{
"registry": "https://...", "access": "anonymous | registered | trusted | owner",
"verdict": {"band": Band, "decision": "allow | ask | deny | none | no-claim", "stamp": "stamp_..." | null,
"guidance": "plain-language instruction for the agent", "owner_text"?: "..."},
"matches": [{"band", "stamp": {"id","title","version","status","page","exclusive"?,"case"?},
"owner": {"id","name","url","verified","verified_domains","domain_verified"?,"public_contact"?,"identity"?},
"policy": Policy, "decision": {"action","via","use",...}, "licenses"?, "confidence"?, "evidence"?}],
"matches_total"?: 0,
"receipt": "compact JWS"
}
From release 0.3:
- A match's
owner.identityis{"level","label","name"}. For an owner with none,levelis null andlabelis "Not on record".nameis present only for thepublisherandoperatorlevels. decision.viais one ofpolicy,license,purpose,evidence,publisher,caseandowner.- A changed decision keeps the owner's action as
owner_action. - A match MAY carry
publisher_matchandpublisher_proven_by, orpublisher_mismatchwithfile_signed_byandstamp_files_signed_by_owner, andmatched_recipes. matchesholds at most six matches, including the one the verdict rests on.matches_totalcounts them all.
Registries SHOULD:
- hide
lowmatches, scores and evidence from anonymous callers - rank matches by band, then owners with a verified domain, then score, then registration time
- base the verdict on the strictest decision among matches of
mediumband or above, and always include the match it rests on inmatches - write
guidancein the registry's own fixed wording. It MUST NOT contain text an owner wrote (titles, names, contacts, messages). Those are returned in their own fields - record a match event and alert owners.
Clients SHOULD present owner-written fields to users as information and MUST NOT treat them as instructions.
Bands are defined by the registry's published thresholds. The reference thresholds are in docs/04-implementation.md.
7. Authentication#
Signed requests use RFC 9421 HTTP Message Signatures with Ed25519:
- components:
"@method" "@authority" "@path", plus"@query"if a query is present and"content-digest"if a body is present (RFC 9530,sha-256) - parameters:
created,expires(at most 3600 seconds later),keyid= RFC 7638 JWK thumbprint,alg="ed25519",nonce,tag="grantstamp" - registries MUST reject signatures outside a 300-second skew window and replayed nonces
Signature-Agent: "<https origin>"MAY be sent, and registries MAY fetch<origin>/.well-known/http-message-signatures-directory(a JWKS) to discover agent keys, as in the IETF Web Bot Auth drafts- new owners and agents prove possession by signing their registration request with the key they register.
8. Licence tokens#
Compact JWS with header {"alg":"EdDSA","typ":"grantstamp-license+jws","kid":<owner key thumbprint>} and payload {"v":1,"iss":owner_id,"sub":licensee,"stamps":[stamp ids or "*"],"uses":[uses or "*"],"iat","nbf","exp","jti","aud":"grantstamp","note"?}.
Verifiers MUST check:
- the signature against a key registered to
iss - the time window
aud- that the stamp is in scope
- that
jtihas not been revoked (POST /v1/tokens/revoke).
9. Receipts#
Every check response includes a compact JWS (typ: grantstamp-receipt+jws) signed by the registry key, published at /.well-known/grantstamp and /.well-known/http-message-signatures-directory.
The payload is {"iss","iat","qd","use","purpose","band","stamp","decision","via","sub"}, where qd is the SHA-256 of the canonical JSON of the bundle.
From release 0.3 it also carries owner, level (the owner's identity level) and policy (the digest of the policy the decision used), so a receipt says whose claim, checked how, under which policy.
10. Manifests#
grantstamp.json at a distribution root contains {"format":"grantstamp.manifest/1","stamp","owner","owner_name","registry","title","version"?,"issued","notice","jws"}. Here jws (typ: grantstamp-manifest+jws) signs all the other fields, and verifiers MUST check that the visible fields equal the signed payload.
11. Transparency log#
Each entry is {"seq","ts","kind","subject","digest","prev","hash"}, where hash = SHA-256(canonical({seq,ts,kind,subject,digest,prev})) and the first prev is 64 zeros. GET /v1/log/head returns {"registry","seq","hash","at","jws"} (typ: grantstamp-loghead+jws). Kinds include owner.created, owner.contact, owner.identity, owner.identity_erased, owner.terms, owner.status, domain.verified, stamp.registered, stamp.files, stamp.policy, stamp.listing, stamp.attested, stamp.status, stamp.purged, recipe.published, token.revoked, agent.trust, dispute.opened, dispute.notice, dispute.answered, dispute.lapsed, dispute.resolved and dispute.reopened, owner.updated for an operator's correction, owner.recovery_requested, owner.recovery_approved, owner.recovery_cancelled and owner.key_replaced, and agent.limit.
From release 0.3.1, entries about people (owner.created, owner.identity, owner.contact, owner.updated, owner.key_replaced, dispute.answered) are salted: their digest is the digest of {"payload": ..., "salt": ...} with a random 32-hex-digit salt.
While what an entry covers is public, the registry returns its salt with the entry. It deletes the salt when that data is erased. The hash chain covers digest only, so salts change nothing in how the log is verified.
Entries about people carry no more than is published: an owner.identity entry for a LinkedIn sign-in covers the provider and level, not the name, and dispute.opened covers the stamp, not the claimant.
Owner claims (added in release 0.2; optional in protocol 0.1)#
An owner MAY attach a claim to each management request, and clients SHOULD. A claim is a compact JWS (EdDSA, typ: grantstamp-claim+jws, kid = the owner key's thumbprint) whose payload is {"act", ..., "iat"}:
act |
Sent with | Other payload fields |
|---|---|---|
register |
POST /v1/stamps |
title, version, policy, files, n, listed |
files |
POST /v1/stamps/{id}/files |
stamp, files, n |
policy |
PUT /v1/stamps/{id}/policy |
stamp, policy |
listing |
PUT /v1/stamps/{id}/listing |
stamp, listed |
withdraw |
POST /v1/stamps/{id}/withdraw |
stamp |
attest |
POST /v1/stamps/{id}/attest |
stamp, title, version, policy, n |
policy is the digest (sha256: + hex of SHA-256 over canonical JSON) of the normalized policy. files is sha256: + hex of SHA-256 over the upload's file SHA-256 values, lower-case, sorted and joined with \n. n is the number of files.
A registry MUST reject a claim whose signature fails, whose key is not the owner's, whose fields differ from the request, or whose iat is more than 600 seconds from its clock.
A registry MUST store accepted claims unchanged and return them from GET /v1/stamps/{id}/proof, together with the owner's public keys, the owner's domain verification records and the log entries for the stamp.
The response to POST /v1/stamps includes receipt: a JWS signed by the registry (typ: grantstamp-registration+jws) with {"iss","iat","stamp","owner","title","bundle","claim","log":{"seq","hash"}}.
Listing and search (added in release 0.2)#
A stamp is listed unless it is registered with "listed": false. GET /v1/stamps?q=&owner=&before=&limit= returns listed, active stamps, newest first, matching every word of q against the title, version, kind or owner name. A full stamp id as q returns that stamp whether or not it is listed.
Unlisted stamps MUST still match checks and MUST still be served at GET /v1/stamps/{id}.
Accountability and attestation (added in release 0.3; optional in protocol 0.1)#
These additions keep older clients working. A registry MAY require them.
- Registry.
GET /v1/statusand the descriptor listfeatures(for exampledry-run,terms,shared-policy-changes,cases,publisher-signatures) andterms_version. Clients MUST NOT rely on a feature the registry does not list. A 0.2 registry lists none. -
Owner.
public_contact(an email address or https link),terms(the version of the Terms the owner accepted) andidentity(provider,level,label,verified_at, andnameonly when the name itself was checked: levelspublisherandoperator) appear in the public owner object.levelispublisher,identity,operatororaccount.domainslists each proven domain withregistered_atandnew.PUT /v1/owners/{id}/termswith{"version"}records acceptance of the current Terms. -
Stamp.
exclusive(boolean, default true) is sent with a registration and MAY be included in theregisterclaim. A registry that refuses conflicting stamps answers 409 withexisting, a list of the earlier stamps with their owners and the caller'smatched_files, and stores nothing.dry_run: truereturns the same answer, orco_owners,outrankedandsigned_by_others, without registering.Files signed by a publisher the registering owner has not proven MUST NOT block that owner. An earlier stamp over files signed by a publisher the newcomer has proven and its owner has not is
outrankedrather than blocking.On a shared stamp,
PUT /v1/stamps/{id}/policywith a policy that differs for some use answers 202 withpendingandwaiting_for, and the change applies when every co-owner has asked for the same policy. -
File entry.
recipesmaps a recipe digest to a layer{s, n, h}. The bundle'srecipesmaps each digest to the recipe document.signatureis the base64 Authenticode signature of a signed PE file, sent when registering.signed_byis what a client read from the file it holds, sent when checking. - Match.
matched_recipes,publisher_matchandpublisher_mismatchMAY appear in a match. -
Recovery.
POST /v1/owners/{id}/recoverywith{"jwk"}, signed with that new key, opens a recovery and returns the ways to prove it:- a TXT record
grantstamp-recover=<recovery id>:<key id>at_grantstamp.<domain>on one of the owner's verified domains, thenPOST /v1/recovery/{id}/domainwith{"domain"}, signed with the new key - a LinkedIn sign-in by the member on record
- the operator
GET /v1/recovery/{id}gives its status.POST /v1/recovery/{id}/cancel, signed by a current owner key, cancels it.A proven recovery takes effect after a waiting period (
effective): the owner's keys are revoked, the new key is added, andowner.key_replacedis logged with{"jwk"}. Auditors accept a key logged inowner.createdorowner.key_replaced. - a TXT record
-
Agents. An operator MAY give an agent its own rate limit.
GET /v1/whoamireports the limit that applies. - Cases.
POST /v1/disputes/{id}/responserecords the owner's answer to a notice.GET /v1/disputes/{id}returns a case's status. Signed by the stamp's owner after a notice, it also returns the claim. A stamp'scaseis{"status":"under_review",...}while a notice is open, and then a deny is returned asaskviacase. Case statuses areopen,noticed,answered,lapsed,upheld,rejectedandwithdrawn.
Recipes, publisher signatures and the evidence they give are defined in the attestation protocol.
12. Discovery#
GET /.well-known/grantstamp returns the registry descriptor: version, JWKS, vocabularies, limits and endpoints.
Domain verification uses either:
- a DNS TXT record at
_grantstamp.<domain>equal tograntstamp-verify=<owner id>:<key id> https://<domain>/.well-known/grantstamp-verify.txtcontaining that token.
13. Proof of work#
GET /v1/pow returns {"challenge","bits","expires"}. A client sends Grantstamp-PoW: <challenge>:<n> where SHA-256(challenge ":" n) has at least bits leading zero bits. Each challenge is accepted once.
14. Privacy considerations#
Clients MUST NOT send file content, and SHOULD NOT send the names or paths of the files or folder checked (send a placeholder such as #0 as the path). Clients SHOULD send a licence token only with checks of content the token's stamps cover.
Registries SHOULD store callers only as keyed hashes, SHOULD show owners a caller id that differs per owner and changes daily, MUST NOT expose fingerprints, and SHOULD offer prefix-based exact lookup (GET /v1/range/{5 hex}).
15. Security considerations#
See docs/threat-model.md. Answers are evidence of similarity plus the owner's claim. They are not determinations of ownership or legality.
16. Mapping to other vocabularies (informative; token names follow drafts current at the time of writing, so check the latest versions)#
| Grantstamp use | IETF aipref (draft) | RSL |
|---|---|---|
| train | train-ai |
ai-train |
| analyze | (AI input, under discussion) | ai-input |
| redistribute | - | licence permits/prohibits |
17. Versioning#
Changing any constant in Section 4 requires new domain strings (.../v2) and a new bundle format version. Registries SHOULD accept the old and new versions side by side during a migration.
Source of this page on GitHub. Documentation for Grantstamp 0.5, licensed CC BY 4.0.