Signed Web Citations

When an application summarizes or quotes an article, readers have no cryptographic proof that the quoted excerpt matches what the publisher served. This Worker signs origin responses with RFC 9530 Content-Digest, canonical per-paragraph X-Block-Digests, and RFC 9421 HTTP Message Signatures verified directly in the browser via crypto.subtle.verify().

Hypothesis

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.

Confirm signal

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.

Falsify signal

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.

Waiting for key directory fetch...

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).

Whole-Body RFC 9530 + 9421 Awaiting fetch

Signed Canonical Block Spans Awaiting fetch

Origin vs. Current Word Diff

Load an article to inspect byte verification 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

Origin Edge Worker 1. SHA-256 body + blocks 2. Build Signature-Base 3. Sign ECDSA P-256 HTTP Wire Headers Content-Digest X-Block-Digests Signature-Input Signature Client Browser Fetch /.well-known JWK crypto.subtle.verify READY
How This Is Set Up

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.

Without signed citations
// 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;
With RFC 9421 + RFC 9530 + Block Digests
// 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.
What disappears

Unverifiable copy-pasted quotes that cannot be checked against publisher origin bytes or public keys.

What becomes explicit

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.

Platform constraints

Whole-body byte digests break under CDN HTML minification or ad wrappers; durable citation provenance requires signing canonical block spans alongside full responses.