An agent that finds our API through a directory, a cached file or another agent is holding a copy. This page shows how it can prove the copy is the one we published, before it calls anything.
did:web:x402-agent-pay.com.| Reason | Meaning | What the agent should do |
|---|---|---|
SCHEMA_DRIFT | The OpenAPI document you hashed is not the one the statement signs. | Fetch the document from the origin again before calling. |
POLICY_DRIFT | The settlement terms you hashed are not the ones signed. | Read the current terms before paying. |
BAD_SIGNATURE | The statement was altered, or signed by a different key. | Reject it. |
UNKNOWN_KEY | The key is not in our DID document. We revoke a key by removing it there. | Reject it. |
EXPIRED | The statement is more than an hour old. | Fetch a fresh one. |
UNSUPPORTED_ALG, MALFORMED_JWS | Not a statement we would issue. | Reject it. |
This is the whole check in Python. It depends on nothing we run except the three public files.
pip install cryptography
import base64, hashlib, json, time, urllib.request
from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PublicKey
B = "https://x402-agent-pay.com"
def get(u):
req = urllib.request.Request(u, headers={"User-Agent": "Mozilla/5.0"})
return urllib.request.urlopen(req).read()
def d(s):
return base64.urlsafe_b64decode(s + "=" * (-len(s) % 4))
jws = json.loads(get(B + "/facilitator/discovery/proof"))["jws"]
h, p, s = jws.split(".")
header, claims = json.loads(d(h)), json.loads(d(p))
did = json.loads(get(B + "/.well-known/did.json"))
key = next(v for v in did["verificationMethod"] if v["id"] == header["kid"])
Ed25519PublicKey.from_public_bytes(d(key["publicKeyJwk"]["x"])).verify(
d(s), (h + "." + p).encode()) # raises if the signature is bad
assert claims["iss"] == "did:web:x402-agent-pay.com"
assert claims["exp"] > time.time()
assert hashlib.sha256(get(B + "/openapi.json")).hexdigest() == claims["interface"]["sha256"]
print("verified", claims["interface"]["version"])
GET https://x402-agent-pay.com/facilitator/discovery/proof returns the statement, free and without a key. POST https://x402-agent-pay.com/facilitator/discovery/proof/verify with {"jws": "...", "openapi_sha256": "..."} runs the checks for you and returns valid with a named reason. Both are available as the MCP tools x402_facilitator_discovery_proof and x402_facilitator_discovery_proof_verify. Checking the signature yourself is stronger than asking us.