feat: seller receipt signing (EIP-191) for PurchaseLog#63
Open
M2M-TRC8004-Registry wants to merge 1 commit intoBofAI:mainfrom
Open
feat: seller receipt signing (EIP-191) for PurchaseLog#63M2M-TRC8004-Registry wants to merge 1 commit intoBofAI:mainfrom
M2M-TRC8004-Registry wants to merge 1 commit intoBofAI:mainfrom
Conversation
Implement ECDSA receipt signing so sellers can attest to purchases on-chain via PurchaseLog.sol. The seller signs a digest of (listingId, buyerAgentId, paymentHash, amount, chainId, contractAddress) using EIP-191 personal-sign, and the buyer submits this signature to PurchaseLog.logPurchase() for on-chain verification. Key changes: - New receipt_signer.py: compute_receipt_digest() and sign_receipt() - SellerSigningConfig for endpoint-level configuration - FastAPI middleware: auto-sign receipts after successful settlement - paymentHash = SHA-256 of PAYMENT-SIGNATURE header (not tx hash) - uint32 overflow validation for listingId and buyerAgentId - validAfter -= 60s to prevent facilitator timing edge cases - ReceiptSignatureData types added to Python and TypeScript SDKs
Author
|
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.
Summary
receipt_signer.py: Implementscompute_receipt_digest()andsign_receipt()for EIP-191 personal-sign overkeccak256(abi.encode(listingId, buyerAgentId, paymentHash, amount, chainId, contractAddress)), matchingPurchaseLog.sol's on-chain verification.SellerSigningConfigparameter tox402_protected(). After successful settlement, the middleware auto-signs a receipt and includes it in thePAYMENT-RESPONSEheader asreceiptSignature.paymentHash= SHA-256 ofPAYMENT-SIGNATUREheader: The payment hash is derived from the buyer's raw payment header (not the settlement tx hash), ensuring a cryptographic binding between the x402 payment and the on-chain purchase record.ReceiptSignatureDataadded to both SDKs'SettleResponse.validAfter = now - 60to prevent facilitatornot_yet_validrace conditions.Security
listingIdandbuyerAgentIdbefore signingchainId+address(this)in digest prevents cross-chain / cross-contract replays ≤ half-orderenforced by eth-account's signing library (malleability guard)Usage
Test plan
verified: truepaymentHashmatches across seller middleware, buyer receipt, and on-chain submission