-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support fees #8
Comments
(edit: adding link to sketch diagram, it may help to understand.) OK after several attempts at thinking about this, I think I have a workable solution with minimal changes to the proposed protocol. Discussion below takes as starting point the diagram at the bottom of https://github.com/AdamISZ/CoinSwapCS/blob/master/docs/coinswap_new.pdf , as usual. So the main goal is to prevent Carol losing any funds if Alice is malicious. I think this also addresses amount correlation, at least partially, but will keep thinking about it. So, rather as above:
Remember that we don't know in advance which of TX2 or TX3 will be used by Alice in any backout; and moreover, Alice can choose which. So the TX2 and TX3 outputs more or less have to be the same, or at least, it's pointless to create a different one such that one is more advantageous to a malicious Alice, as she will always pick that one in that case. The main idea is: add a second output to the backout transactions TX2/TX3, redeemable by Carol only (let's say p2pkh for simplicity). This allows Carol to always receive more from the backout than Alice, most importantly allowing Carol never to lose funds in case of backout/failure. The secondary idea is the use of a "blinding" Δ amount by Carol, as already mentioned above. Here is a proposed transaction "matrix": Funding transactions; note the code already randomises the output order, for simplicity we assume output 0 is the 2/2 funding utxo: TX0
TX1
Next pair are the cooperative outputs; TX4 goes to Carol, TX5 goes to Alice; note there is an open issue to add pseudo change address here, #17 . This could be additional to this basic structure. TX4
TX5
The backout transactions; they must as mentioned above have the same output amounts, but here we add an additional Carol only output TX2
TX3
AccountingCarol inputs Δ + 1 + cf + bf x 3. In cooperative case she received back (Δ + cf + bf x 2 from TX5) + (1 + cf + bf x 2 from TX4), for a net gain of (cf + bf). In recovery case she receives back (1+ bf from TX2 or TX3), and (Δ + cf x 2 + bf x 2 from both), for a net gain of (cf). However she needs to redeem that backout, so it's actually (cf - bf) gain realistically. Alice inputs 1 + cf + bf x 4. In cooperative case she received back (1 from TX5) for a net payment of cf + bf x 4. In recovery case she receives back (1+ bf from TX2 or TX3) for a net payment of cf + bf x 3; however she also needs to pay 1 bf to redeem the backout transaction (usually), so it's basically the same cost (cf + bf x 4) (without the privacy boost). Amount correlation, privacy issuesThe use of a blinding Δ is a help if I've got this right so far. The main TX4/TX5 outputs can be pretty obfuscated with the use of that; you could split them up with fake changes. You could also make delta whatever makes it most obfuscated. The idea that TX5 can have an output to both Alice and Carol doesn't seem to be a problem; Alice can take that utxo knowing it has no connection to her history. Carols cf + bf output from TX2 is going to be small; but by design should be spendable to an output of cf (doesn't have the time priority requirement that the other custom redeem script output has). |
I can't see an issue with the acconting, and I think it's fine to include the output to carol. If anything it asserts honest intentions by alice, and if she's the one making contact then it might be fair. Let's assume an honest coinswap, TX4 and TX5 are relayed. amount =
TX5's input is TX1, so
And TX4's is TX0, so
And:
Rest of this is wrong, next comments
Wrong ^ These are just some "lines on a napking", hopefully I didn't confuse the algebra altogether.. sorry if I did and please point it out. |
Yes, the whole design is based on: (1) the assumption that Alice sees Carol's service as being valuable and paying for it, (2) a perception of a difference with the Coinjoin case; that because of the backouts, it'll be far more difficult to create a 100% trustless case (it's hard enough in joinmarket!), and that there will have to some rough assessment of reputation by at least one side to gain confidence that backout will not occur. Hence trying to create a setup where Alice pays for the service, and Carol doesn't need to trust Alice at all not to be malicious. That leaves Alice needing to make a reputation decision about Carol, although the worst that happens is she loses a small chunk of fees and time. W.r.t the tracking: I think there may be a mistake in the indices of the "And" section, but the gist of it is your:
This isn't exactly correct according to the above tables? I think it's rather:
so assuming you know d (as you point out, it's the difference between tx1:0 and tx0:0 out, although remember, the tx0/1 outs are randomized so you have to know which one is the non-change), you can generate a potential match on a pair of transactions with that equality. I guess this is roughly what I expected. Let's assume timing correlation is put aside (see #18), and the analyst has to analyse basically all p2sh transactions; he can compare pairwise and generate a list of possible |
amount =
TX5's input is TX1, so
And TX4's is TX0, so
And:
so,
As discussed in #coinswap, this is going to be very hard even if this time I got it right. As the fee protocol is ironed out, we'll get a better idea on what's possible. |
Yes. I think
Re:
Well but that's a funny way to put it; it's intended to solve a problem :) Without it, the two pairs of transactions are trivially linked. Re the calculation, I think the last line, for cf, misses a
|
It's missing a lot more :) |
A point noted from the process of testing this setup:
This is suboptimal, but may still be practical, but only in a situation where one leans a bit on reputation, and losing a coinswap fee once wouldn't be much of an issue (you just move to a better provider of the service), because it's so small. But, someone willing to pay a large fee (e.g. 0.5-1% on a large amount), let's say that the market requires it, has to assess it significantly differently than if it didn't have this drawback. |
Above plan implemented in merge at cd39b5c Closing this based on it being a task towards a milestone, but feel free to keep discussing it (the last comment above does seem like a meaningful drawback). Or just start another issue. |
Reopening, just realised it wasn't part of the milestone. And it's nicer to keep continuity of discussion. |
Documentation of the above has been added in docs/fees.md |
At the risk of flip-flopping, I'm going to close this now as it's both implemented in the code, and documented, issue can be reopened or new issue opened if there are specific problems with it. |
Copypasting this here I think the blinding amount thing can be broken. In the cooperative case, Alice receives an output of 1 btc, the same tx has another output going to Carol for Delta btc. The adversary can calculate 1 + Delta btc and search the blockchain for transactions where 1 + Delta btc is the output value, which would be carol's funding tx1, therefore unmixing the coinswap. |
Yes, I agree. As I noted in the second comment: In other words, I wasn't really convinced, but it seemed like adding a delta was a net benefit. At some point later, I decided that it was not really useful except as a weak obfuscation, probably through similar logic, although I forget; but I didn't write it down anywhere. Thanks for writing it here now -> it doesn't solve amount correlation. |
I expect it will not be too hard to do this, at least in a dumb way, but it interacts awkwardly with backouts.
(EDIT I think the below is all wrong; will come back to it later)
(In the following paragraph, "bf" = bitcoin transaction fee and "cf" = coinswap fee):(The diagram at the bottom of this may help in thinking).
The simplest way to do it is to have the TX0 and TX1 amounts be different; e.g. Carol deposits 1btc to TX1, Alice deposits 1btc + bf x 4 + cf to TX0. The two paths are: Alice -> TX0 -> TX4 (Carol), and Carol -> TX1 -> TX5(Alice). So for the first of those, Carol receives 1 + bf x 2 + cf and for the second, Alice receives 1 - bf x2. The net balance is: Carol is up by cf, and Alice is down by 4 x bf + cf.
It should be coded to allow negative values for cf, just in case that turns out to be a viable idea.
This as mentioned above is the "dumb" way, because it ignores backouts. What is tricky there is that it is not known in advance which of TX2/TX3 will be the source of each sides backouts, and they must be signed and entirely fixed in advance. This is why a more persistent-identity, client/server model is more attractive, to reduce these nasty backouts to the minimum. Now, TX2 is fixed to spend the same output as TX0, and TX3 likewise for TX1. One approach is to ensure that whichever backout Alice redeems, she does not gain money, e.g. TX2 out value = TX3 out value = 1btc in the above example; this would burn the coinswap fees to miner fees and give Alice negative incentive to cheat, but would leave Carol with the same amount she put in, losing nothing. I think this might be the best and simplest compromise to start with.
This is explicitly not included in the 0.0.1 milestone, perhaps it suits a 0.1 milestone (first version usable on mainnet), but up for debate.
Other non-dumb ways to address the interaction of fees with backouts may well exist, but I'd lean against over-complicating the protocol because of it; it's already complicated enough! There is already some discussion over at JoinMarket-Org/joinmarket#335
The text was updated successfully, but these errors were encountered: