ERC-7573 · Draft · ERC · 2023-12-05
ERC-7573: Conditional-upon-Transfer-Decryption for DvP
A delivery-versus-payment protocol across two blockchains: the asset is locked under two hashed keys, and a stateless decryption oracle reveals the right key depending on whether the payment on the other chain succeeded.
What problem does it solve?
In finance, delivery versus payment (DvP) means the asset is delivered if and only if it is paid for. That is easy when both legs live on the same ledger, but often the asset (say a tokenised bond) is on one chain and the cash is on another chain or payment system. Existing approaches rely on API bridges between the systems, or on hash time-locks whose timeouts are hard to get right.
ERC-7573 proposes a scheme with no trusted intermediary holding funds: the asset chain locks the asset, the payment chain attempts the payment, and a stateless decryption oracle attached to the payment chain releases exactly one of two keys that decides where the locked asset goes.
How it works
Two contracts, one per chain:
ILockingContract(asset chain). The seller callsinceptTransferwith a hash and an encryption of their key; the buyer callsconfirmTransferwith the same trade data and a hash and encryption of their key, which locks the asset. Later,transferWithKey(id, key): ifkeyhashes to the buyer's value, the asset goes to the buyer (TokenClaimed); if it matches the seller's, it returns to the seller (TokenReclaimed).IDecryptionContract(payment chain). The payment is set up with two encrypted keys:keyEncryptedSuccess(the buyer's key) andkeyEncryptedFailure(the seller's key).transferAndDecrypt(id)attempts the payment and emitsTransferKeyRequestedwith the success key if it worked, or the failure key if it did not.cancelAndDecryptrequests the failure key if no transfer was attempted.
The oracle decrypts the requested key and calls releaseKey on the payment contract, which emits TransferKeyReleased. Anyone can then present that key to the locking contract to settle the asset.
Keys are encrypted with the oracle's public key. To keep the oracle stateless, the plaintext key document embeds the address of the contract allowed to receive it; the spec proposes an XML format and an oracle verify function that returns hashes without revealing keys. Trade data must match exactly across incept/confirm, and each id may be used only once.
The spec also covers asynchronous key generation, callback interfaces for oracle proxies (strict vs best-effort fulfilment) and multi-party DvP, where several legs settle atomically.
Sample code
The locking side, as defined in the spec (events omitted):
interface ILockingContract {
function inceptTransfer(uint256 id, int amount, address from, address to,
bytes memory transaction, bytes memory keyHashedSeller, bytes memory keyEncryptedSeller) external;
function confirmTransfer(uint256 id, int amount, address from, address to,
bytes memory transaction, bytes memory keyHashedBuyer, bytes memory keyEncryptedBuyer) external;
function cancelTransfer(uint256 id, int amount, address from, address to,
bytes memory transaction, bytes memory keyHashedSeller, bytes memory keyEncryptedSeller) external;
function transferWithKey(uint256 id, bytes memory key) external;
}
The overall flow as pseudocode:
asset chain: seller.inceptTransfer(id, ..., H(Ks), E(Ks))
asset chain: buyer.confirmTransfer(id, ..., H(Kb), E(Kb)) -> asset locked
payment chain: incept/confirm payment with E(Kb) as success, E(Ks) as failure
payment chain: transferAndDecrypt(id)
payment ok? -> TransferKeyRequested(E(Kb))
payment fail -> TransferKeyRequested(E(Ks))
oracle: decrypt, call releaseKey(id, K) -> TransferKeyReleased(K)
asset chain: transferWithKey(id, K) -> to buyer if K == Kb, back to seller if K == Ks
Things to know
- Status is Draft, and the specification has been revised substantially; check the latest text before implementing.
- The asset leg must be locked for the duration of the trade. The spec treats this as a feature, since locking is what makes multi-party atomic settlement possible.
- Security rests on the decryption oracle: it must decrypt only for the contract named in the key document, and the parties must trust its key handling and availability.
- The key, encrypted key and hashed key are opaque
bytes, so the encryption scheme is implementation-defined and should be inferable from the encrypted key itself. amountis a signedint, unlike most token standards.