docs(x402): spike #206 — hand-roll verdict + proven local EIP-3009 facilitator loop#211
Merged
Conversation
…cilitator loop Standalone spike feeding two build decisions into #34: Q1 (dep decision): hand-roll the EIP-3009 TransferWithAuthorization in deckard-core (the cow_types alloy sol! precedent), NOT x402-types. Proven byte-for-byte: hand-roll, x402-rs, foundry cast, and the deployed USDC contract all agree on typehash/digest/ signature. Pulling x402-chain-eip155 into the trust core = 222 transitive crates (3x rustls, hyper, reqwest, full alloy-provider stack) for zero cryptographic gain. Q2 (local loop): PROVEN on anvil --fork-url $RPC_URL_SEPOLIA --fork-block-number 10822990. Self-hosted x402-rs facilitator (eip155:11155111 -> fork, no Docker) runs 402 -> sign -> /verify -> /settle end-to-end against real Circle USDC FiatTokenV2_2: USDC moves, nonce consumed, facilitator pays gas, replay rejected. Go: stay on the Sepolia fork. Recipe reproduces from a cold start via run.sh given $RPC_URL_SEPOLIA. Spike code (digest-cmp) is self-excluded from the deckard workspace; no workspace Cargo.toml/lock changes. Refs #206, feeds #34.
… vector Per review: the Q1 evidence (byte-identical digests, transcript) and the KAT vector stay; the throwaway comparison crate is dropped from the repo (it was never a workspace member).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes the #206 spike. Docs-only: adds a reproducible recipe + the two build decisions #34 needs before it starts. No code, no workspace
Cargo.toml/Cargo.lockchanges (the spike harness underdigest-cmp/is self-excluded from the deckard workspace via an empty[workspace]table).What this proves
Q1 — build shape → hand-roll in
deckard-core, notx402-types.A 6-line
alloy sol!TransferWithAuthorization(thecow_types.rsprecedent) produces the byte-identical EIP-712 typehash, digest, and signature as x402-rs's own type — cross-checked four ways (hand-roll, x402-rs, foundrycast wallet sign, and the deployed USDC contract accepting it on-chain). Pullingx402-chain-eip155into the#![forbid(unsafe_code)]trust core drags 222 transitive crates (3×rustls,hyper,reqwest, fullalloy-providerstack) for zero cryptographic gain. Use x402-rs only as the demo-fixture facilitator binary, never a build dep — as #34 already planned.Q2 — the fully-local loop works → stay on the Ethereum Sepolia fork.
402 → sign EIP-3009 → facilitator /verify → /settle → on-chainruns end-to-end against the real Circle USDCFiatTokenV2_2onanvil --fork-url $RPC_URL_SEPOLIA --fork-block-number 10822990, with a self-hosted x402-rs facilitator (eip155:11155111 → fork, no Docker). Asserted: USDC moved, nonce consumed, gas paid by the facilitator (not the buyer), replay rejected.run.shreproduces it from a cold start.Spec corrections v2 forced (detailed in the doc, folded into the #34 decision comment)
eip155:11155111); v1 has no network name for Ethereum Sepolia."USDC", version"2"— not mainnet's"USD Coin". The 402extramust carry{assetTransferMethod:"eip3009", name:"USDC", version:"2"}.X-Paymentv1 /Payment-Required+Payment-Signaturev2) is agent-side transport; the facilitator API is plain JSON.SignatureCheckerrejects the EOA signature. Use fresh codeless keys.Files
docs/research/x402-spike/README.md— the full report + evidence transcriptsrun.sh— self-contained proof of the loopfacilitator-config.json,typed-data.json,eip3009-kat.json— fixtures + the KAT vector for x402 phase 2: exact/EIP-3009 payments on the Ethereum reference path, fully local demo loop #34digest-cmp/— the Q1 hand-roll-vs-x402-rs harness (standalone; git dep on x402-rs)Decision comment posted on #34.