Quickstart
Node
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. No packages.
1. Create the files
quickstart.mjs
// Silvector quickstart for Node 20 or later. No dependencies.
// Run: node quickstart.mjs
import { createPublicKey, verify } from "node:crypto";
const API = process.env.SILVECTOR_API ?? "https://api.silvector.com";
// 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 verifies(receipt, jwk) {
const key = createPublicKey({ key: { kty: "OKP", crv: "Ed25519", x: jwk.x }, format: "jwk" });
return verify(null, Buffer.from(canonical(receipt.body)), key, Buffer.from(receipt.sig, "base64url"));
}
// 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) throw new Error(`/v1/check returned ${checked.status}`);
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 = Boolean(key) && verifies(receipt, key);
// 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 = Boolean(key) && verifies(tampered, key);
console.log(`receipt: ${decision.receiptId}`);
console.log(`outcome: ${receipt.body.outcome} (rule ${receipt.body.rule_id})`);
console.log(`key: ${key ? key.kid : `none published for ${receipt.body.agent_kid}`}`);
console.log(`verified: ${verified}`);
console.log(`tampered copy verifies: ${tamperedVerifies}`);
console.log("evidence grade: rung 2 Operational, confidence none, uncalibrated (assigned by the docs, not a signed field)");
process.exit(verified && !tamperedVerifies ? 0 : 1);
2. Run it
Run
node quickstart.mjs
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 Node
node:cryptoaccepts the published JWK directly, so the key needs no conversion.
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/node/. All quickstarts