|
| 1 | +# Taprootized Atomic Swaps |
| 2 | + |
| 3 | +Taprootized Atomic Swaps (TAS) is an extension for Atomic Swaps that presumes the untraceability of |
| 4 | +transactions related to a particular swap. Build top on Schnorr signatures, Taproot technology, and |
| 5 | +zero-knowledge proofs TAS hide swap transactions under regular payments. |
| 6 | + |
| 7 | +## Intro |
| 8 | +Atomic swap is an incredible approach to cross-chain exchanges without mediators. However, one of |
| 9 | +the disadvantages of its implementation in the classical form is the “digital trail” - any party |
| 10 | +can make a matching between transactions in the blockchains in which the exchange took place and |
| 11 | +find out both the participants in the exchange and the proportion in which assets were exchanged. |
| 12 | + |
| 13 | +<div align="center"> |
| 14 | +<img src="https://github.com/distributed-lab/taprootized-atomic-swaps/blob/main/assets/atomic-swap.png"/> |
| 15 | +</div> |
| 16 | + |
| 17 | +On the other hand, atomic swaps is a technology that initially assumed the involvement of only two |
| 18 | +parties and a “mathematical contract” between them directly. That is, an ideal exchange presupposes |
| 19 | +2 conditions: |
| 20 | +1) Only counterparties participate in the exchange (works by default) |
| 21 | +2) Only counterparties know about the fact of the exchange (it would be nice to ensure) |
| 22 | + |
| 23 | +To an external auditor, transactions to initiate and execute atomic swaps will be indistinguishable |
| 24 | +from regular Bitcoin payments. In the other accounting system involved in the transfer, more |
| 25 | +information is disclosed (the fact of exchange can be traced). Still, it is impossible to link this |
| 26 | +to the corresponding Bitcoin transactions (without additional context from the involved parties). |
| 27 | + |
| 28 | +<div align="center"> |
| 29 | +<img src="https://github.com/distributed-lab/taprootized-atomic-swaps/blob/main/assets/sequence-diagram.png"/> |
| 30 | +</div> |
| 31 | + |
| 32 | +### The protocol includes the following steps: |
| 33 | +1. Alice (`skA`, `PKA`) and Bob (`skB`, `PKB`) have their keypairs and know each other's public keys. |
| 34 | +2. Alice generates a random `k` and calculates the public value `K = k * G` |
| 35 | +3. Alice calculates an escrow public key as `PKEsc = K + PKB` |
| 36 | + 1. The signature can be generated only with the knowledge of `k` and `skB` |
| 37 | +4. Alice calculates the `h` as a hash value of `k` (zk-friendly hash function is recommended to use) |
| 38 | +5. Alice forms the funding transactions with the following conditions of how it can be spent: |
| 39 | + 1. Signature of `skEsc`: Bob, with knowledge of `k` and skB can spend the output |
| 40 | + 2. Signature of `skA` + Locktime: Alice, with knowledge of `skA` can spend the output, but only |
| 41 | + after some point in time t1 |
| 42 | +6. Alice sends the transaction to the Bitcoin network |
| 43 | +7. Alice generates the zero-knowledge proof that includes: |
| 44 | + 1. The proof of knowledge of `k` that satisfes `k * G == K` |
| 45 | + 2. The proof of knowledge of `k` that satisfes `zkHash(k) == h` |
| 46 | +8. Alice provides the set of data to Bob: |
| 47 | + 1. `h` |
| 48 | + 2. `K` |
| 49 | + 3. `PKEsc` |
| 50 | + 4. `proof` |
| 51 | +9. Bob performs the following verifications: |
| 52 | + 1. Verify that `PKEsc == K + PKB`, it means that the valid `PK` of Bob was added to escrow PK |
| 53 | + 2. Verifes that Alice knows `k` that satisfies `k * G == K` and `zkHash(k) == h`, it means that Bob |
| 54 | + can access the output `PKEsc` if he receives `k` |
| 55 | +10. If verifications are passed, Bob forms the transaction that locks his funds on the following |
| 56 | +conditions: |
| 57 | + 1. Publishing of `k` and the signature of `skA`: only Alice can spend it if she reveals `k` |
| 58 | + 2. Signature of `skB` + Locktime: Bob, with knowledge of `skB`, can spend the output, but only after |
| 59 | + some point in time t2 |
| 60 | +11. Bob sends the transaction to the Ethereum network (or other) |
| 61 | +12. Alice sees the locking conditions defined by Bob and publishes the `k` together with the signature |
| 62 | + generated by her `skA`. As a result - Alice spent funds locked by Bob. |
| 63 | + 1. If Alice doesn’t publish the relevant `k`, Bob can return funds after locktime is reached |
| 64 | +13. If Alice publishes a transaction with `k`, Bob can recognize it and extract the kvalue |
| 65 | +14. Bob calculate the needed `skEsc` as `skEsc = k + skB` |
| 66 | +15. Bob sends the transaction with the signature generated by the `skEsc` and spends funds locked by |
| 67 | +Alice. |
0 commit comments