How it works
PQ-402 extends x402, the HTTP payment protocol built on status
402 Payment Required. It keeps the x402 v2 headers and replaces two things: the payment is signed with ML-DSA-87
instead of ECDSA, and the bodies travel sealed with ML-KEM-1024.
- Probe. The client sends the request without its body, with
PQ402-Probe: 1. It does not send the body in plain text before it knows the server seals. - Price. A paid route answers
402with what it costs, who gets paid, which schemes it accepts, and the gateway account that seals and signs. - Key. The client reads the gateway’s ML-KEM-1024 key from the chain’s KEM key registry. It never takes a key from
the
402. - Pay. The client seals the body to that key and signs a payment with its ML-DSA-87 key. The payment commits to the price, the payee, a time window, a nonce and a hash of the method, path and sealed body.
- Verify. The server checks the signature against the key
pqcKeyStatusreports for the payer, refuses replays, and reads the payer’s ML-KEM-1024 key so it can seal the answer. - Serve. The server opens the body, runs your handler, and seals the answer to the payer’s key.
- Settle. The server’s relayer submits the payment on chain and pays the gas. The contract that moves the money,
the escrow or the agent-budget vault, checks the ML-DSA-87 signature again with the
pqcVerifyprecompile. - Answer. The sealed answer comes back with a receipt signed by the gateway’s ML-DSA-87 key. The receipt binds the payment, the request and the exact bytes of the answer.
- Check and open. The client checks the receipt against the gateway’s key on chain, then opens the answer with its ML-KEM-1024 key.
Two ways to pay
Section titled “Two ways to pay”| Scheme | Paid from | Settled by |
|---|---|---|
pq-erc20 |
a deposit of fUSD in PQ402Escrow |
PQ402Escrow.settle |
pq-perennial |
an agent budget: a vault position whose owner set funds aside for the agent | the vault’s spend |
A server offers one or both, at the same price. See pay from an escrow and pay from an agent budget.
Who pays the gas
Section titled “Who pays the gas”The server. Its relayer submits every settlement from its own account and EVM window, so the client holds no QOR for paying and sends no transaction per call. The relayer can only submit what payers signed, to the payees they named.