MPP.X402.Nonce (mpp v0.19.0)

Copy Markdown View Source

x402 exact EIP-3009 nonce rules.

Native Payment-auth credentials use MPP.Methods.EVM.Authorization.challenge_hash/2 (keccak256(id <> realm)). x402 exact uses a random 32-byte nonce, or an mppx extension-bound SHA-256 nonce when extensions.mppx is present (refs/mppx/src/x402/client/Exact.ts and internal/RouteBinding.ts). The two contracts must not accept each other's nonces.

Summary

Functions

Return true when nonce is the native challengeHash for id/realm.

Return the x402 exact nonce contract for this payload (:random or :extension_bound).

Compute the mppx extension-bound nonce.

Generate a random 32-byte 0x-prefixed EIP-3009 nonce.

Insert a fresh info.nonce salt under extensions.mppx for extension-bound signing.

Functions

challenge_hash?(nonce, id, realm)

@spec challenge_hash?(String.t(), String.t(), String.t()) :: boolean()

Return true when nonce is the native challengeHash for id/realm.

Used to prove the shared signing primitive cannot satisfy the x402 contract by presenting a native nonce, and vice versa.

contract(arg1)

@spec contract(map() | nil) :: :random | :extension_bound

Return the x402 exact nonce contract for this payload (:random or :extension_bound).

extension_bound(accepted, resource, extensions)

@spec extension_bound(map(), map(), map()) :: String.t()

Compute the mppx extension-bound nonce.

SHA-256 of serialize(accepted)|serialize(resource)|serialize(extensions) where serialize is JCS then base64url (no padding), matching refs/mppx/src/x402/internal/RouteBinding.ts.

random()

@spec random() :: String.t()

Generate a random 32-byte 0x-prefixed EIP-3009 nonce.

with_nonce_salt(extensions)

@spec with_nonce_salt(map()) :: map()

Insert a fresh info.nonce salt under extensions.mppx for extension-bound signing.