Quickstart
Cloudflare Workers
Get a decision, verify its receipt against the published keys, and watch a changed receipt fail. About ten minutes, most of it reading.
You need
Node 20 or later. Wrangler is fetched by npx; no Cloudflare account is needed to run it locally.
1. Create the files
Set up
mkdir silvector-quickstart && cd silvector-quickstart && mkdir src
wrangler.jsonc
{
"name": "silvector-quickstart",
"main": "src/index.js",
"compatibility_date": "2026-10-01",
"vars": { "SILVECTOR_API": "https://api.silvector.com" }
}
src/index.js
// Silvector quickstart for Cloudflare Workers. No dependencies.
// Run: npx wrangler dev, then open the local URL it prints.
const encoder = new TextEncoder();
// Canonical JSON: keys sorted, no whitespace, integers only. This is the exact byte
// string the receipt signature covers.
function canonical(value) {
if (value === null) return "null";
if (Array.isArray(value)) return `[${value.map(canonical).join(",")}]`;
if (typeof value === "object") {
return `{${Object.keys(value).sort().map((key) => `${JSON.stringify(key)}:${canonical(value[key])}`).join(",")}}`;
}
if (typeof value === "number" && !Number.isInteger(value)) throw new Error("receipts carry integers only");
return JSON.stringify(value);
}
function b64url(text) {
const base64 = text.replace(/-/g, "+").replace(/_/g, "/").padEnd(Math.ceil(text.length / 4) * 4, "=");
return Uint8Array.from(atob(base64), (char) => char.charCodeAt(0));
}
async function verifies(receipt, jwk) {
const key = await crypto.subtle.importKey("raw", b64url(jwk.x), { name: "Ed25519" }, false, ["verify"]);
return crypto.subtle.verify({ name: "Ed25519" }, key, b64url(receipt.sig), encoder.encode(canonical(receipt.body)));
}
export default {
async fetch(_request, env) {
const api = env.SILVECTOR_API ?? "https://api.silvector.com";
// 1. Ask for a decision. The response carries a signed receipt.
const checked = await fetch(`${api}/v1/check`, {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ method: "GET", path: "/pricing" }),
});
if (!checked.ok) return new Response(`/v1/check returned ${checked.status}\n`, { status: 502 });
const decision = await checked.json();
const receipt = decision.receipt;
// 2. Fetch the published keys.
const jwks = await (await fetch(`${api}/.well-known/jwks.json`)).json();
const keys = jwks.keys.filter((key) => key.kty === "OKP" && key.crv === "Ed25519");
// 3. Verify with the one key whose kid equals the receipt's agent_kid. Other published
// keys sign other things, so never fall back to them.
const key = keys.find((candidate) => candidate.kid === receipt.body.agent_kid);
const verified = key ? await verifies(receipt, key) : false;
// 4. Change one field and check that the signature no longer holds.
const tampered = { ...receipt, body: { ...receipt.body, outcome: receipt.body.outcome === "allow" ? "deny" : "allow" } };
const tamperedVerifies = key ? await verifies(tampered, key) : false;
const lines = [
`receipt: ${decision.receiptId}`,
`outcome: ${receipt.body.outcome} (rule ${receipt.body.rule_id})`,
`key: ${key ? key.kid : `none published for ${receipt.body.agent_kid}`}`,
`verified: ${verified}`,
`tampered copy verifies: ${tamperedVerifies}`,
"evidence grade: rung 2 Operational, confidence none, uncalibrated (assigned by the docs, not a signed field)",
];
return new Response(`${lines.join("\n")}\n`, {
status: verified && !tamperedVerifies ? 200 : 500,
headers: { "content-type": "text/plain; charset=utf-8" },
});
},
};
2. Run it
Run
npx wrangler dev
# then, in a second terminal:
curl http://localhost:8787/
3. Read the output
REPLAY Recorded 2026-11-07 against api.silvector.com. Your receipt id and timestamp will differ.
Output
receipt: b8d4f2ceb697b3904d50459c649d6fc220418387d87332d04ab47cf2bd32fa98
outcome: allow (rule allow.default)
key: edge-receipt
verified: true
tampered copy verifies: false
evidence grade: rung 2 Operational, confidence none, uncalibrated (assigned by the docs, not a signed field)
- Decide.
POST /v1/checkran the request shape through the public policy for tenanttryand returned the outcome, the rule and a signed receipt. - Fetch the keys.
GET /.well-known/jwks.jsonreturned the public Ed25519 keys. - Verify. The script rebuilt the canonical JSON of the receipt body and checked the signature with the one key whose
kidequals the receipt'sagent_kid. It never tries the other published keys: they sign other things, such as sessions, so a receipt that verifies under one of them is not a valid receipt. - Tamper. It flipped the outcome and checked again. The signature no longer holds, which is the point of a receipt.
4. The evidence grade of this receipt
A receipt is a rung 2 record: it shows which rule decided and that the record was not changed. It does not, by itself, say whether the sender was an AI agent.
Evidence grade
Rung 2 · Operational
- Covers
- Which rule decided this request and that the record was not changed after signing. Not whether the sender was an AI agent.
- Confidence
- None stated. No calibrated confidence applies to this record.
- Calibration
- Uncalibrated
- Known error rates
- None measured. Silvector publishes no detection error rate yet.
- Basis
- Deterministic decide() rule allow.default
- Ed25519 signature over the canonical receipt body, checked against the published JWKS
- Bias risks
- The decision is only as good as the facts it was given. A request with no signature claim is not_identified, which is not a finding that a person or an agent sent it.
- Next step
- To ask who was behind a series of requests, keep the receipts and escalate to rung 3 with at least two independent signal families. How escalation works
- Assigned by
- These docs, from the rung definitions. The grade is not a signed field of the receipt.
Notes for Cloudflare Workers
- Workers support Ed25519 in Web Crypto, so verification needs no library.
wrangler devruns the Worker locally. Deploying it is not part of this quickstart.
Troubleshooting
- 429 Too Many Requests. The public check endpoint allows 60 requests a minute per caller. Wait a minute.
- verified: false. A value in the receipt body changed after signing, or your verifier builds the canonical form differently: keys sorted by UTF-16 code unit, no whitespace, integers only, strings escaped as JavaScript's
JSON.stringifyescapes them. Whitespace, key order and escape style in the JSON you received do not matter; the verifier rebuilds the canonical form from the parsed values. - key: none published for … The key set has no key with the receipt's
agent_kid, so the receipt cannot be verified.pnpm --filter @ag47/api devpublishes test keys under thumbprint ids and shows this; runpnpm --filter @ag47/docs apiinstead. - Another API. Set
SILVECTOR_API, for example tohttp://127.0.0.1:8787afterpnpm --filter @ag47/docs apiin the repository. For the Workers quickstart, givewrangler devanother port with--portand pass the URL with--var SILVECTOR_API:http://127.0.0.1:8787.
Next
ConceptReceipt
Every field, and the invariants that hold.
TryDecision playgroundChange the request and watch the decision and receipt.
JobShow an auditor what your policy didHand over receipts anyone can check.
Source: apps/docs/quickstarts/workers/. All quickstarts