Write your own verifier
Use this page when your language has no Assay verifier. Implement the request signature profile below, then compare your implementation with the shared test vectors. For Node, Python or Go, use the existing libraries.
How it works
Section titled “How it works”Assay uses Ed25519 over an HTTP Message Signatures base in the style of RFC 9421. Signature-Input describes the covered components and parameters. Signature carries the signature bytes. Both are structured dictionaries; select their member named assay.
Get public keys from the configured trusted JWKS at https://api.goassay.ai/.well-known/assay-request-keys.json. Never let a request choose the key-fetch URL. Read the original request target and raw body before a framework decodes paths or parses JSON.
Implement the checks in order
Section titled “Implement the checks in order”- Parse both headers as structured dictionaries. Missing headers or missing
assaymembers fail withMISSING; parsing failures or a signature member that is not a byte sequence fail withMALFORMED. - Require an inner list of components in
Signature-Input. Check the parameters below. A missing or different tag isWRONG_TAG; invalid required parameters areMALFORMED. - Require the exact component list and order below. A nonempty body without covered
content-digestisMALFORMED. If covered, requireContent-Digest, parse itssha-256byte sequence and compare it with SHA-256 of the raw body. Missing digest isMISSING, invalid structured syntax isMALFORMED, and a missing or different SHA-256 value isDIGEST_MISMATCH. - Check the time window in Unix seconds. Require
expires >= created,expires - created <= 300, andcreated - 60 <= now <= expires + 60. Fail withEXPIREDotherwise. These bounds are inclusive. - Build the signature base exactly as described below. Require a nonempty trimmed call ID and authority, and a valid target; otherwise fail with
MALFORMED. - Look up
keyidin the trusted key set and verify Ed25519 over the UTF-8 base bytes. A missing usable key isUNKNOWN_KEY; a failed cryptographic check isBAD_SIGNATURE. - Atomically check and store the nonce only after cryptographic verification. Keep it for
max(1, expires + 60 - now)seconds. A live existing entry isREPLAYED. A store error must reject the request without running the application.
| Parameter | Required value or type |
|---|---|
created, expires |
Integers, in Unix seconds |
nonce |
Nonempty string |
keyid |
Nonempty string identifying the public key |
alg |
ed25519 |
tag |
assay-request |
Assay generates the nonce from 16 random bytes encoded as base64url. Verification requires a nonempty string; do not invent a different nonce-length requirement.
Build the canonical form
Section titled “Build the canonical form”Without a covered digest, the component list is exactly:
("@method" "@authority" "@path" "@query" "x-assay-call-id")With a digest, insert "content-digest" immediately before "x-assay-call-id". No other component order is accepted. An empty body may have a covered digest; hash the empty byte string in that case.
| Component | Value in the base |
|---|---|
@method |
Uppercase HTTP method |
@authority |
Configured public authority if set; otherwise trimmed Host, lowercased. Keep the port as received. If Host is absent and the input is an absolute URL, the library uses that URL’s host. |
@path |
Raw path, or / if empty |
@query |
? followed by the raw query; just ? when absent |
content-digest |
Trimmed complete Content-Digest header value, when covered |
x-assay-call-id |
Trimmed X-Assay-Call-Id header value |
For an origin-form target such as /v1/search?q=a%20b, split at the first ?. Preserve query order, percent escapes and path segments. Do not decode, sort, resolve or re-encode them. Reject targets starting with // or lacking the leading /. The library also accepts an absolute URL through a URL parser; prefer your server’s raw origin-form target to avoid normalization before verification.
Write each line as "component-name": value. Append "@signature-params": followed by the raw inner list and parameters of the assay member. This is the text after its assay=, ending before any next dictionary member; preserve parameter order, spacing and escaping. Do not include assay= or rebuild parameters from an unordered map.
Join the lines with a single LF (\n), with no trailing newline. Encode as UTF-8. Verify plain Ed25519 over those bytes, without adding a separate hash or using Ed25519ph.
The usual digest header is sha-256=:BASE64_DIGEST:. The digest and signature use standard base64 inside structured byte sequences. The JWK’s x public-key value uses base64url. Select a matching kid with kty="OKP", crv="Ed25519" and a usable Ed25519 public key; skip unusable keys. Follow the production cache rules to handle rotation.
Example: exact base from a fixture
Section titled “Example: exact base from a fixture”The first positive fixture has raw body {"q":"a b"}. Its canonical base is these seven lines, without a final newline:
"@method": POST"@authority": api.example.test"@path": /v1/search"@query": ?q=a%20b"content-digest": sha-256=:dm7Bv3nwO4zfpapceY8ZEGZiaYiTOc8C3j72DLhHCSw=:"x-assay-call-id": c-1"@signature-params": ("@method" "@authority" "@path" "@query" "content-digest" "x-assay-call-id");created=1760700000;expires=1760700300;nonce="AQEBAQEBAQEBAQEBAQEBAQ";keyid="test-2026-10";alg="ed25519";tag="assay-request"To inspect the exact expected string and verify its fixture signature independently, run this from a copy of the verifier repository. It requires Node 20 or newer and uses only built-in modules:
node --input-type=module <<'JS'import { readFileSync } from "node:fs";import { createPublicKey, verify } from "node:crypto";const vectors = JSON.parse(readFileSync("test-vectors/v1.json", "utf8"));const c = vectors.cases[0];const signature = c.expected.headers.Signature.match(/^assay=:([^:]+):$/)[1];const ok = verify( null, Buffer.from(c.expected.signatureBase, "utf8"), createPublicKey({ key: vectors.publicKeyJwk, format: "jwk" }), Buffer.from(signature, "base64"),);if (!ok) throw new Error("fixture signature failed");console.log(JSON.stringify(c.expected.signatureBase));console.log("fixture signature verified");JSThis checks the fixture itself. Your implementation must also rebuild the base from the request and compare it byte for byte with expected.signatureBase.
Check it worked
Section titled “Check it worked”Run every case in test-vectors/v1.json and test-vectors/negative.json through your verifier. For positive cases, merge request.headers with expected.headers, use publicKeyJwk, encode the body as UTF-8 and pin the clock to params.created. Require acceptance and the exact expected base.
For negative cases, use each supplied now and require the exact expectedReason; OK means acceptance. Start a fresh replay store per case, but keep it across a case’s sequence. That is how the replay case proves that the first call passes and the next fails. The fixture seed and public key belong only in tests.
Include concurrency and store-outage checks in your integration tests. The production store must share nonce state across instances and perform its check and insertion atomically.
Errors
Section titled “Errors”Return HTTP 401, content-type: application/json and {"error":"invalid_assay_signature","reason":"CODE"} for a signature rejection. Preserve the check order so your reason agrees with the fixtures. Infrastructure failures must also stay closed; they are not evidence of a bad signature.
See Reject reasons for the complete caller-facing reason table and fixes.
Go further
Section titled “Go further”- Run the verifier in production.
- List your API (optional): Write your own verifier.
