Documentation Index
Fetch the complete documentation index at: https://mintlify.com/nhestrompia/shielded-x402/llms.txt
Use this file to discover all available pages before exploring further.
Overview
The protocol uses cryptographic signatures to authenticate payment flows and bind commitments to merchant challenges. All signatures operate on structured data with domain separation.X402 Signature Flow
The X402 protocol requires signatures at two critical points:- Payment Signature: Client signs the payment proof and challenge
- Merchant Verification: Merchant verifies signature before accepting payment
Signature Structure
signature field contains the hex-encoded signature over:
- The payment requirement (canonical JSON)
- The shielded payment response
- The challenge nonce
Challenge Hash Derivation
Challenge hashes bind payments to specific merchant requests using domain separation.Domain Tag
keccak256 of the domain separator string.
Preimage Structure
The challenge hash preimage consists of four 32-byte words:Challenge Hash Computation
The final challenge hash is:Example
Nullifier Derivation
Nullifiers prevent double-spending by deriving unique identifiers from spent notes.Domain Tag
Derivation Formula
- nullifierSecret: Private secret known only to the note owner
- noteCommitment: Public commitment to the note being spent
Properties
- Uniqueness: Each note produces a unique nullifier
- Privacy: Nullifier doesn’t reveal note details
- Non-malleability: Only the note owner can derive the correct nullifier
Commitment Signatures
Output commitments use domain-separated hashing for merchant and change notes.Merchant Commitment
Domain:shielded-x402:v1:output
Amount being paid to merchant
Random blinding factor for merchant’s note (32 bytes)
Hash of merchant’s public key (32 bytes)
Change Commitment
Domain:shielded-x402:v1:output
Amount being returned as change
Random blinding factor for change note (32 bytes)
Hash of sender’s public key (32 bytes)
Header Encoding
X402 headers use base64-encoded JSON for transport.Encoding
Decoding
Header Types
PAYMENT-REQUIREDVerification Steps
Client Verification
- Decode
PAYMENT-REQUIREDheader - Validate
x402Version === 2 - Extract
PaymentRequirement - Compute challenge hash
- Generate payment proof
- Sign payload
- Encode
PAYMENT-SIGNATUREheader
Merchant Verification
- Decode
PAYMENT-SIGNATUREheader - Validate
x402Version === 2 - Verify signature over payload
- Validate challenge hash matches
- Verify ZK proof on-chain
- Check nullifier hasn’t been used
- Accept payment
Security Properties
- Domain Separation: Prevents cross-protocol attacks
- Replay Protection: Challenge nonces prevent replay
- Double-Spend Prevention: Nullifiers enforced on-chain
- Binding: Signatures bind payments to challenges
- Privacy: Zero-knowledge proofs hide payment details