Skip to Content
AgentShield
Fundamentals

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)
PartRule
unix-secondsBase-10 integer seconds since the epoch. Must be within 60 seconds of the gateway clock, in either direction
nonceMatches ^[A-Za-z0-9_-]{16,128}$. It cannot contain ., the field separator
body hashSHA-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

HeaderValue
X-AgentShield-Agent-IdThe agent's UUID
X-AgentShield-TimestampThe unix-seconds used in the signing input
X-AgentShield-NonceThe nonce used in the signing input
X-AgentShield-SignatureUnpadded base64url Ed25519 signature
Content-Typeapplication/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 headers

The 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:

  1. Load the 32-byte seed and derive the Ed25519 private key from it.
  2. Serialize the JSON body to bytes once. Any valid JSON encoding works, but duplicate keys are rejected by the gateway.
  3. Compute hex(sha256(body)) in lowercase.
  4. Build f"{timestamp}.{nonce}.{hash}" and sign its ASCII bytes.
  5. Base64url-encode the 64-byte signature and strip = padding.
  6. Send the same body bytes with the four headers. Refuse redirects: a signed request must not be replayed to another origin.
  7. 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

AlternativeWhy it is not the agent credential
Bearer tokenEasy to steal from an agent log, and not bound to the arguments of a call
Mutual TLSIdentifies a connection, not a request body. Still compatible as an additional transport control
JWT access tokenNot 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.

Was this page helpful?

On this page