Research/Bitcoin Dev Archive / lightning-dev list
ThunderNetwork - A Java LightningNetwork Implementation Working Today
9 messages, Aug 11 to 14, 2015. Started by Mats Jerratsch.
Mats Jerratsch (4), Joseph Poon (4), Rusty Russell
Hey Joseph,
thank you very much for your invaluable feedback!
Can you elaborate, why you think that the client is not able to close the channel? I think this is a misunderstanding on your side, which most of the rest of your post argues from. While there is a slight favor for the server in the channel design, there is nothing what prevents the client from broadcasting (and enforcing) the channel.
I will of course respect your inquiry - if you really mean it after that misunderstanding - and stop calling it a Lightning Network implementation as long as it does not provide the complete no-trust.
I have thought a lot about RBF, and it is definitely a problem with this implementation.
2015-08-11 20:30 GMT+02:00 Joseph Poon <joseph at lightning.network>:
Quoted text (73 lines)
> Hi Mats, > > Interesting work on payment channels, I think a lot of the bitcoinj code > can be used for further development as the necessary bitcoin softforks > for LN are incorporated. A bitcoinj implementation for lightning would > be great! > > On Tue, Aug 11, 2015 at 06:12:04PM +0200, Mats Jerratsch wrote: >> I present you a implementation for a Lightning Network Payment-Hub + >> Client. Everything is written in Java and can be accessed on > > Can you do me a big favor and not call this an implementation for > Lightning Network, though? I would prefer some name like "payment > channel networks" or something similar, as it's materially different in > design and trust models. In particular, if exit scams occur, I don't > want it to be associated with Lightning Network. > >> I made some changes to the channel design to have everything working >> on the current Blockchain, without the need for softforks. Due to >> that, the network is no longer no-trust, but low-trust. This will >> change with the upcoming new OP_CODES. > > Yeah, a lot of the code can definitely be used for a full LN > implementation when the opcodes come in for sure! > >> The provided wallet is just a prototype, I will focus on building a >> potent backend in the future. There are many wallets out there >> already, it will be much more useful if those add these >> functionalities. > > Some quick feedback (might have more later): > * I don't think a dual-Commitment structure is necessary if only one > party can close out the channel. The purpose of having two Commitments > is so that the payout structure is different. In this case, since only > the server can broadcast the final balance (and the client has no way > to close out the channel), only the B Commitment is necessary). > * HTLCs have significant malleability risks with malicious servers > (hostage scenarios). > * If you presume full-RBF (which I think is a game-theoretic > eventuality), clients can pay a higher fee to mutate the server's > broadcast of the Commitment, which will result in the server's funds > being held up permanently until the server is willing to negotiate > (malleability hostage scenario). > * Exit Scamming is a distinct and likely possibility. The server can > develop a good reputation for a while, then decide to screw over > everyone. The server refuses to do any further transactions in any > channel which has funds in the clients favor (current channel balance > for the client is above what was funded). With the timeout, the server > gets the original deposit back, which is above what they should get > back, in other words, the server steals your money. > * This creates an asymmetric playing field. If one cannot be confident > they will receive their funds back, this is similar to depositing your > money on a hosted wallet such as Coinbase or whatever. The primary > value of transacting on bitcoin is that the social costs of > counterparty risks are minimized -- and counterparty risk is one of > the primary inputs on interest rates (remove trust -> remove > counterparty risk -> remove fees/interest). This can only exist if > you're sufficiently willing to transact with nearly anyone (minimal > underwriting). > >> Furthermore, as there are less everyday payments on the blockchain, >> there is more space for important transactions of higher value. > > I agree that this is one of the primary values of payment channel based > systems. To extend and take your point in a different direction, there > is a risk if everyone uses blockchain transactions for every day > purchases, that high-value transactions will crowd out low-value > transactions. There is a tension that exists between the need for > sufficiently high fees to pay miners (when the block rewards decline) > and allowing low-fee transactions to be on-chain in a timely manner. > > -- > Joseph Poon
On Tue, Aug 11, 2015 at 08:42:50PM +0200, Mats Jerratsch wrote:
Quoted text (5 lines)
> Can you elaborate, why you think that the client is not able to close > the channel? I think this is a misunderstanding on your side, which > most of the rest of your post argues from. While there is a slight > favor for the server in the channel design, there is nothing what > prevents the client from broadcasting (and enforcing) the channel.
Ah, sorry, i'm reading it more closely now. I assumed only the server had a copy since that what made the most sense to me under this kind of asymmetric model, since it makes sense to not trust the client.
In this case, the client can hold up funds from the server completely and attack the server by mutating their transaction.
Presume Alice and Bob have a channel open together. They both contributed 0.5 bitcoin for a total balance of 1 BTC.
At Commitment 20, the channel state is 0 BTC to Alice and 1 to Bob. At commitment 31, the channel state is 1 BTC to Alice and 0 to Bob.
Alice is the client and Bob is the server.
Presume Alice deicdes to be a jerk! She broadcasts a mutated (re-signed) version of Commitment 20. The server is out 1 BTC! This is now a hostage negotiation.
Let's presume that you set up some kind of reserve requirement instead: At Commitment 20, the channel state is 0.05 BTC to Alice and 0.95 to Bob. At commitment 31, the channel state is 0.95 BTC to Alice and 0.05 to Bob.
Again, Alice deicdes to be a jerk! She broadcasts a mutated (re-signed) version of Commitment 20. The server is out 0.95 BTC! But wait, you say, Alice might be out 0.05 of her own BTC. This model breaks down because it's still a hostage scenario! Alice tells Bob, "hey, I know I have 0.05 BTC stuck here (and you have 0.9 stuck), but I'm rich. I don't care how long it takes, how about you give me a 'tax' of 0.1 BTC. You'll get your money back... well most of it, just sign this transaction where I get 0.15".
2015-08-11 21:16 GMT+02:00 Joseph Poon <joseph at lightning.network>:
Quoted text (10 lines)
> On Tue, Aug 11, 2015 at 08:42:50PM +0200, Mats Jerratsch wrote: >> Can you elaborate, why you think that the client is not able to close >> the channel? I think this is a misunderstanding on your side, which >> most of the rest of your post argues from. While there is a slight >> favor for the server in the channel design, there is nothing what >> prevents the client from broadcasting (and enforcing) the channel. > > Ah, sorry, i'm reading it more closely now. I assumed only the server > had a copy since that what made the most sense to me under this kind of > asymmetric model, since it makes sense to not trust the client.
Ah I see, yes, theres a lot of additional documentation needed. When you have your head that deep into some topic for months, you assume everyone looks at your notes and understands everything just perfectly.
[...]
Quoted text (8 lines)
> At Commitment 20, the channel state is 0 BTC to Alice and 1 to Bob. > At commitment 31, the channel state is 1 BTC to Alice and 0 to Bob. > > Alice is the client and Bob is the server. > > Presume Alice deicdes to be a jerk! She broadcasts a mutated (re-signed) > version of Commitment 20. The server is out 1 BTC! This is now a hostage > negotiation.
But the 1 BTC of Commitment 20 goes straight to Bob (and not to a multi-sig address). Mutating a channel transaction only hurts the party that is doing the mutation. This is why RBF is a major problem, if it ever gets deployed.
Quoted text (12 lines)
> Let's presume that you set up some kind of reserve requirement instead: > At Commitment 20, the channel state is 0.05 BTC to Alice and 0.95 to Bob. > At commitment 31, the channel state is 0.95 BTC to Alice and 0.05 to Bob. > > Again, Alice deicdes to be a jerk! She broadcasts a mutated (re-signed) > version of Commitment 20. The server is out 0.95 BTC! But wait, you say, > Alice might be out 0.05 of her own BTC. This model breaks down because > it's still a hostage scenario! Alice tells Bob, "hey, I know I have 0.05 > BTC stuck here (and you have 0.9 stuck), but I'm rich. I don't care how > long it takes, how about you give me a 'tax' of 0.1 BTC. You'll get your > money back... well most of it, just sign this transaction where I get > 0.15".
The same as above, if she resignes commitment 20, she is losing 0.05 BTC, while Bob does still get the 0.95 BTC.
There is a problem with channel histories, where Alice holds all the funds at one point, and Bob holds all the funds at some later point, as open payments are not as secure as those settled balances. I mitigate this by setting a hard requirement on the spendable amount. I will describe this in more detail soon.
Best Regards, Mats Jerratsch
Quoted text (3 lines)
> > -- > Joseph Poon
On Tue, Aug 11, 2015 at 09:26:43PM +0200, Mats Jerratsch wrote:
Quoted text (13 lines)
> > At Commitment 20, the channel state is 0 BTC to Alice and 1 to Bob. > > At commitment 31, the channel state is 1 BTC to Alice and 0 to Bob. > > > > Alice is the client and Bob is the server. > > > > Presume Alice deicdes to be a jerk! She broadcasts a mutated (re-signed) > > version of Commitment 20. The server is out 1 BTC! This is now a hostage > > negotiation. > > But the 1 BTC of Commitment 20 goes straight to Bob (and not to a > multi-sig address). Mutating a channel transaction only hurts the > party that is doing the mutation. This is why RBF is a major problem, > if it ever gets deployed.
Sorry, I usually use Bob as the attacker in my examples and Alice as the client, so I got mixed up there. I meant: At Commitment 20, the channel state is 1 BTC to Alice and 0 to Bob. At commitment 31, the channel state is 0 BTC to Alice and 1 to Bob.
In this case, if Alice attacks Bob she's not out any money, but Bob has funds locked up in a 2-of-2. Bob must now negotiate with Alice to get his money back. Alice will probably want some 'convenience fee'.
Quoted text (16 lines)
> > > Let's presume that you set up some kind of reserve requirement instead: > > At Commitment 20, the channel state is 0.05 BTC to Alice and 0.95 to Bob. > > At commitment 31, the channel state is 0.95 BTC to Alice and 0.05 to Bob. > > > > Again, Alice deicdes to be a jerk! She broadcasts a mutated (re-signed) > > version of Commitment 20. The server is out 0.95 BTC! But wait, you say, > > Alice might be out 0.05 of her own BTC. This model breaks down because > > it's still a hostage scenario! Alice tells Bob, "hey, I know I have 0.05 > > BTC stuck here (and you have 0.9 stuck), but I'm rich. I don't care how > > long it takes, how about you give me a 'tax' of 0.1 BTC. You'll get your > > money back... well most of it, just sign this transaction where I get > > 0.15". > > The same as above, if she resignes commitment 20, she is losing 0.05 > BTC, while Bob does still get the 0.95 BTC.
At Commitment 20, the channel state is 0.95 BTC to Alice and 0.05 to Bob. At commitment 31, the channel state is 0.05 BTC to Alice and 0.95 to Bob.
Quoted text (5 lines)
> There is a problem with channel histories, where Alice holds all the > funds at one point, and Bob holds all the funds at some later point, > as open payments are not as secure as those settled balances. I > mitigate this by setting a hard requirement on the spendable amount. I > will describe this in more detail soon.
You can't mitigate this by setting some reserve requirement, though. So long as Alice has more money than Bob, she can do it. If Alice is 10x richer than Bob, she doesn't *care* and she knows Bob will eventually give up. "Two-party escrow" doesn't work because one party can have more money and less time-value than another. Time-value is not a universal value.
2015-08-11 22:06 GMT+02:00 Joseph Poon <joseph at lightning.network>:
Quoted text (24 lines)
> On Tue, Aug 11, 2015 at 09:26:43PM +0200, Mats Jerratsch wrote: >> > At Commitment 20, the channel state is 0 BTC to Alice and 1 to Bob. >> > At commitment 31, the channel state is 1 BTC to Alice and 0 to Bob. >> > >> > Alice is the client and Bob is the server. >> > >> > Presume Alice deicdes to be a jerk! She broadcasts a mutated (re-signed) >> > version of Commitment 20. The server is out 1 BTC! This is now a hostage >> > negotiation. >> >> But the 1 BTC of Commitment 20 goes straight to Bob (and not to a >> multi-sig address). Mutating a channel transaction only hurts the >> party that is doing the mutation. This is why RBF is a major problem, >> if it ever gets deployed. > > Sorry, I usually use Bob as the attacker in my examples and Alice as the > client, so I got mixed up there. I meant: > At Commitment 20, the channel state is 1 BTC to Alice and 0 to Bob. > At commitment 31, the channel state is 0 BTC to Alice and 1 to Bob. > > In this case, if Alice attacks Bob she's not out any money, but Bob has > funds locked up in a 2-of-2. Bob must now negotiate with Alice to get > his money back. Alice will probably want some 'convenience fee'. >
But Bob has both keys of the 2-of-2 multisig. One is his (main) key, and the other one was supplied by Alice as a requirement to update the channel and move funds. But that is what I meant with mitigate it. Even if Bob claims all payments, he will lose funds due to blockchain fees. (see below)
Quoted text (6 lines)
> You can't mitigate this by setting some reserve requirement, though. So > long as Alice has more money than Bob, she can do it. If Alice is 10x > richer than Bob, she doesn't *care* and she knows Bob will eventually > give up. "Two-party escrow" doesn't work because one party can have more > money and less time-value than another. Time-value is not a universal > value.
It is possible to say that the minimum (stealable) amount of Alice must be higher than any sum of concurrent payments minus the blockchain fees. This way Bob can always claim all the payments of all Commitments of the Channel and still stay in positive net balance. It really comes down to having an incentive to clear out payments of the channel. Only open payments are problematic, settled balance can always be stealed with just one transaction.
Mats Jerratsch
Ah I see, if you use a hash-based revocation, then the only primary attack vector left is with the Funding and HTLCs (which can be partially mitigated with a reserve)
On 8/11/15, Mats Jerratsch <matsjj at gmail.com> wrote:
Quoted text (51 lines)
> 2015-08-11 22:06 GMT+02:00 Joseph Poon <joseph at lightning.network>: >> On Tue, Aug 11, 2015 at 09:26:43PM +0200, Mats Jerratsch wrote: >>> > At Commitment 20, the channel state is 0 BTC to Alice and 1 to Bob. >>> > At commitment 31, the channel state is 1 BTC to Alice and 0 to Bob. >>> > >>> > Alice is the client and Bob is the server. >>> > >>> > Presume Alice deicdes to be a jerk! She broadcasts a mutated >>> > (re-signed) >>> > version of Commitment 20. The server is out 1 BTC! This is now a >>> > hostage >>> > negotiation. >>> >>> But the 1 BTC of Commitment 20 goes straight to Bob (and not to a >>> multi-sig address). Mutating a channel transaction only hurts the >>> party that is doing the mutation. This is why RBF is a major problem, >>> if it ever gets deployed. >> >> Sorry, I usually use Bob as the attacker in my examples and Alice as the >> client, so I got mixed up there. I meant: >> At Commitment 20, the channel state is 1 BTC to Alice and 0 to Bob. >> At commitment 31, the channel state is 0 BTC to Alice and 1 to Bob. >> >> In this case, if Alice attacks Bob she's not out any money, but Bob has >> funds locked up in a 2-of-2. Bob must now negotiate with Alice to get >> his money back. Alice will probably want some 'convenience fee'. >> > > But Bob has both keys of the 2-of-2 multisig. One is his (main) key, > and the other one was supplied by Alice as a requirement to update the > channel and move funds. > But that is what I meant with mitigate it. Even if Bob claims all > payments, he will lose funds due to blockchain fees. (see below) > >> You can't mitigate this by setting some reserve requirement, though. So >> long as Alice has more money than Bob, she can do it. If Alice is 10x >> richer than Bob, she doesn't *care* and she knows Bob will eventually >> give up. "Two-party escrow" doesn't work because one party can have more >> money and less time-value than another. Time-value is not a universal >> value. > > It is possible to say that the minimum (stealable) amount of Alice > must be higher than any sum of concurrent payments minus the > blockchain fees. This way Bob can always claim all the payments of all > Commitments of the Channel and still stay in positive net balance. It > really comes down to having an incentive to clear out payments of the > channel. Only open payments are problematic, settled balance can > always be stealed with just one transaction. > > Mats Jerratsch >
Sweet!
Do you mind if I start calling it a Lightning Network Implementation then? ;)
Also note that both these problems can be eliminated with OP_CLTV, which will be implemented at least somewhat soon.
2015-08-11 22:33 GMT+02:00 Joseph Poon <joseph at lightning.network>:
Quoted text (56 lines)
> Ah I see, if you use a hash-based revocation, then the only primary > attack vector left is with the Funding and HTLCs (which can be > partially mitigated with a reserve) > > On 8/11/15, Mats Jerratsch <matsjj at gmail.com> wrote: >> 2015-08-11 22:06 GMT+02:00 Joseph Poon <joseph at lightning.network>: >>> On Tue, Aug 11, 2015 at 09:26:43PM +0200, Mats Jerratsch wrote: >>>> > At Commitment 20, the channel state is 0 BTC to Alice and 1 to Bob. >>>> > At commitment 31, the channel state is 1 BTC to Alice and 0 to Bob. >>>> > >>>> > Alice is the client and Bob is the server. >>>> > >>>> > Presume Alice deicdes to be a jerk! She broadcasts a mutated >>>> > (re-signed) >>>> > version of Commitment 20. The server is out 1 BTC! This is now a >>>> > hostage >>>> > negotiation. >>>> >>>> But the 1 BTC of Commitment 20 goes straight to Bob (and not to a >>>> multi-sig address). Mutating a channel transaction only hurts the >>>> party that is doing the mutation. This is why RBF is a major problem, >>>> if it ever gets deployed. >>> >>> Sorry, I usually use Bob as the attacker in my examples and Alice as the >>> client, so I got mixed up there. I meant: >>> At Commitment 20, the channel state is 1 BTC to Alice and 0 to Bob. >>> At commitment 31, the channel state is 0 BTC to Alice and 1 to Bob. >>> >>> In this case, if Alice attacks Bob she's not out any money, but Bob has >>> funds locked up in a 2-of-2. Bob must now negotiate with Alice to get >>> his money back. Alice will probably want some 'convenience fee'. >>> >> >> But Bob has both keys of the 2-of-2 multisig. One is his (main) key, >> and the other one was supplied by Alice as a requirement to update the >> channel and move funds. >> But that is what I meant with mitigate it. Even if Bob claims all >> payments, he will lose funds due to blockchain fees. (see below) >> >>> You can't mitigate this by setting some reserve requirement, though. So >>> long as Alice has more money than Bob, she can do it. If Alice is 10x >>> richer than Bob, she doesn't *care* and she knows Bob will eventually >>> give up. "Two-party escrow" doesn't work because one party can have more >>> money and less time-value than another. Time-value is not a universal >>> value. >> >> It is possible to say that the minimum (stealable) amount of Alice >> must be higher than any sum of concurrent payments minus the >> blockchain fees. This way Bob can always claim all the payments of all >> Commitments of the Channel and still stay in positive net balance. It >> really comes down to having an incentive to clear out payments of the >> channel. Only open payments are problematic, settled balance can >> always be stealed with just one transaction. >> >> Mats Jerratsch >>
Hi Mats,
On Tue, Aug 11, 2015 at 10:44:27PM +0200, Mats Jerratsch wrote:
Quoted text (2 lines)
> Do you mind if I start calling it a Lightning Network Implementation > then? ;)
I can't stop you from calling it whatever you want, however, I'm just concerned with any system which has some implicit level of trust, especially with long-term systemic risks (e.g. implications for fungibility, and other social accessibility costs). The goal of LN is to allow you to connect to anyone without the risk of the counterparty outright stealing or encumbering funds.
So if the purpose is to get it working today with some trust compromises, then any potential design trust issues may be associated with LN. I don't want to encourage the use of systems which lets you maliciously encumber HTLC funds in transit and funding on main-net. As much as I would absolutely appreciate how a semi-trusted implementation would help counter the "Lightning doesn't exist" meme, it seems simpler to test with the new opcodes using dummy opcodes on testnet. I think we need not only the opcodes, but also long-term I see some kind of malleability fix and timestop as ideal if not necessary.
Quoted text (2 lines)
> Also note that both these problems can be eliminated with OP_CLTV, > which will be implemented at least somewhat soon.
Yes, if it uses the new opcodes similar to Rusty's construction, then it's a LN implementation for sure (it will especially help with HTLCs in transit). Do you expect any significant differences (beyond a balance reserve for just OP_CLTV)? I think a bitcoinj implementation of Lightning is sorely needed, for sure, and greatly appreciate any implementation, as it's a huge positive step for the bitcoin ecosystem! I feel like we might have gotten off on the wrong foot here (partially due to me misunderstanding the design), I think we both agree that scalability of bitcoin micropayments is something that is very important to the wider ecosystem and I'm looking forward to continuing developing these techonlogies with you!
Joseph Poon <joseph at lightning.network> writes:
Quoted text (4 lines)
> I think a bitcoinj implementation of > Lightning is sorely needed, for sure, and greatly appreciate any > implementation, as it's a huge positive step for the bitcoin > ecosystem!
Me too!
Sorry I've been a bit non-responsive: I really want to make sure I'm happy with the basic inter-node protocol so we can start sharing it (yay, a bakeoff!).
I love doing protocol design with fellow implementers: it tends to cut through the crap and get a good result. And protocols are hard...
Cheers! Rusty.