-
Notifications
You must be signed in to change notification settings - Fork 8
Description
The original coinswap has issues with amount correlation, because Alice and Carol swap the same amount of bitcoin. In this project that has been solved using the added amount Δ.
Another way of doing it is to have several transactions instead of one on each side of the coinswap. I have this written on some paper I wrote a few months ago and now I'm copying it onto github.
Right now this is the situation for coinswapping 10btc. This is just a recap of https://github.com/AdamISZ/CoinSwapCS/blob/master/docs/coinswap_new.pdf
TX0 (Alice funding)
Alice ---> Alice + Carol multisig [10btc]
TX2 (Alice refund)
TX0 ---> Carol + H(X) OR Alice + CLTV L0 [10btc]
TX4 (Alice cooperate)
TX0 ---> Carol [10btc]
And on Carol's side we have the same thing but mirrored, except Carol's timeout L1 is closer to the present than Alice's L0. (L1 < L0) This is because Alice is the one who generated the secret X.
TX1 (Carol funding)
Carol ---> Alice + Carol multisig [10btc]
TX3 (Carol refund)
TX1 ---> Alice + H(X) OR Carol + CLTV L1 [10btc]
TX5 (Carol cooperate)
TX1 ---> Alice [10btc]
For the multi-transaction scheme, there are still TX0, TX1, TX2 and so on but they are made of more than one transaction, which I'll call TX0_0, TX0_1, TX1_0, TX1_1 and so on. The hashlock secret H(X) and timelock times L1, L0 are the same for everything. This example uses two transactions but it could work for three or four transactions.
The privacy for amount correlation comes from the subset-sum problem. If the adversary sees Alice mixing 10btc they need to scan the entire blockchain in the relevant period looking for transaction outputs which together add up to 10btc. The subset sum problem is NP-complete and increasing the number of transactions N generally increases the difficulty of the problem exponentially.
Here is a scheme for mixing 10btc, Alice creates a coinswap with 9btc + 1btc, Carol creates a coinswap with 8btc + 2btc
(Alice funding)
TX0_0
Alice ---> Alice + Carol multisig [9btc]
TX0_1
Alice ---> Alice + Carol multisig [1btc]
(Alice refund)
TX2_0
TX0_0 ---> Carol + H(X) OR Alice + CLTV L0 [9btc]
TX2_1
TX0_1 ---> Carol + H(X) OR Alice + CLTV L0 [1btc]
(Alice cooperate)
TX4_0
TX0_0 ---> Carol [9btc]
TX4_1
TX0_1 ---> Carol [1btc]
Carol's transactions are:
(Carol funding)
TX1_0
Carol ---> Alice + Carol multisig [8btc]
TX1_1
Carol ---> Alice + Carol multisig [2btc]
(Carol refund)
TX3_0
TX1_0 ---> Alice + H(X) OR Carol + CLTV L1 [8btc]
TX3_1
TX1_1 ---> Alice + H(X) OR Carol + CLTV L1 [2btc]
(Carol cooperate)
TX5_0
TX1_0 ---> Alice [8btc]
TX5_1
TX1_1 ---> Alice [2btc]
The order of events is similar to single-transaction coinswap.
- Both sides swap public keys and parameters (H(X), L0, L1) with each other
- Both sides create the funding transactions TX0_0, TX0_1, TX1_0, TX1_1 (but dont reveal yet)
- They create refund transactions TX2_0, TX2_1, TX3_0, TX3_1, they reveal them to each other and get the other's signature.
- They broadcast the funding transactions and wait for confirmations.
- If the other side doesn't broadcast, the first side can use the refund transactions to get their money back, either after a delay or using the X secret if they know it.
- They create the cooperative transactions TX4_0, TX4_1, TX5_0, TX5_1 and send the unsigned transaction to the other party which sends back its signature.
- Only sending the unsigned transaction means the other side can't broadcast just one transaction, which avoids an attack. Only one party knows the final fully-signed transactions TX4 and TX5 and they broadcast them together (or with some delay for privacy)
- If one side broadcasts just one refund transaction (e.g. TX4_0) then that counts as non-cooperation and the other side broadcasts the other (TX4_1) and the whole setup goes into the non-cooperative state where people either reveal the secret X or wait for the timeouts L0/L1.
This also works with different numbers of transactions on each side. So for example Alice could have just bought bitcoins from a very un-private exchange and wants to mix them. She can create just one TX0 but receive 5 or 6 TX5s from Carol. Probably in practice Carol would choose the number of TX5s to fit with how many UTXOs she has so that she don't have to create too many change addresses.