Request Signing
The AgentShield v1 request signature. The exact signing input, header encoding, verification rules, and how to implement it in another language.
Every agent request is signed with Ed25519 over a string that binds the time, a single-use nonce, and the exact bytes of the body. The same specification is implemented in Go (runtime/identity), Python (agentshield_sdk.signing), and TypeScript (sdk/typescript/src/signing.ts), and all three are tested against a shared vector.
The signing input
<unix-seconds>.<nonce>.<lowercase-hex SHA-256 of the raw request body>For example:
1764504000.hQ3xR8pV2mK9sT4wZ7yB1c.9f2c1e0b7d4a…(64 hex characters)| Part | Rule |
|---|---|
unix-seconds | Base-10 integer seconds since the epoch. Must be within 60 seconds of the gateway clock, in either direction |
nonce | Matches ^[A-Za-z0-9_-]{16,128}$. It cannot contain ., the field separator |
| body hash | SHA-256 of the bytes on the wire, as lowercase hex. The gateway never re-serializes before hashing |
The signature is the Ed25519 signature of that ASCII string, encoded as unpadded base64url.
Headers
| Header | Value |
|---|---|
X-AgentShield-Agent-Id | The agent's UUID |
X-AgentShield-Timestamp | The unix-seconds used in the signing input |
X-AgentShield-Nonce | The nonce used in the signing input |
X-AgentShield-Signature | Unpadded base64url Ed25519 signature |
Content-Type | application/json |
Sign the bytes you send
The most common integration bug is signing one serialization and sending another. Serialize once, sign that buffer, and send the same buffer:
import secrets, time
from agentshield_sdk import sign
from agentshield_sdk.jsonenc import encode_json
body = encode_json({"decision_id": DECISION_ID, "idempotency_key": KEY}) # bytes
timestamp = int(time.time())
nonce = secrets.token_urlsafe(16) # 22 characters of [A-Za-z0-9_-]
signature = sign(seed, timestamp, nonce, body)
# POST exactly `body` with the four headersThe SDK clients do all of this for you. You only need the low-level functions to implement a client in another language or to debug.
What verification checks
identity.Verify returns an error, and the gateway returns 401, when:
- the public key is not 32 bytes,
- the nonce does not match the pattern,
- the timestamp is more than 60 seconds from the gateway clock,
- the signature is not valid base64url, or
- the Ed25519 signature does not verify.
Verify alone does not prevent replay inside the 60-second window. The gateway reserves the nonce in Redis immediately after verification. See Replay protection.
Implementing another client
To write a client in a new language:
- Load the 32-byte seed and derive the Ed25519 private key from it.
- Serialize the JSON body to bytes once. Any valid JSON encoding works, but duplicate keys are rejected by the gateway.
- Compute
hex(sha256(body))in lowercase. - Build
f"{timestamp}.{nonce}.{hash}"and sign its ASCII bytes. - Base64url-encode the 64-byte signature and strip
=padding. - Send the same body bytes with the four headers. Refuse redirects: a signed request must not be replayed to another origin.
- Generate a fresh nonce for every request, including retries.
Reproduce the test vector in runtime/identity/identity_test.go before sending real traffic. The Python and TypeScript test suites check the same vector.
Why sign the body
| Alternative | Why it is not the agent credential |
|---|---|
| Bearer token | Easy to steal from an agent log, and not bound to the arguments of a call |
| Mutual TLS | Identifies a connection, not a request body. Still compatible as an additional transport control |
| JWT access token | Not bound to the body. May be added later for low-sensitivity reads, not for authorize |
A body signature means an intermediary that changes a single byte of the arguments invalidates the request. A proxy that reformats JSON breaks signatures; that is the intended behavior.
Implementation references
Was this page helpful?
Authentication
How agents authenticate to the gateway with signed requests and how humans authenticate to the control plane with bearer sessions.
Authorization
How the gateway turns an authenticated request into exactly one recorded decision, and every check that runs between the signature and the policy.