Atomic swap
Last updated
Last updated
Zkopru supports the atomic swap in a straightforward way. If A and B want to swap their assets, they create notes for each other and expose the wished note on the transaction data. Then the coordinator should pair the opposite transaction or get slashed.
For example, Alice wants to swap her 50 ETH with Bob's 1000 DAI.
Alice spends her 60 ETH note and creates 10 ETH note for herself, and 50 ETH note for Bob.
Alice also calculates the hash value of her future 1000 DAI note and expose that hash value to the swap
field of her transaction.
Bob also spends his 3000 DAI note and create 2000 DAI for himself and 1000 DAI note for Alice.
Bob also calculates the hash value of his future 50 ETH note and expose that hash value to the swap
field of his transaction.
Once the coordinator matches the paired set of transactions in the transaction pool, it includes the pair into a new block.
If a block inclues only one of them, the coordinator will get slashed.
Zkopru is using this simple version of the atomic swap. However if you want to check an MPC based zk atomic swap model, you can check details here.