Combining RFC 9530 Content-Digest and RFC 9421 HTTP Message Signatures lets browsers verify
in-tab that a quoted passage matches exact origin bytes served by the publisher.
Origin signatures validate via crypto.subtle.verify() against
/.well-known/http-message-signatures-directory, and altering a single word highlights the diff
and fails verification immediately.
CDN wrapper injections or minor whitespace normalization break whole-body byte-level
Content-Digest checks unless canonical block spans are signed independently.
1. Fetch Signed Origin Document
Fetches GET /api/articles/:id and the publisher key directory at
/.well-known/http-message-signatures-directory, then verifies both whole-body and per-paragraph
signed digests.
2. Tamper & CDN Rewrite Verifier
Edit any character below to test single-word tampering (confirm signal), or inject a harmless CDN wrapper / whitespace change to compare whole-body vs. canonical block-span signatures (falsify signal).
Origin vs. Current Word Diff
3. Sign Custom Excerpt at Edge (POST /api/sign-custom)
Submit any sentence to mint fresh RFC 9530 Content-Digest, X-Block-Digests, and
RFC 9421 ECDSA P-256 signature headers from the Worker.
RFC 9421 Sign-and-Verify Pipeline
Implementation & Verification Contract
The Worker attaches RFC 9530 Content-Digest, canonical X-Block-Digests, and RFC 9421
ECDSA P-256 Signature headers in src/rfc9421.ts, serves the publisher JWK at
/.well-known/http-message-signatures-directory, and verifies bytes client-side in
public/lib/verifier.js using WebCrypto.
// Unverified quote card: no cryptographic binding to origin bytes
const citation = {
quote: "Effective isolation requires an opaque null origin.",
sourceUrl: "https://aifoc.us/the-browser-is-the-sandbox/#:~:text=opaque",
};
// Any proxy, cache, or summarization step can alter words silently
cardQuoteEl.textContent = citation.quote;
cardLinkEl.href = citation.sourceUrl;
// public/app.js + public/lib/verifier.js
const [res, dir] = await Promise.all([
fetch("/api/articles/sandbox", { cache: "no-store" }),
fetch("/.well-known/http-message-signatures-directory").then((r) => r.json()),
]);
const rawBodyText = await res.text();
const report = await verifySignedResponse({
publicKeyJwk: dir.keys[0],
method: "GET",
path: "/api/articles/sandbox",
rawBodyText,
contentDigestHeader: res.headers.get("Content-Digest"),
signatureInputHeader: res.headers.get("Signature-Input"),
signatureHeader: res.headers.get("Signature"),
extraHeaders: { "x-block-digests": res.headers.get("X-Block-Digests") },
});
Complete Origin Signer & Browser Verifier Wiring (src/rfc9421.ts + src/worker.ts + public/lib/verifier.js)
Matches the active Worker signing pipeline and browser verification code: whole-body SHA-256 digest plus
signed canonical paragraph hashes in X-Block-Digests.
// 1. Origin Edge Signer (src/rfc9421.ts + src/worker.ts)
const blockDigests = await computeCanonicalBlockDigests(article.paragraphs);
const signed = await signMessage(
ctx.privateKey,
ctx.kid,
"GET",
"/api/articles/hypermedia",
rawBody,
Math.floor(Date.now() / 1000),
[["x-block-digests", blockDigests]],
);
// Emits Content-Digest, X-Block-Digests, Signature-Input, Signature
// plus Access-Control-Expose-Headers so cross-origin browsers can verify.
// 2. Browser Verifier (public/lib/verifier.js)
const expectedDigest = await computeContentDigest(editedBody);
const signatureMatches = await crypto.subtle.verify(
{ name: "ECDSA", hash: "SHA-256" },
importedPublicKey,
sigBytes,
new TextEncoder().encode(signatureBase),
);
const blocks = await verifyCanonicalBlocks(editedBody, xBlockDigestsHeader);
// Whole-body check fails on CDN whitespace rewrites; canonical block digests still verify
// when quoted paragraph text is intact, and fail immediately on a 1-word quote edit.
Unverifiable copy-pasted quotes that cannot be checked against publisher origin bytes or public keys.
Covered components in @signature-params (@method, @path, content-digest, x-block-digests), key discovery at /.well-known/http-message-signatures-directory, and CORS header exposure.
Whole-body byte digests break under CDN HTML minification or ad wrappers; durable citation provenance requires signing canonical block spans alongside full responses.