forgetproof Try the button

Rendered from packages/forgetproof-verify/README.md; raw Markdown.

forgetproof-verify#

forgetproof-verify is a JavaScript module that checks a ForgetProof receipt without trusting the server that served it: the Ed25519 signature, the issuer's published keys and the declared outcome, reported apart. This page shows you how to get the module, make the one call and read its three verdicts; it then lists the full API and explains key rotation and how verification runs in a browser and in Node.

Status: not yet on npm. The demo site serves the three files, and this page says where.

A receipt is one holder's signed statement about one erasure: counts, timestamps and words from a fixed list, never a path or a value. The issuer is the party whose key signed it, and it publishes its keys in a discovery document on its own origin. An outcome is one of six words the receipt declares. The glossary has the rest.

Get the module#

One ES module, no dependencies, no bundler; it runs as-is in modern browsers and in Node 18 or later. Copy the three files from the demo site next to your page or into your project:

for f in index.js canonical.js ed25519.js; do curl -s -o $f https://forget.stellarminds.ai/static/$f; done
node --input-type=module -e 'import { hasWebCryptoEd25519 } from "./index.js"; console.log(await hasWebCryptoEd25519())'

The second command prints true on Node 18 or later. In a page, import { verifyEvidence } from "./index.js" from a <script type="module"> is the whole install.

Verify a receipt#

verifyEvidence is the one call to make when a person, a page or an auditor is handed a receipt. It answers three questions separately and never lets one stand in for another:

import { fetchIndex, verifyEvidence } from "./index.js";

// The expected issuer's discovery, fetched from the issuer's own origin (never from a URL the receipt names).
const index = await fetchIndex("https://company.forget.stellarminds.ai/forget-me/v1");
const report = await verifyEvidence(receipt, { issuer: { doc: index, url: "https://company.forget.stellarminds.ai/forget-me/v1" } });
console.log(report.summary.join("\n"));

It prints four lines: the signature, the issuer, the declared outcome, and the file hashes. For a good receipt from that Company they begin "Signature valid: key … signed exactly this receipt", "Issuer confirmed: …", "Declared by the issuer: outcome inspected-and-clear …", and "A portable receipt carries no file hashes …". A receipt from anyone else begins its second line "Issuer rejected". The report's fields:

report.signature; // { ok: true, fingerprint: "…" }                        1. the bytes are what the key signed
report.issuer;    // { status: "confirmed" | "pinned" | "rejected" | "unconfirmed", why, claimed, published, source, url }
report.outcome;   // { kind: "portable", outcome: "inspected-and-clear", verdict: "CLEAN", consistent, settled, coverage: {inspected, checks, limits, scope}, before, after, actions, … }
report.files;     // { listed, checked: false, note: "… a browser cannot inspect a remote disk" }
report.ok;        // signature valid AND issuer confirmed or pinned
report.summary;   // four sentences, one per line above

The issuer verdicts#

issuer.statusMeans
confirmedThe signing key is one the expected issuer publishes in the discovery you fetched from its own origin (issuer.doc or issuer.keys).
pinnedNo discovery was consulted; the key matches the pinnedKey you obtained out of band (offline verification). Your trust in the pin, not an issuer confirmation.
rejectedDiscovery (or the pin) was consulted and the key is not there.
unconfirmedNothing to check the key against. The key embedded in the receipt never confirms an issuer by itself. A valid signature with an unconfirmed issuer is merely well-signed.

outcome is what the receipt declares: the issuer's statement of outcome, verdict and coverage. A signature proves it was not altered, not that it is true. For a forget-me-receipt/1 it also says whether the outcome word and the verdict word agree (consistent) and whether the outcome is settled. For a forgetproof-receipt/0.x it carries the verdict, the scan counts and the number of listed files.

files: hashes help only where the files are. Pass files (bytes by path) when you have them, as on the machine that holds the store; a page in a browser cannot inspect a remote disk, and the report says so.

The older calls#

verifyReceipt and its companions predate verifyEvidence and remain for engine receipts and the 0.2 provider surface:

import { verifyReceipt, verifyFiles, fetchWellKnown, verifyAgainstWellKnown } from "./index.js";

const receipt = JSON.parse(await (await fetch("/receipts/case-4471.json")).text());

// 1. Is the receipt intact, and who signed it?
const result = await verifyReceipt(receipt);
// { ok: true, fingerprint: "f19ea5a2ecffcb259fa5b96e33ae0ded", format: "forgetproof-receipt/0.2", verdict: "CLEAN" }
// or { ok: false, why: "the signature doesn't match this receipt", ... }

