AP2 · LIVE DEMO
AP2 — Intent envelope signing demo
Build an AP2 intent envelope, sign it with Ed25519, and watch the signature verify. Flip one byte and watch verification fail. A live signing ceremony, not a mockup.
AP2 is an evolving spec. This demo uses a simplified envelope shape (ap2/0.1-demo) to show the signing ceremony end-to-end — intent built, canonicalized, signed with Ed25519, published with a kid, verified against the public JWK set. For the protocol background, see the AP2 overview.
What just happened
You built an intent envelope— the agent's declaration of what it wants to do on the principal's behalf. The server dropped defaults for issued_at and expires_at (15 minutes into the future), canonicalized the envelope by JSON.stringify, and signed the UTF-8 bytes with the primary Ed25519 key from the JWK set. The signature rides in the envelope's signature field alongside its kid, so a verifier knows exactly which key to pull.
Why tampering fails
Ed25519 is deterministic. The same key plus the same message produces the same signature, byte-for-byte. The tamper & re-verify button rotates one character of the signature.value— still valid base64url, still 64 bytes, but no longer a signature over the envelope's canonical bytes. The verifier catches it in a single call to crypto.subtle.verify.
Call it from anywhere
# Sign
curl -s https://aethelforge.ai/api/intents/sign \
-H 'content-type: application/json' \
-d '{
"intent": "purchase",
"actor": { "principal": "[email protected]", "agent_id": "did:agent:example" },
"resource": { "merchant": "merchant.example.com", "sku": "SKU-1", "quantity": 1 },
"amount": { "currency": "USD", "value": "12.00" }
}'
# Verify
curl -s https://aethelforge.ai/api/intents/verify \
-H 'content-type: application/json' \
-d '{ "envelope": { ... the JSON from /sign ... } }'Interop note
Canonicalization is JSON.stringify with construction-order keys. That works today because both the signer and the verifier are this code. Before any third party produces envelopes for us to verify, swap the canonicalization to RFC 8785 JCS — otherwise a verifier that reserializes the envelope differently will silently fail the signature check.