Research/Bitcoin Dev Archive / lightning-dev list
Resumable channels using OP_CHECKSIGFROMSTACK
14 messages, Aug 14 to 30, 2023. Started by Thomas Voegtlin.
Thomas Voegtlin (5), Bastien TEINTURIER (4), Peter Todd (3), SomberNight, GamedevAlice
Hello list,
Here is an idea to make lightning channels resumable from wallet seed. I have not implemented it yet, and there might be issues I am not seeing. Thus, I would be grateful for feedback.
Thanks to SomberNight and Peter Todd for reviewing earlier versions of this proposal.
Thomas
-----------------------------------------------
Resumable channels using OP_CHECKSIGFROMSTACK =============================================
In order to resume the activity of a Lightning channel, one needs a backup that contains all the information about the current channel state. The need to perform channel backups has plagued user experience, with many implementations reverting to static backups, which can be used to recover funds, but not to resume channel operations.
Asking your channel counterparty to store your channel state has the advantage to make backup operations atomic. However, there is no guarantee that this is safe. Indeed, if the other party suspects that you have lost your state (for example, because you have been offline for a long time, or if they can see that you requested blockchain information following a certain pattern), they can try to send you a revoked state, and there is no way to punish them for doing that.
Here is a proposal for a new type of channel funding transaction, where the redeem script has an additional spending path, that accepts a fraud proof: a proof that the channel counterparty has lied about the current state. This proposal requires two opcodes that are currently not available in Bitcoin: OP_CAT and OP_CHECKSIGFROMSTACK.
Roles are asymmetric in this channel: Alice is a client, and Bob is a server, who stores Alice's state. Thus, this proposal is mostly suited for private channels with Lightning service providers. During channel reestablishment, Bob will send her latest state to Alice, using an extra field in the channel_reestablish message. Since Alice cannot punish Bob if she has lost her state, she must not let Bob learn whether she still has her state. Thus, Alice will never send channel_reestablish first.
This proposal assumes that Alice and Bob each have a clock, and that these clocks do not drift too much relative to each other. The channel may become unusable if clocks differ too much, as discussed below.
Simplified description ----------------------
The *state* of the channel refers to everything Alice needs in order to resume channel operations. With every new commitment, Alice sends her current state, with her signature of that state:
- if Alice sends commitment_signed, the state and signature are
included in that message.
- if Alice receives commitment_signed, the state and signature will
be included in the next revoke_and_ack sent by Alice.
With every new commitment, Bob sends a signed tuple (ctn, timestamp), where ctn is the current commitment number (for the moment, forget about the distinction between local and remote ctns), and timestamp is the current time for Bob.
- if Bob sends commitment_signed, the signed tuple is included in
that message.
- if Bob receives commitment_signed, the signed tuple will be
included in the next revoke_and_ack sent by Bob.
The private key used by Bob to sign the tuples is constant over the lifetime of the channel, and it must not be reused in other channels. The corresponding public key will be used in the fraud proof spending path of the redeem script.
Alice verifies Bob's signature. She also checks that the received timestamps are reasonable (see below) and strictly monotonic.
With every channel_reestablish message, Bob will send two extra fields: - (ctn, timestamp, bob_signature) - (alice_state, alice_signature).
Alice verifies that the state she received was signed by her, and that the (ctn, timestamp) tuple was signed by Bob. She also checks that the timestamp is reasonable.
Fraud Proofs ------------
Let us assume that Bob tries to send a revoked state to Alice in channel_reestablish. The channel_reestablish received by Alice contains a signed tuple (ctn1, t1), with t1 current timestamp.
However, another signed tuple (ctn2, t2) has been received in the past, with ctn1 < ctn2 and t1 > t2.
If Alice has not lost her state, she will now hold two signed tuples (ctn1, t1) and (ctn2, t2), that satisfy ctn1 < ctn2 and t1 > t2.
This constitutes a fraud proof. With OP_CAT and OP_CHECKSIGFROMSTACK, we can build a script that verifies the fraud proof, and allows Alice to unilaterally spend the channel funding output.
Here is an example of such a script:
witness: [ alice_signature(transaction) bob_signature((ctn1,timestamp1)) ctn1 timestamp1 bob_signature((ctn2,timestamp2)) ctn2 timestamp2 ]
witness_script: OP_PICK 1 OP_PICK 4 OP_LESSTHAN # verify ctn1 < ctn2 OP_VERIFY OP_PICK 0 OP_PICK 3 OP_GREATERTHANOREQUAL # verify timestamp1 >= timestamp2 OP_VERIFY # check signatures OP_CAT OP_PUSHDATA bob_pubkey # we may use Bob's funding_pubkey OP_CHECKSIGFROMSTACK OP_VERIFY OP_CAT OP_PUSHDATA bob_pubkey OP_CHECKSIGFROMSTACK OP_VERIFY OP_PUSHDATA alice_pubkey # we may use Alice's funding_pubkey OP_CHECKSIGVERIFY
In order to keep things simple, a few details have been omitted in the description:
- Bob actually needs to send both the local and the remote ctns in
his signed tuples. A pair of tuples is a fraud proof if the order
is violated for either local or remote ctns. Thus, the actual
script will be more complex than what has been drafted above.
- Integers pushed on the Bitcoin stack are maximum 4 bytes (31 bits +
1 bit for the sign). Since commitment numbers are 48 bits long,
they will need to be split into two integers. Timestamps might
require a similar decomposition. This adds further complexity to
the redeem script.
- Note that Bob must strictly increase his timestamp on each
ctn. This puts a lower bound on the precision used for timestamps.
Reasonable Timestamps ---------------------
Since Alice and Bob do not have the same clock, Bob may legitimately send a timestamp that is in Alice's past or future. Every time Alice receives a timestamp from Bob, she compares it to her current time.
- If Alice receives a timestamp that is in her future, instead of
closing the channel, she may wait it out before she accepts to
resume operations.
- If Alice receives a timestamp that is too far in her past, she
should disconnect. Indeed, Bob may be sending an old state and
replaying old timestamps, which is not punishable. In that case,
Alice should not automatically force close the channel, because she
can only do that if she has not lost her state; if force-closing
was automatic, not force-closing would reveal to Bob that she
has lost her state.
A delay needs to be tolerated by Alice, because Bob does not have the same clock; that delay should be chosen so that it is always smaller than the interval between two sessions.
Saving Bandwidth ----------------
Alice's channel state does not need to be sent with every commitment, if it is made of information that is known by both parties. In that case, it is sufficient for Alice to send her signature of the current state. Both Alice and Bob must be able to serialize the state, so that Alice can verify her own signature against a serialization of the state created by Bob. The state only needs to be sent by Bob once, in channel_reestablish.
For this to work, the channel state cannot include information that is private to Alice. If the private keys used by Alice in the channel are derived deterministically from her wallet seed, they do not need to be part of the state. Alternatively, private keys may be included in an encrypted blob that is included in the state. Since that encrypted blob is constant, it only needs to be sent once by Alice, during the channel opening negotiation. Bob will save it and add it to the state sent in channel_reestablish.
In addition, the state must not include any payment_hash preimage known by Alice; thus, Alice will have to fail incoming payments for those preimages, if she has lost her state.
The channel state should include the compact storage of per-commitment secrets sent by Bob.
Concluding remarks ------------------
- Obviously, this proposal assumes that Alice remembers with whom she
has an open channel.
- Alice may restore her wallet from seed on a new device, while the
initial wallet is still active. In that case, Alice must stop using
the channels on her old device. Thus, Alice should disconnect if
she has not lost her state and receives a state with a ctn that is
in her future. This ensures that only one device uses the channels.
- Without waiting for OP_CHECKSIGFROMSTACK to be available in
Bitcoin, it would be possible for Bob to lockup funds on another
blockchain such as Liquid. It is also possible to create fraud
proofs that are not used in a redeem script, but that are tied to
Bob's public identity and reputation. In that case, Bob should sign
with his node pubkey, and fraud proofs will need to include a short
channel id.On Mon, Aug 14, 2023 at 02:59:16PM +0200, Thomas Voegtlin wrote:
Quoted text (18 lines)
> Resumable channels using OP_CHECKSIGFROMSTACK > ============================================= > > > In order to resume the activity of a Lightning channel, one needs a > backup that contains all the information about the current channel > state. The need to perform channel backups has plagued user > experience, with many implementations reverting to static backups, > which can be used to recover funds, but not to resume channel > operations. > > Asking your channel counterparty to store your channel state has the > advantage to make backup operations atomic. However, there is no > guarantee that this is safe. Indeed, if the other party suspects that > you have lost your state (for example, because you have been offline > for a long time, or if they can see that you requested blockchain > information following a certain pattern), they can try to send you a > revoked state, and there is no way to punish them for doing that.
As we discussed on Signal, it'd be most useful for me to write up my counter-arguement to this part of your proposal here for others to read as well.
I believe backing up channel state with your counterparty is both useful, and significantly less risky than it initially appears. The basic reason why is that client can make fraud uneconomical by checking the backup each time they connect, and immediately closing the channel if the wrong backup is provided.
# Definitions
Let's say Alice has a private channel open with Bob, and Alice is also storing a channel state backup with Bob.
Define V_h as the honest lifetime value of the channel to Bob. By "honest lifetime value" we mean the value of the channel in terms of expected fees. Since this is a private channel, Bob can expect no other benefits (Bob can't route through the channel).
Define V_f as the value Bob can fraudulently obtain by giving Alice an incorrect backup.
Define P_d as the probability of data loss since the last time Alice connected to Bob.
# Protocol
## Normal Operation
Each time Alice connects to Bob, Alice asks Bob for a copy of the most recent channel state backup. If the backup is incorrect, Alice immediately force closes the channel.
## Recovery
Alice asks Bob for a copy of the most recent channel state backup, in exactly the same fashion as in Normal Operation. The only difference is Alice now uses that backup.
# Analysis
Bob can profit from fraudulently giving Alice an incorrect backup if:
V_f * P_d > V_h
So, what does this mean? First of all, note that V_f is non-zero only when the channel balance from Alice's perspective has increased: there needs to be a previous valid channel balance where Alice had less funds than now.
Secondly, note that P_d is a probability that Bob wants to estimate, based on the information Bob has at hand. For example, if Alice typically connects to Bob once an hour, but has been offline for a week, Bob might suppose that it's more likely that Alice has lost data than otherwise. On the other hand, if Alice('s) regularly go a few days without connecting, a delay of a few days is not evidence of data loss.
Suppose that Alice goes a few days without connecting to Bob 10 times per year, and this particular connection attempt is an example of that 10/year event. Suppose that Alice has a 1% chance of data loss per year that **requires her to use Bob's channel state backup**, and suppose that with 100% certainty, in the event of data loss Alice would take a few days to attempt recovery. That means that this particular connection event represents a 1% / 10 = 0.1% probability event, and P_d = 0.1%
Let's suppose that at some point in the channel's history Alice has completely drained her channel, and at this point it has been totally refilled. That means that V_f is equal to the balance of her channel, as Bob could give Alice a channel state backup corresponding to the state when Alice had zero balance, while her balance now is 100%.
Recall that V_h is the revenue Bob expects to get from the channel in the future. For example, if Bob makes on average 0.2% fees, and reasonably expects Alice to drain the channel one more time over the future life of the channel, it's not rational for Bob to attempt channel state fraud because:
V_f * 0.1% < V_f * 0.2%
# Conclusion
I believe these numbers are reasonable estimates for a reasonable worst-case scenario. They strongly suggest that storing channel backups with peers is valuable, and that in many - possibly most - cases fraud would not be economically rational. Of course, with encryption we can also store channel backups redundantly, across multiple channel peers. And supporting watchtowers in addition further improves this situation by reducing the probability of actual data loss, and decreasing the chance of a succesful fraud.
Hi Thomas,
I don't think those fraud proofs are necessary at all. They're also dangerous, because they impose a hard penalty on LSPs for something that should be best effort (and could get desynchronized by connection issues, especially with flaky mobile connections).
I agree with Peter Todd that since the mobile wallet can check the state of the returned backup at every connection request, this makes it highly unlikely that the LSP can cheat: that's the approach we've taken for Phoenix.
I'm surprised that you don't mention the BOLT PR we created for those backups in [1], I believe that is sufficient. It should probably be moved to a blip instead of a BOLT once we've implemented this version (the approach we use in Phoenix currently is slightly different), but apart from that it contains all the mechanisms necessary to achieve this today.
Cheers, Bastien
[1] https://github.com/lightning/bolts/pull/881
Le mar. 15 août 2023 à 05:52, Thomas Voegtlin <thomasv at electrum.org> a écrit :
Quoted text (239 lines)
> Hello list, > > Here is an idea to make lightning channels resumable from wallet seed. > I have not implemented it yet, and there might be issues I am not > seeing. Thus, I would be grateful for feedback. > > Thanks to SomberNight and Peter Todd for reviewing earlier versions of > this proposal. > > Thomas > > > ----------------------------------------------- > > Resumable channels using OP_CHECKSIGFROMSTACK > ============================================= > > > In order to resume the activity of a Lightning channel, one needs a > backup that contains all the information about the current channel > state. The need to perform channel backups has plagued user > experience, with many implementations reverting to static backups, > which can be used to recover funds, but not to resume channel > operations. > > Asking your channel counterparty to store your channel state has the > advantage to make backup operations atomic. However, there is no > guarantee that this is safe. Indeed, if the other party suspects that > you have lost your state (for example, because you have been offline > for a long time, or if they can see that you requested blockchain > information following a certain pattern), they can try to send you a > revoked state, and there is no way to punish them for doing that. > > Here is a proposal for a new type of channel funding transaction, > where the redeem script has an additional spending path, that accepts > a fraud proof: a proof that the channel counterparty has lied about > the current state. This proposal requires two opcodes that are > currently not available in Bitcoin: OP_CAT and OP_CHECKSIGFROMSTACK. > > Roles are asymmetric in this channel: Alice is a client, and Bob is a > server, who stores Alice's state. Thus, this proposal is mostly suited > for private channels with Lightning service providers. During channel > reestablishment, Bob will send her latest state to Alice, using an > extra field in the channel_reestablish message. Since Alice cannot > punish Bob if she has lost her state, she must not let Bob learn > whether she still has her state. Thus, Alice will never send > channel_reestablish first. > > This proposal assumes that Alice and Bob each have a clock, and that > these clocks do not drift too much relative to each other. The channel > may become unusable if clocks differ too much, as discussed below. > > > Simplified description > ---------------------- > > The *state* of the channel refers to everything Alice needs in order > to resume channel operations. With every new commitment, Alice sends > her current state, with her signature of that state: > > - if Alice sends commitment_signed, the state and signature are > included in that message. > > - if Alice receives commitment_signed, the state and signature will > be included in the next revoke_and_ack sent by Alice. > > With every new commitment, Bob sends a signed tuple (ctn, timestamp), > where ctn is the current commitment number (for the moment, forget > about the distinction between local and remote ctns), and timestamp is > the current time for Bob. > > - if Bob sends commitment_signed, the signed tuple is included in > that message. > > - if Bob receives commitment_signed, the signed tuple will be > included in the next revoke_and_ack sent by Bob. > > The private key used by Bob to sign the tuples is constant over the > lifetime of the channel, and it must not be reused in other > channels. The corresponding public key will be used in the fraud proof > spending path of the redeem script. > > Alice verifies Bob's signature. She also checks that the received > timestamps are reasonable (see below) and strictly monotonic. > > With every channel_reestablish message, Bob will send two extra fields: > - (ctn, timestamp, bob_signature) > - (alice_state, alice_signature). > > Alice verifies that the state she received was signed by her, and that > the (ctn, timestamp) tuple was signed by Bob. She also checks that the > timestamp is reasonable. > > Fraud Proofs > ------------ > > Let us assume that Bob tries to send a revoked state to Alice in > channel_reestablish. The channel_reestablish received by Alice > contains a signed tuple (ctn1, t1), with t1 current timestamp. > > However, another signed tuple (ctn2, t2) has been received in the > past, with ctn1 < ctn2 and t1 > t2. > > If Alice has not lost her state, she will now hold two signed tuples > (ctn1, t1) and (ctn2, t2), that satisfy ctn1 < ctn2 and t1 > t2. > > This constitutes a fraud proof. With OP_CAT and OP_CHECKSIGFROMSTACK, > we can build a script that verifies the fraud proof, and allows Alice > to unilaterally spend the channel funding output. > > Here is an example of such a script: > > witness: > [ > alice_signature(transaction) > bob_signature((ctn1,timestamp1)) > ctn1 > timestamp1 > bob_signature((ctn2,timestamp2)) > ctn2 > timestamp2 > ] > > witness_script: > OP_PICK 1 > OP_PICK 4 > OP_LESSTHAN # verify ctn1 < ctn2 > OP_VERIFY > OP_PICK 0 > OP_PICK 3 > OP_GREATERTHANOREQUAL # verify timestamp1 >= timestamp2 > OP_VERIFY > # check signatures > OP_CAT > OP_PUSHDATA bob_pubkey # we may use Bob's funding_pubkey > OP_CHECKSIGFROMSTACK > OP_VERIFY > OP_CAT > OP_PUSHDATA bob_pubkey > OP_CHECKSIGFROMSTACK > OP_VERIFY > OP_PUSHDATA alice_pubkey # we may use Alice's funding_pubkey > OP_CHECKSIGVERIFY > > > In order to keep things simple, a few details have been omitted in the > description: > > - Bob actually needs to send both the local and the remote ctns in > his signed tuples. A pair of tuples is a fraud proof if the order > is violated for either local or remote ctns. Thus, the actual > script will be more complex than what has been drafted above. > > - Integers pushed on the Bitcoin stack are maximum 4 bytes (31 bits + > 1 bit for the sign). Since commitment numbers are 48 bits long, > they will need to be split into two integers. Timestamps might > require a similar decomposition. This adds further complexity to > the redeem script. > > - Note that Bob must strictly increase his timestamp on each > ctn. This puts a lower bound on the precision used for timestamps. > > > Reasonable Timestamps > --------------------- > > Since Alice and Bob do not have the same clock, Bob may legitimately > send a timestamp that is in Alice's past or future. Every time Alice > receives a timestamp from Bob, she compares it to her current time. > > - If Alice receives a timestamp that is in her future, instead of > closing the channel, she may wait it out before she accepts to > resume operations. > > - If Alice receives a timestamp that is too far in her past, she > should disconnect. Indeed, Bob may be sending an old state and > replaying old timestamps, which is not punishable. In that case, > Alice should not automatically force close the channel, because she > can only do that if she has not lost her state; if force-closing > was automatic, not force-closing would reveal to Bob that she > has lost her state. > > A delay needs to be tolerated by Alice, because Bob does not have the > same clock; that delay should be chosen so that it is always smaller > than the interval between two sessions. > > > Saving Bandwidth > ---------------- > > Alice's channel state does not need to be sent with every commitment, > if it is made of information that is known by both parties. In that > case, it is sufficient for Alice to send her signature of the current > state. Both Alice and Bob must be able to serialize the state, so that > Alice can verify her own signature against a serialization of the > state created by Bob. The state only needs to be sent by Bob once, in > channel_reestablish. > > For this to work, the channel state cannot include information that is > private to Alice. If the private keys used by Alice in the channel are > derived deterministically from her wallet seed, they do not need to be > part of the state. Alternatively, private keys may be included in an > encrypted blob that is included in the state. Since that encrypted > blob is constant, it only needs to be sent once by Alice, during the > channel opening negotiation. Bob will save it and add it to the state > sent in channel_reestablish. > > In addition, the state must not include any payment_hash preimage > known by Alice; thus, Alice will have to fail incoming payments for > those preimages, if she has lost her state. > > The channel state should include the compact storage of per-commitment > secrets sent by Bob. > > > Concluding remarks > ------------------ > > - Obviously, this proposal assumes that Alice remembers with whom she > has an open channel. > > - Alice may restore her wallet from seed on a new device, while the > initial wallet is still active. In that case, Alice must stop using > the channels on her old device. Thus, Alice should disconnect if > she has not lost her state and receives a state with a ctn that is > in her future. This ensures that only one device uses the channels. > > - Without waiting for OP_CHECKSIGFROMSTACK to be available in > Bitcoin, it would be possible for Bob to lockup funds on another > blockchain such as Liquid. It is also possible to create fraud > proofs that are not used in a redeem script, but that are tied to > Bob's public identity and reputation. In that case, Bob should sign > with his node pubkey, and fraud proofs will need to include a short > channel id. > _______________________________________________ > Lightning-dev mailing list > Lightning-dev at lists.linuxfoundation.org > https://www.learnbitcoin.com/archive/lists/lightning-dev >
On Wed, Aug 16, 2023 at 09:56:21AM +0200, Bastien TEINTURIER wrote:
Quoted text (6 lines)
> Hi Thomas, > > I don't think those fraud proofs are necessary at all. They're also > dangerous, because they impose a hard penalty on LSPs for something > that should be best effort (and could get desynchronized by connection > issues, especially with flaky mobile connections).
Note that a hard pentalty might be more appropriate for a paid service, where there's a clear expectation that the service works.
Also I'll point out to Thomas, that he's actually come up with a generic "latest state backup" oracle scheme that might be useful for applications outside of Lightning. It might be wortwhile to forward it to bitcoin-dev, pointing that out, so it sees a wider audience. I can't recall anyone else coming up with that precise mechanism before.
Quoted text (4 lines)
> I agree with Peter Todd that since the mobile wallet can check the state > of the returned backup at every connection request, this makes it highly > unlikely that the LSP can cheat: that's the approach we've taken for > Phoenix.
Does Phoenix tell the user this has happened? Phoenix being a centralized entity, a useful outcome would be people finding out something is wrong and saying so on, eg, social media.
Similarly, the most likely reason why that would be triggered is Phoenix making a mistake, not malice. Having clients loudly shutdown probably protects Phoenix overall from their own mistakes in that scenario, by quickly getting people to stop using Phoenix wallet temporarily until the situation is fixed. Bad for reputation in the short term. But IMO better in the long term.
Hi Peter,
Quoted text (1 line)
> Note that a hard penalty might be more appropriate for a paid service,
where there's a clear expectation that the service works.
Agreed, and in that case we'd have to design payment for this service, which isn't completely trivial and I'm not sure users are ready to pay for it (the free version that mostly works is likely a better fit for the majority of users).
Quoted text (3 lines)
> Does Phoenix tell the user this has happened? Phoenix being a centralized entity, a useful outcome would be people finding out something is wrong and saying so on, eg, social media.
We made sure that the code clearly distinguishes that case: we currently handle it by simply ignoring the stale server backup, but it should be easy to surface this to the user (which would also help us figure out some edge cases where disconnections lead to a desynchronization between the wallet and the wallet provider). The non-trivial part is to design the proof that the user could share publicly, without revealing its private data or leaking its backup encryption keys.
Thanks, Bastien
Le mer. 16 août 2023 à 15:16, Peter Todd <pete at petertodd.org> a écrit :
Quoted text (39 lines)
> On Wed, Aug 16, 2023 at 09:56:21AM +0200, Bastien TEINTURIER wrote: > > Hi Thomas, > > > > I don't think those fraud proofs are necessary at all. They're also > > dangerous, because they impose a hard penalty on LSPs for something > > that should be best effort (and could get desynchronized by connection > > issues, especially with flaky mobile connections). > > Note that a hard pentalty might be more appropriate for a paid service, > where > there's a clear expectation that the service works. > > Also I'll point out to Thomas, that he's actually come up with a generic > "latest state backup" oracle scheme that might be useful for applications > outside of Lightning. It might be wortwhile to forward it to bitcoin-dev, > pointing that out, so it sees a wider audience. I can't recall anyone else > coming up with that precise mechanism before. > > > I agree with Peter Todd that since the mobile wallet can check the state > > of the returned backup at every connection request, this makes it highly > > unlikely that the LSP can cheat: that's the approach we've taken for > > Phoenix. > > Does Phoenix tell the user this has happened? Phoenix being a centralized > entity, a useful outcome would be people finding out something is wrong and > saying so on, eg, social media. > > Similarly, the most likely reason why that would be triggered is Phoenix > making > a mistake, not malice. Having clients loudly shutdown probably protects > Phoenix > overall from their own mistakes in that scenario, by quickly getting > people to > stop using Phoenix wallet temporarily until the situation is fixed. Bad for > reputation in the short term. But IMO better in the long term. > > -- > https://petertodd.org 'peter'[:-1]@petertodd.org >
Hello Peter,
I have to disagree with both your reasoning and the numerical values you are proposing. Let us first look at the equations:
Quoted text (8 lines)
> Suppose that Alice goes a few days without connecting to Bob 10 > times per year, and this particular connection attempt is an example > of that 10/year event. Suppose that Alice has a 1% chance of data > loss per year that **requires her to use Bob's channel state backup**, > and suppose that with 100% certainty, in the event of data loss Alice > would take a few days to attempt recovery. That means that this > particular connection event represents a 1% / 10 = 0.1% probability > event, and P_d = 0.1%
In this paragraph, you are expressing the joint probability that Alice has lost her data AND that she is displaying a certain behaviour visible to Bob (staying disconnected for a few days).
First, let me clarify the "per year" issue. Since you are trying to compute the probability of data loss at a particular connection event, the terms used in your equation must be the probability P(loss) of data loss *at that connection*, and the probability P(behaviour) of having been offline for several days *at that connection*. It may be possible to express P(loss) and P(behaviour) from the probabilities *per year*, but that would requires assumptions about the frequency of connections, and the duration of the process. For example, once data is lost, it remains lost forever. Since units of time do not show up in your equations, I will assume that you simply meant probabilities at connection: P(loss) = 0.01 and P(behaviour) = 0.1
To compute the joint probability that Alice has lost data and that she is displaying that behaviour, you used as a product, as if those were independent events:
P(loss AND behaviour) = P(loss) * P(behaviour)
Unfortunately, those events are not independent. If the behaviour of Alice is caused by the loss, then P(loss AND behaviour) is certainly not equal to P(loss) * P(behaviour), but considerably closer to P(loss).
Anyway, the joint probability P(loss AND behaviour) is not the relevant quantity here. Indeed, when you wrote:
Quoted text (1 line)
> Bob can profit if V_f * P_d > V_h,
you were implying that P_d is the same as the one you computed above, using that multiplication. This is wrong. If we want to compute whether Bob can profit, we need to look at what the probability of data loss given the information available to Bob. In other words, P_d should be the the conditional probability that Alice has lost her state, given the information available to Bob: P(loss|behaviour):
Bob can profit if V_f * P(loss|behaviour) > V_h
This can be expressed using the Bayes theorem:
P(loss|behaviour) = P(behaviour|loss) * P(loss) / P(behaviour)
In practice, the posterior probability that Alice has lost her state will be higher if she behaves as if she has lost it. Your assumption "suppose that with 100% certainty, in the event of data loss Alice would take a few days to attempt recovery" should be translated as P(behaviour|loss) = 1. With the numerical values from above (P(loss) = 0.01, P(behaviour) = 0.1), we arrive at P(loss|behaviour) = 0.1, which is 100 times higher than your estimate.
Second, regarding the numerical values:
I do not wish to argue over the numerical value of the probability of data loss per year. However, I want to point out that the probability of users connecting without having their data becomes considerably higher if restoring your channels from seed becomes a feature. If users are told that they can restore their state from seed, then they are going to use that feature. For example, some Electrum users decide to uninstall and reinstall their wallet app from their device whenever they cross a border. So, the relevant question is, how frequently do users restore their wallet from seed, and not how frequently they have actually lost data.
Finally, note that the "behaviour" encompasses all the information available to Bob, not only the fact that Alice has been offline for a few day. There might be other channels that can be exploited by an attacker to gain information about Alice. If Alice's wallet uses Electrum servers, then whoever operates the server will be able to infer whether Alice has been restoring from seed or not. Not only Electrum, uses Electrum servers, but a whole range of mobile wallets do, including Phoenix.
Hello Bastien
Quoted text (1 line)
> I don't think those fraud proofs are necessary at all.
That's a pity. I would have expected you to be interested, given that Phoenix could benefit from that feature.
Anyway, since my proposal requires new opcodes, I think of it more as a theoretical discussion, rather than a concrete proposal.
Quoted text (5 lines)
> They're also > dangerous, because they impose a hard penalty on LSPs for something > that should be best effort (and could get desynchronized by connection > issues, especially with flaky mobile connections). >
How are the fraud proofs I described more dangerous than revoked states? There is no "toxic data" in here.
The server must not sign (ctn1, t1), (ctn2, t2) with ctn1>ctn2 and t1<t2. That is the only constraint, and it does not depend on flaky connections.
All the server needs to do is remember the value of the highest timestamp signed so far. And, if they need to subtract leap seconds to their clock, wait a little bit before resuming the channel. That does not sound too hard...
Quoted text (7 lines)
> I'm surprised that you don't mention the BOLT PR we created for those > backups in [1], I believe that is sufficient. It should probably be > moved to a blip instead of a BOLT once we've implemented this version > (the approach we use in Phoenix currently is slightly different), but > apart from that it contains all the mechanisms necessary to achieve > this today. >
Sorry, I had seen that PR a few years ago, but in the meantime I had forgotten about it. I just had a new look at it now.
Perhaps that PR could benefit from my idea of sending backup data as new fields of existing messages? I see that update_channel_backup needs to be sent *before* the corresponding change of state. I think using the existing messages would be more elegant, because it makes things atomic.
Note that in practice, the client would only need to send his signature of the backup, and not the backup itself, which should be reconstructed by the server on each new state (see section 'saving bandwidth').
cheers
Thomas
Hi Thomas,
Quoted text (2 lines)
> That's a pity. I would have expected you to be interested, given that > Phoenix could benefit from that feature.
I don't think this is an attack wallet providers can reasonably attempt. The mobile wallet can check at every connection that the provider isn't trying to cheat, and the provider doesn't have any way of knowing when the mobile wallet has lost data: it would thus be a very risky move to try to cheat, because it is very unlikely to succeed and will result in reputation loss for the provider.
So for this specific backup use case, I think it would simply be adding complexity to solve an issue that doesn't matter in practice.
Quoted text (2 lines)
> How are the fraud proofs I described more dangerous than revoked states? > There is no "toxic data" in here.
I didn't say they were more dangerous than revoked states? What I meant is that signing those "commitments" by the wallet provider is dangerous for their reputation if that service is only best-effort, because there are race conditions in the lightning protocol for which the wallet provider may not have the mobile wallet's latest state (it is not entirely trivial to keep track of that state).
Quoted text (5 lines)
> Perhaps that PR could benefit from my idea of sending backup data as new > fields of existing messages? I see that update_channel_backup needs to be > sent *before* the corresponding change of state. I think using the existing > messages would be more elegant, because it makes things atomic.
That was the main thing discussed in that PR. See [1] for the end of that discussion (the earlier comments contain a lot of details on that design choice). Sending data in existing messages has a length issue, because `commitment_signed` for example may already fill up the message which doesn't leave any room for an additional backup.
Cheers, Bastien
[1] https://github.com/lightning/bolts/pull/881#issuecomment-1132698926
Le jeu. 17 août 2023 à 12:52, Thomas Voegtlin <thomasv at electrum.org> a écrit :
Quoted text (53 lines)
> > Hello Bastien > > > I don't think those fraud proofs are necessary at all. > > That's a pity. I would have expected you to be interested, given that > Phoenix could benefit from that feature. > > Anyway, since my proposal requires new opcodes, I think of it more as > a theoretical discussion, rather than a concrete proposal. > > > They're also > > dangerous, because they impose a hard penalty on LSPs for something > > that should be best effort (and could get desynchronized by connection > > issues, especially with flaky mobile connections). > > > > How are the fraud proofs I described more dangerous than revoked states? > There is no "toxic data" in here. > > The server must not sign (ctn1, t1), (ctn2, t2) with ctn1>ctn2 and t1<t2. > That is the only constraint, and it does not depend on flaky connections. > > All the server needs to do is remember the value of the highest timestamp > signed so far. And, if they need to subtract leap seconds to their clock, > wait a little bit before resuming the channel. That does not sound too hard... > > > > I'm surprised that you don't mention the BOLT PR we created for those > > backups in [1], I believe that is sufficient. It should probably be > > moved to a blip instead of a BOLT once we've implemented this version > > (the approach we use in Phoenix currently is slightly different), but > > apart from that it contains all the mechanisms necessary to achieve > > this today. > > > > Sorry, I had seen that PR a few years ago, but in the meantime I had > forgotten about it. I just had a new look at it now. > > Perhaps that PR could benefit from my idea of sending backup data as new > fields of existing messages? I see that update_channel_backup needs to be > sent *before* the corresponding change of state. I think using the existing > messages would be more elegant, because it makes things atomic. > > Note that in practice, the client would only need to send his signature > of the backup, and not the backup itself, which should be reconstructed > by the server on each new state (see section 'saving bandwidth'). > > cheers > > Thomas
On Thu, Aug 17, 2023 at 11:36:58AM +0200, Thomas Voegtlin wrote:
Quoted text (40 lines)
> Hello Peter, > > I have to disagree with both your reasoning and the numerical values > you are proposing. Let us first look at the equations: > > > Suppose that Alice goes a few days without connecting to Bob 10 > > times per year, and this particular connection attempt is an example > > of that 10/year event. Suppose that Alice has a 1% chance of data > > loss per year that **requires her to use Bob's channel state backup**, > > and suppose that with 100% certainty, in the event of data loss Alice > > would take a few days to attempt recovery. That means that this > > particular connection event represents a 1% / 10 = 0.1% probability > > event, and P_d = 0.1% > > In this paragraph, you are expressing the joint probability that Alice > has lost her data AND that she is displaying a certain behaviour > visible to Bob (staying disconnected for a few days). > > First, let me clarify the "per year" issue. Since you are trying to > compute the probability of data loss at a particular connection event, > the terms used in your equation must be the probability P(loss) of > data loss *at that connection*, and the probability P(behaviour) of > having been offline for several days *at that connection*. It may be > possible to express P(loss) and P(behaviour) from the probabilities > *per year*, but that would requires assumptions about the frequency of > connections, and the duration of the process. For example, once data > is lost, it remains lost forever. Since units of time do not show up > in your equations, I will assume that you simply meant probabilities > at connection: P(loss) = 0.01 and P(behaviour) = 0.1 > > To compute the joint probability that Alice has lost data and that she > is displaying that behaviour, you used as a product, as if those were > independent events: > > P(loss AND behaviour) = P(loss) * P(behaviour) > > Unfortunately, those events are not independent. If the behaviour of > Alice is caused by the loss, then P(loss AND behaviour) is certainly > not equal to P(loss) * P(behaviour), but considerably closer to > P(loss).
While I agree that my math was a bit sloppy, I think you are thinking about this problem in the wrong way.
The "normal" connections are the k-anonymity set: they are the non-loss events that could potentially be loss events. In addition to that set of events, there are also loss events that are indistinguishable from the non-loss events.
If each client averages 10 delayed connections per year, a node with N clients will see:
10
r_d = N * ----
year
...total delayed connections per year. In addition to those delayed connections, that same node with N clients will see:
1%
r_l = N * ----
year
...total connections with data loss per year. That means the probability of a given connection attempt representing data loss is:
r_l
P_d = ---------
r_l + r_d
Notice how if you work that out, the units completely cancel out, leaving you the dimensionless ratio 0.0999% ~= 0.1%, approximately the same number as my earlier less rigorous approach.
Quoted text (11 lines)
> Anyway, the joint probability P(loss AND behaviour) is not the > relevant quantity here. Indeed, when you wrote: > > > Bob can profit if V_f * P_d > V_h, > > you were implying that P_d is the same as the one you computed above, > using that multiplication. This is wrong. If we want to compute > whether Bob can profit, we need to look at what the probability of > data loss given the information available to Bob. In other words, P_d > should be the the conditional probability that Alice has lost her > state, given the information available to Bob: P(loss|behaviour):
I already took that into account by defining the k-anonymity set as the set of all delayed non-loss connections. Conditional probability isn't relevant here.
Quoted text (12 lines)
> Second, regarding the numerical values: > > I do not wish to argue over the numerical value of the probability of > data loss per year. However, I want to point out that the probability > of users connecting without having their data becomes considerably > higher if restoring your channels from seed becomes a feature. If > users are told that they can restore their state from seed, then they > are going to use that feature. For example, some Electrum users decide > to uninstall and reinstall their wallet app from their device whenever > they cross a border. So, the relevant question is, how frequently do > users restore their wallet from seed, and not how frequently they have > actually lost data.
That's a good point. But I'm willing to say that's an example of the user doing something stupid and reckless. And it's an example that can be mitigated by making the process of an emergency restore from seed inconvenient, eg by adding artificial delays.
Quoted text (4 lines)
> Finally, note that the "behaviour" encompasses all the information > available to Bob, not only the fact that Alice has been offline for a > few day. There might be other channels that can be exploited by an > attacker to gain information about Alice.
In general, this is a class of engineering problem that we already have in many other circumstances. I don't believe it is a deal breaker to the idea.
Quoted text (5 lines)
> If Alice's wallet uses > Electrum servers, then whoever operates the server will be able to infer > whether Alice has been restoring from seed or not. Not only Electrum, > uses Electrum servers, but a whole range of mobile wallets do, > including Phoenix.
That's also a good point. But I'm willing to consider that another k-anonymity set situation: how many randomly chosen blockchain data sources does the attacker control? Provided the probability of that happening is low, it's not a significant concern.
Hi Bastien,
Quoted text (6 lines)
> I don't think this is an attack wallet providers can reasonably attempt. > The mobile wallet can check at every connection that the provider isn't > trying to cheat, and the provider doesn't have any way of knowing when > the mobile wallet has lost data: it would thus be a very risky move to > try to cheat, because it is very unlikely to succeed and will result in > reputation loss for the provider.
It would be nice to have a peer backup solution that can be provided by ~any node, and reasonably used without trust by ~any node [0]. To be more precise (and practical), imagine providing the backup "service" by default if you run a public forwarding node. E.g. if Alice runs eclair on their server and have some public channels, the default config of eclair could result in Alice signalling the "backup-provider" feature bit. Then, if Bob uses a phone-wallet, and opens to Alice (chosen by Bob arbitrarily), Bob could store their backups with her.
Note that the "reputation loss" argument does not hold up that well if you let Bob connect to arbitrary nodes. Something stronger, such as actual confiscation of funds via Thomas' idea seems more applicable. Afterall, what does a random node have to lose if they tried to replay an old backup? You said in another email Phoenix atm simply ignores the stale backup. I wonder, does the client happily keep using the channel after a reconnect? If so, what is there to lose by attempting to replay old states? Random nodes don't really have an easy concept of reputation.
Obviously the ACINQ node is not random - being hardcoded in your case it is anything but. Of course, in the case of an LSP/wallet combo such as Phoenix, the reputation argument is sufficient, I agree.
-----
[0]: I think the whole backup provicer idea could be made symmetric. I had previously thought that it is inherently asymmetric but after some more thought I think I was wrong:
Symmetric resumable channels ----------------------------
Alice and Bob could have a channel where they both provide state backups to each other. Regarding who goes first in channel_reestablish, we need an extra preliminary round where both Alice and Bob commit to what they will send in channel_reestablish:
Round 1: 1. Alice sends hashA = hash(bobs_backup, nonceA) 2. Bob sends hashB = hash(alices_backup, nonceB)
Alice persists hashB to disk upon receiving it, and enforces that even if there is a disconnection, Bob cannot arbitrarily send a different commitment next time. (if the channel gets reestablished fully and Alice sends a new backup to Bob, the stored hashB can be cleared)
Round 2: 3. Alice sends channel_reestablish containing bobs_backup, and nonceA 4. Bob sends channel_reestablish containing alices_backup, and nonceB
Alice checks that the commitment received from Bob in round1 matches what was received in round2.
Regarding the opening post OP_CHECKSIGFROMSTACK on-chain enforcement, that can be made symmetric as well! The channel funding output script needs one taproot branch each for both Alice and Bob lying. The protocol needs to be tweaked a bit so as to allow a party to legitimately admit having lost state and commit to the hash of that in round1, and then reveal they lost state in round2 (e.g. send null data). In which case the other party would not be able to use the fraud proof taproot branch.
Though note that user-error and manual copying/restoring of DBs could lead to catastrophic failure with the on-chain enforcement: if you restore an old db and launch your client, the client won't know it is running an old state and happily participate in the two round dance, giving a fraud proof to the counterparty in the process.
Regards, ghost43
Hi ghost,
Quoted text (2 lines)
> Note that the "reputation loss" argument does not hold up that well if > you let Bob connect to arbitrary nodes.
That's true, in that case such nodes don't care as much about their reputation and could have an incentive to cheat. But even in that case, the user will detect it easily (because again, the backup provider doesn't know when the wallet has lost state) and in that case they shouldn't ignore it but should rather close their channel.
By itself, this is an incentive to not cheat, because even though the wallet user lost money in on-chain fees, the backup provider loses potential routing fees and has a very small chance of successfully stealing funds from the user.
But I agree that in that case, a more complex protocol like what you and Thomas suggest could make sense. But I'd still be wary about the additional complexity it would add compared to the benefits it brings.
Thanks, Bastien
Le jeu. 17 août 2023 à 20:43, SomberNight <somber.night at protonmail.com> a écrit :
Quoted text (79 lines)
> > Hi Bastien, > > > I don't think this is an attack wallet providers can reasonably attempt. > > The mobile wallet can check at every connection that the provider isn't > > trying to cheat, and the provider doesn't have any way of knowing when > > the mobile wallet has lost data: it would thus be a very risky move to > > try to cheat, because it is very unlikely to succeed and will result in > > reputation loss for the provider. > > It would be nice to have a peer backup solution that can be provided by > ~any node, and reasonably used without trust by ~any node [0]. To be more > precise (and practical), imagine providing the backup "service" by > default if you run a public forwarding node. E.g. if Alice runs eclair > on their server and have some public channels, the default config of > eclair could result in Alice signalling the "backup-provider" feature > bit. Then, if Bob uses a phone-wallet, and opens to Alice (chosen by Bob > arbitrarily), Bob could store their backups with her. > > Note that the "reputation loss" argument does not hold up that well if > you let Bob connect to arbitrary nodes. Something stronger, such as > actual confiscation of funds via Thomas' idea seems more applicable. > Afterall, what does a random node have to lose if they tried to replay > an old backup? You said in another email Phoenix atm simply ignores the > stale backup. I wonder, does the client happily keep using the channel > after a reconnect? If so, what is there to lose by attempting to replay > old states? Random nodes don't really have an easy concept of > reputation. > > Obviously the ACINQ node is not random - being hardcoded in your case > it is anything but. Of course, in the case of an LSP/wallet combo > such as Phoenix, the reputation argument is sufficient, I agree. > > ----- > > [0]: I think the whole backup provicer idea could be made symmetric. > I had previously thought that it is inherently asymmetric but after > some more thought I think I was wrong: > > Symmetric resumable channels > ---------------------------- > > Alice and Bob could have a channel where they both provide state backups > to each other. Regarding who goes first in channel_reestablish, we need > an extra preliminary round where both Alice and Bob commit to what they > will send in channel_reestablish: > > Round 1: > 1. Alice sends hashA = hash(bobs_backup, nonceA) > 2. Bob sends hashB = hash(alices_backup, nonceB) > > Alice persists hashB to disk upon receiving it, and enforces that even > if there is a disconnection, Bob cannot arbitrarily send a different > commitment next time. (if the channel gets reestablished fully and > Alice sends a new backup to Bob, the stored hashB can be cleared) > > Round 2: > 3. Alice sends channel_reestablish containing bobs_backup, and nonceA > 4. Bob sends channel_reestablish containing alices_backup, and nonceB > > Alice checks that the commitment received from Bob in round1 matches > what was received in round2. > > Regarding the opening post OP_CHECKSIGFROMSTACK on-chain enforcement, > that can be made symmetric as well! The channel funding output script > needs one taproot branch each for both Alice and Bob lying. The protocol > needs to be tweaked a bit so as to allow a party to legitimately admit > having lost state and commit to the hash of that in round1, and then > reveal they lost state in round2 (e.g. send null data). In which case > the other party would not be able to use the fraud proof taproot branch. > > Though note that user-error and manual copying/restoring of DBs could > lead to catastrophic failure with the on-chain enforcement: > if you restore an old db and launch your client, the client won't know > it is running an old state and happily participate in the two round > dance, giving a fraud proof to the counterparty in the process. > > Regards, > ghost43
Quoted text (11 lines)
> If Alice's wallet uses > Electrum servers, then whoever operates the server will be able to infer > whether Alice has been restoring from seed or not. Not only Electrum, > uses Electrum servers, but a whole range of mobile wallets do, > including Phoenix. That's also a good point. But I'm willing to consider that another > k-anonymity > set situation: how many randomly chosen blockchain data sources does the > attacker control? Provided the probability of that happening is low, it's > not a > significant concern.
I think it only makes sense to talk about probability here if peers are fully anonymous, which to my understanding is not currently the case. You can consider an attack begins much before there is even an open channel with the victim. Once an attacker identifies a target, only then would they try to open a channel open with the victim, fully intending to exploit them. The victim is already vulnerable in some way but doesn't yet know it. From this perspective, the event of Alice attempting to restore from seed at a particular moment is likely one that the attacker planned all along, not some random occurrence. It's the last step in the attack, not the first.
On Fri, Aug 18, 2023 at 3:06 AM Peter Todd <pete at petertodd.org> wrote:
Quoted text (147 lines)
> On Thu, Aug 17, 2023 at 11:36:58AM +0200, Thomas Voegtlin wrote: > > Hello Peter, > > > > I have to disagree with both your reasoning and the numerical values > > you are proposing. Let us first look at the equations: > > > > > Suppose that Alice goes a few days without connecting to Bob 10 > > > times per year, and this particular connection attempt is an example > > > of that 10/year event. Suppose that Alice has a 1% chance of data > > > loss per year that **requires her to use Bob's channel state backup**, > > > and suppose that with 100% certainty, in the event of data loss Alice > > > would take a few days to attempt recovery. That means that this > > > particular connection event represents a 1% / 10 = 0.1% probability > > > event, and P_d = 0.1% > > > > In this paragraph, you are expressing the joint probability that Alice > > has lost her data AND that she is displaying a certain behaviour > > visible to Bob (staying disconnected for a few days). > > > > First, let me clarify the "per year" issue. Since you are trying to > > compute the probability of data loss at a particular connection event, > > the terms used in your equation must be the probability P(loss) of > > data loss *at that connection*, and the probability P(behaviour) of > > having been offline for several days *at that connection*. It may be > > possible to express P(loss) and P(behaviour) from the probabilities > > *per year*, but that would requires assumptions about the frequency of > > connections, and the duration of the process. For example, once data > > is lost, it remains lost forever. Since units of time do not show up > > in your equations, I will assume that you simply meant probabilities > > at connection: P(loss) = 0.01 and P(behaviour) = 0.1 > > > > To compute the joint probability that Alice has lost data and that she > > is displaying that behaviour, you used as a product, as if those were > > independent events: > > > > P(loss AND behaviour) = P(loss) * P(behaviour) > > > > Unfortunately, those events are not independent. If the behaviour of > > Alice is caused by the loss, then P(loss AND behaviour) is certainly > > not equal to P(loss) * P(behaviour), but considerably closer to > > P(loss). > > While I agree that my math was a bit sloppy, I think you are thinking about > this problem in the wrong way. > > The "normal" connections are the k-anonymity set: they are the non-loss > events > that could potentially be loss events. In addition to that set of events, > there > are also loss events that are indistinguishable from the non-loss events. > > If each client averages 10 delayed connections per year, a node with N > clients > will see: > > 10 > r_d = N * ---- > year > > ...total delayed connections per year. In addition to those delayed > connections, > that same node with N clients will see: > > 1% > r_l = N * ---- > year > > ...total connections with data loss per year. That means the probability > of a > given connection attempt representing data loss is: > > r_l > P_d = --------- > r_l + r_d > > Notice how if you work that out, the units completely cancel out, leaving > you > the dimensionless ratio 0.0999% ~= 0.1%, approximately the same number as > my > earlier less rigorous approach. > > > Anyway, the joint probability P(loss AND behaviour) is not the > > relevant quantity here. Indeed, when you wrote: > > > > > Bob can profit if V_f * P_d > V_h, > > > > you were implying that P_d is the same as the one you computed above, > > using that multiplication. This is wrong. If we want to compute > > whether Bob can profit, we need to look at what the probability of > > data loss given the information available to Bob. In other words, P_d > > should be the the conditional probability that Alice has lost her > > state, given the information available to Bob: P(loss|behaviour): > > I already took that into account by defining the k-anonymity set as the > set of > all delayed non-loss connections. Conditional probability isn't relevant > here. > > > Second, regarding the numerical values: > > > > I do not wish to argue over the numerical value of the probability of > > data loss per year. However, I want to point out that the probability > > of users connecting without having their data becomes considerably > > higher if restoring your channels from seed becomes a feature. If > > users are told that they can restore their state from seed, then they > > are going to use that feature. For example, some Electrum users decide > > to uninstall and reinstall their wallet app from their device whenever > > they cross a border. So, the relevant question is, how frequently do > > users restore their wallet from seed, and not how frequently they have > > actually lost data. > > That's a good point. But I'm willing to say that's an example of the user > doing > something stupid and reckless. And it's an example that can be mitigated by > making the process of an emergency restore from seed inconvenient, eg by > adding > artificial delays. > > > Finally, note that the "behaviour" encompasses all the information > > available to Bob, not only the fact that Alice has been offline for a > > few day. There might be other channels that can be exploited by an > > attacker to gain information about Alice. > > In general, this is a class of engineering problem that we already have in > many > other circumstances. I don't believe it is a deal breaker to the idea. > > > If Alice's wallet uses > > Electrum servers, then whoever operates the server will be able to infer > > whether Alice has been restoring from seed or not. Not only Electrum, > > uses Electrum servers, but a whole range of mobile wallets do, > > including Phoenix. > > That's also a good point. But I'm willing to consider that another > k-anonymity > set situation: how many randomly chosen blockchain data sources does the > attacker control? Provided the probability of that happening is low, it's > not a > significant concern. > > -- > https://petertodd.org 'peter'[:-1]@petertodd.org > _______________________________________________ > Lightning-dev mailing list > Lightning-dev at lists.linuxfoundation.org > https://www.learnbitcoin.com/archive/lists/lightning-dev >
On 17.08.23 16:20, Bastien TEINTURIER wrote:
Quoted text (9 lines)
> Hi Thomas, > > > I don't think this is an attack wallet providers can reasonably attempt. > The mobile wallet can check at every connection that the provider isn't > trying to cheat, and the provider doesn't have any way of knowing when > the mobile wallet has lost data: it would thus be a very risky move to > try to cheat, because it is very unlikely to succeed and will result in > reputation loss for the provider.
I believe your idea of a "wallet provider" conflates two roles: - the entity that distributes the wallet application. - the entity that has channels with the user.
Phoenix does not allow users to open channels with arbitrary nodes, thus these entities are the same for you, and that might be why you think that the loss of reputation is a sufficient deterrent.
However, if Phoenix was allowing users to open channels and have backup stored with arbitrary nodes, would you still be comfortable with the idea that this is an attack these nodes cannot reasonably attempt?
I would not. I think the reputation loss would harm the software distributor more than the lightning node operator.
Please do not misunderstand me: I have nothing against the fact that Phoenix users cannot connect to arbitrary nodes. In fact, without OP_CHECKSIGFROMSTACK or a similar solution available, we will probably have to adopt a similar development model for Electrum, as far as peer backup storage is concerned.
However, when we discuss protocol improvements, it would be good to consider a more decentralized model, where users are free to connect to whatever node they want, without the permission of their software provider.
cheers,
Thomas
Regarding your proposal to make peer backups symmetric, with a first message that commits to the current state, and then a second message that reveals the state: I think it could work, but I see the following issue:
If Alice reveals that she has lost her state, Bob might be tempted to disconnect, because he expects that Alice will forget his already sent state commitment. For example this would happen if the user is frustrated and uninstalls/re-installs the app, or if she decides to try from another device because the first device "failed" to restore her wallet). Thus, Bob could try to send a different commitment the next time.
A possible way to prevent that: Alice could, if Bob does not reveal his state, write Bob's state commitment on-chain, in an OP_RETURN. That way, Bob cannot expect her to have forgotten his state commitment.
Thomas
On 17.08.23 20:43, SomberNight wrote:
Quoted text (41 lines)
> > Symmetric resumable channels > ---------------------------- > > Alice and Bob could have a channel where they both provide state backups > to each other. Regarding who goes first in channel_reestablish, we need > an extra preliminary round where both Alice and Bob commit to what they > will send in channel_reestablish: > > Round 1: > 1. Alice sends hashA = hash(bobs_backup, nonceA) > 2. Bob sends hashB = hash(alices_backup, nonceB) > > Alice persists hashB to disk upon receiving it, and enforces that even > if there is a disconnection, Bob cannot arbitrarily send a different > commitment next time. (if the channel gets reestablished fully and > Alice sends a new backup to Bob, the stored hashB can be cleared) > > Round 2: > 3. Alice sends channel_reestablish containing bobs_backup, and nonceA > 4. Bob sends channel_reestablish containing alices_backup, and nonceB > > Alice checks that the commitment received from Bob in round1 matches > what was received in round2. > > Regarding the opening post OP_CHECKSIGFROMSTACK on-chain enforcement, > that can be made symmetric as well! The channel funding output script > needs one taproot branch each for both Alice and Bob lying. The protocol > needs to be tweaked a bit so as to allow a party to legitimately admit > having lost state and commit to the hash of that in round1, and then > reveal they lost state in round2 (e.g. send null data). In which case > the other party would not be able to use the fraud proof taproot branch. > > Though note that user-error and manual copying/restoring of DBs could > lead to catastrophic failure with the on-chain enforcement: > if you restore an old db and launch your client, the client won't know > it is running an old state and happily participate in the two round > dance, giving a fraud proof to the counterparty in the process. > > Regards, > ghost43