// 2. Was it signed by the key you expected? (public key or fingerprint, as `forgetproof key` prints)
await verifyReceipt(receipt, { expectedKey: "f19ea5a2ecffcb259fa5b96e33ae0ded" });

// 3. Do the files on disk still match what the receipt hashed?
await verifyFiles(receipt, { "notes.db": await readBytes("notes.db") });
// { ok: true, mismatched: [], missing: [] }

// 4. Hosted provider: is the key the one it publishes?
const wellKnown = await fetchWellKnown("https://pim.example");
await verifyAgainstWellKnown(receipt, wellKnown);

API#

FunctionDoes
verifyEvidence(receipt, {issuer?, pinnedKey?, files?, forceFallback?})The report above. issuer is {doc} (a ForgetMe index or a 0.2 well-known document) or {keys: [...]} plus source and url for the report.
fetchIndex(indexUrl, fetchImpl?)GETs a ForgetMe v1 index (GET {endpoint}) and insists on namespace, version "1" and keys.
canonicalize(value): stringPython's json.dumps(v, sort_keys=True, separators=(",", ":"), ensure_ascii=False): keys sorted by code point, no whitespace, non-ASCII raw. Integers only; floats throw.
verifyReceipt(receipt, {expectedKey?, forceFallback?}){ok, why?, fingerprint?, format?, verdict?}. why is one of: unknown receipt format …, malformed public key, malformed signature, signed by a different key, the signature doesn't match this receipt.
fingerprint(publicKeyB64url): Promise<string>First 32 hex characters of SHA-256 over the raw 32-byte key.
verifyFiles(receipt, {path: bytes}){ok, mismatched, missing} against receipt.files. Extra files are ignored.
fetchWellKnown(originOrUrl, fetchImpl?)GETs /.well-known/forgetproof.json (when given an origin) and returns the parsed document.
verifyAgainstWellKnown(receipt, wellKnown, options?)Rejects unless receipt.public_key is wellKnown.public_key or in wellKnown.keys[].public_key, then verifyReceipt.
publishedKeys(wellKnown)The keys a well-known document lists.
verifySignatureBytes(sig, msg, pub, options?)Raw Ed25519 verify, for anything else signed with the same key.
signedBytes(receipt)The exact bytes the signature covers.
hasWebCryptoEd25519()Whether this runtime verifies Ed25519 natively.
fromBase64url, toBase64url, sha256Helpers that work without Buffer.

Accepted formats: forgetproof-receipt/0.1, forgetproof-receipt/0.2 and the ForgetMe portable receipt forget-me-receipt/1, all with the same signing rule. Verdicts: CLEAN, RESIDUE_REMAINS, UNVERIFIABLE. Portable outcomes (OUTCOMES, worst first): error, bytes-still-found, queued, unsupported, intentionally-retained, inspected-and-clear, each mapped to a verdict by VERDICT_OF. The JSON Schemas are described on the schemas page.

Key rotation#

An issuer rotates by publishing the new key and keeping the old ones listed: keys[] in the ForgetMe index (GET {endpoint}) and in /.well-known/forgetproof.json (public_key is the current key; keys[] lists every key whose receipts should still verify, each with key_fingerprint and an optional valid_from). publishedKeys, verifyAgainstWellKnown and verifyEvidence accept any listed key, so receipts signed before a rotation keep verifying as long as the issuer lists the old key. A key an issuer removes from its list no longer confirms it; receipts signed with it still verify by signature (verifyReceipt) and against a pin, and verifyEvidence then reports the issuer as rejected.

How verification runs#

Ed25519 uses WebCrypto (crypto.subtle with {name: "Ed25519"}) when the runtime has it: Node 18+, Chrome, Firefox, Safari 17+. Elsewhere the bundled src/ed25519.js, a small RFC 8032 verifier written with BigInt, takes over automatically; {forceFallback: true} selects it explicitly, which the tests use to exercise both paths. SHA-256 and SHA-512 always come from WebCrypto, so in a browser the page needs a secure context (HTTPS or localhost). Nothing is imported from Node built-ins, so the same files work from a <script type="module">.

What a good result means#

verifyReceipt's ok: true says the receipt has not changed since the holder of public_key signed it, and names that key by fingerprint. It does not say who holds the key: compare the fingerprint with one you obtained out of band (pinnedKey), or with the discovery the issuer serves at its own origin (fetchIndex, fetchWellKnown). verifyEvidence reports those as separate verdicts, and neither says the issuer did what the receipt declares.

Tests#

npm test

It ends with a node:test summary whose fail count is 0. The three fixtures under test/fixtures/ were signed by the Python implementation and pin the canonicalization: if canonicalize drifts by a byte, their signatures stop verifying.

Next steps#