Research/Bitcoin Dev Archive / lightning-dev list
Escrow Over Lightning?
22 messages, Jun 20, 2019, to Feb 27, 2021. Started by ZmnSCPxj.
ZmnSCPxj (10), Nadav Kohen (4), Andrés G. Aragoneses (4), Pedro Moreno-Sanchez (3), Christian Decker
Good morning list,
One thing I am attempting to think through is some implementation of escrow over Lightning.
A non-custodial onchain escrow protocol simply uses a 2-of-3 multisig amongst the two participants and the escrow. Such a contract (like any onchain-enforceable contract) can be transported over a *single* Lightning channel, but cannot be safely hopped across channels: the escrow may take "one" side in one channel while taking the "other" side on the other channel, thus putting every hop node at risk.
Escrow services are useful when Bitcoin needs to interact with other systems, such as the mythical "real world", when tr*st in a brandless entity is difficult to procure, while some escrow service can aggregate and reuse tr*st in its brand to enable trades between brandless entities. Thus if at all possible, we should consider how best to support escrow services over Lightning.
I formulate the contract below:
* A brandless buyer B wants to pay a brandless seller S for a service or product. * Both B and S have non-trust in one another, but can agree to tr*st a common branded escrow E. * B shall pay S if both B and S can agree that the service was rendered satisfactorily or product was delivered. * In case of dispute, E decides whether S is paid or B is refunded. * B and S want to provide as little information to E as possible if both B and S can come to an agreement (i.e. only reveal information if a dispute occurs).
Tr*st is still needed in E. In particular, B and S both trust that E will not be susceptible to bribery from their counterparty.
The above can trivially be implemented onchain using a 2-of-3 multisig.
1, The branded escrow E provides a public key as part of its brand.
2. B and S generate a short contract description of the service or product to be rendered, in a language that E understands.
3. B and S tweak the escrow public key (if `E` is the escrow pubkey and `c` is the description of the service/product, use `E + h(E | c) * G`).
4. B and S generate a 2-of-3 address using their own keys, plus the tweaked escrow public key.
5. If B and S can come to an agreement, then they sign using their own keys, and the third key (the tweaked escrow key) remains tweaked and E cannot determine that it could have been used as the escrow, or the details of the transaction, even if it monitors the blockchain (since its key is not used directly, instead a tweaked version is used, and the tweak is not revealed E if B and S are in agreement).
But if B and S come to a dispute, either can provide E with the agreed-upon description `c` that is committed to onchain, and lets E judge where the payment should go.
Under bip-taproot this can be optimized somewhat in favor of the "no dispute" case by setting the taproot internal key to `MuSig(B, S)`, and having separate MAST branches for `MuSig(E + h(E | c) * G, B)` and `MuSig(E + h(E | c) * G, S)`.
This use-case is important: consider the case where the seller is selling pieces of decorated paper mass-printed by some centralized financial institution. For face-to-face transactions, it is enough for all of the participants to appear and for the Lightning payment to be attempted and so forth. But for non-face-to-face transactions (such as when one participant is secretly an AI that is attempting to take over the world, and is currently unable to puppet some meatspace representative), such escrow would be best done online with no requirement of physical presence.
---
Naively, it seems that switching to payment points / scalars from payment hashes / preimages (a necessity for payment decorrelation) may work. It may be possible to use some kind of verifiable secret sharing.
However, I would like to make the following points possible:
* The escrow does not learn about an escrowed trade unless a dispute between buyer and seller occurs. * The escrow is capable of returning the buyer funds immediately as soon as it can resolve the dispute without timing out the payment. * Intermediate hop nodes that are not the buyer, seller, or escrow, remain unaware of the escrowed trade (ideally, if they support the "normal" payment points / scalars system, they should not need any special support for escrowed trade).
Let me sketch below something, which might not work since I have not actually learned verifiable secret sharing at all. In particular, if verifiable secret sharing requires that the participants including the escrow to set up the payment point interactively, this fails the first desired item, that the escrow only learns of the escrowed trade in a dispute case. (i.e. a real mathist should actually check this.)
---
I will ignore here temporarily the issues of payment decorrelation, and pretend that the same point is used in the entire path.
Before all this, E publishes its escrow key `E`.
First, B and S generate temporary payment points and scalars, `B = b * G` and `S = s * G`. Then they agree on the contract `c` describing their agreement, in a language that E understands, e.g. "seller S will deliver 100 pieces of USA federal reserve commemorative decoration paper in exchange for 1 satoshi from buyer".
Then B generates an ECDH shared secrets between escrow and buyer:
tweak(c, P) = P + h(P | c) * G
ecdh(a, B) = h(a * B)
b' = ecdh(b, tweak(c, E))
B' = b' * G
S' = S + B'
The payment point used in the payment route is `S'`.
B provides `B` and `B'` to S (this can be done using TLV in the onion packet). Of course, we also need to provide a proof that `B' == ecdh(b, tweak(c, E)) * G` where `B == b * G`. I have no idea how easy (or impossible) it is to make such a proof (without E having to attest to it).
If S believes it has fulfilled the contract and delivered the product or service, it contacts B. If B is satisfied with the product or service, it provides `b'`, allowing S to compute `s + b'` needed to claim the payment point `S + B'`. In the non-dispute case, E never learns that it could have been the escrow. B receives the scalar `s + b'` from the payment, but it knows `b'` and can compute the scalar `s` which now serves as proof-of-payment.
If B is unsatisfied, we have a dispute condition and S contacts the escrow E. S provides `B` and the contract `c` to the escrow. ECDH allows E to determine `b' = ecdh(e + h((e * G) | c), B)`. If E decides in favor of the seller, then it reveals `b'` to S, which can then compute `s + b'` and claim the payment point `S + B'`.
However, note that if E decides in favor of the buyer, it cannot do anything other than let the payment timeout lapse, which automatically forces the seller S to fail the HTLC. I cannot derive a way for E to force S to fail the HTLC, without revealing to intermediate hop nodes that this is an escrow payment.
Even if E is the only intermediate hop node between B and S (an undesirable situation since it allows E to censor and surveil the payments between B and S), it is not safe for E to fail its incoming PTLC until S has failed its incoming PTLC, as otherwise B and S could be coordinating to steal from escrow E.
There are likely to be better schemes. Again, the ideal scheme would provide:
* Escrow only learns of dispute cases, never learns non-dispute case. * Buyer can recover funds immediately as soon as escrow decides in favor of buyer. <- this seems difficult/impossible under LN. * Intermediate hop nodes are unaware of anything special with the payment.
Regards, ZmnSCPxj
Hi ZmnSCPxj,
I find this idea super exciting!
I think that the main wrinkle in what you've presented is how the Seller can verify that `B'` is indeed `ecdh(b, tweak(c, E))*G` since absent this authentication, the Escrow will be unable to provide the Seller with the necessary information to claim funds during a dispute.
Perhaps there is some fancy ZKP that allows the Seller and Buyer to establish this alone but I don't know what that would look like. If it exists than that scheme would be better than the following but here are my thoughts:
If we do need the Escrow to attest to the validity of `B'`, we want to make sure that the Escrow gains as little knowledge as possible. If we add a salt to the `tweak` function's hash (i.e `tweak(c, P, salt) = P + h(P | c | salt)*G`) and this salt is agreed upon by the Buyer and Seller (say for example, `salt = ecdh(s, B)`), then the Seller can tell the Escrow to compute `B'` given only `h(E | c | salt)` and `B` using `B' = ecdh(e + h(E | c | salt), B) * G`. In this way, the Escrow can validate for the Seller that `B'` is what it should be, while learning only a random hash (who's `salt` ensures no information about `c` is revealed), and a temporary public key, neither of which appear in any traceable way during a routed payment; certainly this is worse than no knowledge since the Escrow can compute `b'` and choose to cheat by giving this to the Seller, but I claim that this does not require more trust in the Escrow than is already being put in them. The only information gained by the Escrow is that a payment is happening, and assuming that the Seller contacts them over an onion-routed network (such as TOR), the Escrow doesn't even learn any information about the Buyer or Seller's identities. Although it would certainly be better to have the Escrow not even learn that they are being used, this seems like a pretty acceptable amount of information for them to learn, and has the potential benefit of ensuring that being a trustworthy Escrow platform remains a sustainable (and competitive) endeavor, even in the absence of disputes.
On a somewhat unrelated note, I just want to throw out there that it may be simpler to have a scheme for routing Discreet Log Contracts over the lightning network for the kinds of simple oracle contracts like "seller S will deliver 100 pieces of USA federal reserve commemorative decoration paper in exchange for 1 satoshi from buyer". Using a DLC would have the benefit of requiring no interaction with the oracle (excluding broadcast which is fine) during dispute settlement. Just a thought :)
Best, Nadav
On Thu, Jun 20, 2019 at 12:54 AM ZmnSCPxj via Lightning-dev < lightning-dev at lists.linuxfoundation.org> wrote:
Quoted text (168 lines)
> Good morning list, > > One thing I am attempting to think through is some implementation of > escrow over Lightning. > > A non-custodial onchain escrow protocol simply uses a 2-of-3 multisig > amongst the two participants and the escrow. > Such a contract (like any onchain-enforceable contract) can be transported > over a *single* Lightning channel, but cannot be safely hopped across > channels: the escrow may take "one" side in one channel while taking the > "other" side on the other channel, thus putting every hop node at risk. > > Escrow services are useful when Bitcoin needs to interact with other > systems, such as the mythical "real world", when tr*st in a brandless > entity is difficult to procure, while some escrow service can aggregate and > reuse tr*st in its brand to enable trades between brandless entities. > Thus if at all possible, we should consider how best to support escrow > services over Lightning. > > I formulate the contract below: > > * A brandless buyer B wants to pay a brandless seller S for a service or > product. > * Both B and S have non-trust in one another, but can agree to tr*st a > common branded escrow E. > * B shall pay S if both B and S can agree that the service was rendered > satisfactorily or product was delivered. > * In case of dispute, E decides whether S is paid or B is refunded. > * B and S want to provide as little information to E as possible if both B > and S can come to an agreement (i.e. only reveal information if a dispute > occurs). > > Tr*st is still needed in E. > In particular, B and S both trust that E will not be susceptible to > bribery from their counterparty. > > The above can trivially be implemented onchain using a 2-of-3 multisig. > > 1, The branded escrow E provides a public key as part of its brand. > 2. B and S generate a short contract description of the service or > product to be rendered, in a language that E understands. > 3. B and S tweak the escrow public key (if `E` is the escrow pubkey and > `c` is the description of the service/product, use `E + h(E | c) * G`). > 4. B and S generate a 2-of-3 address using their own keys, plus the > tweaked escrow public key. > 5. If B and S can come to an agreement, then they sign using their own > keys, and the third key (the tweaked escrow key) remains tweaked and E > cannot determine that it could have been used as the escrow, or the details > of the transaction, even if it monitors the blockchain (since its key is > not used directly, instead a tweaked version is used, and the tweak is not > revealed E if B and S are in agreement). > But if B and S come to a dispute, either can provide E with the > agreed-upon description `c` that is committed to onchain, and lets E judge > where the payment should go. > > Under bip-taproot this can be optimized somewhat in favor of the "no > dispute" case by setting the taproot internal key to `MuSig(B, S)`, and > having separate MAST branches for `MuSig(E + h(E | c) * G, B)` and `MuSig(E > + h(E | c) * G, S)`. > > This use-case is important: consider the case where the seller is selling > pieces of decorated paper mass-printed by some centralized financial > institution. > For face-to-face transactions, it is enough for all of the participants to > appear and for the Lightning payment to be attempted and so forth. > But for non-face-to-face transactions (such as when one participant is > secretly an AI that is attempting to take over the world, and is currently > unable to puppet some meatspace representative), such escrow would be best > done online with no requirement of physical presence. > > --- > > Naively, it seems that switching to payment points / scalars from payment > hashes / preimages (a necessity for payment decorrelation) may work. > It may be possible to use some kind of verifiable secret sharing. > > However, I would like to make the following points possible: > > * The escrow does not learn about an escrowed trade unless a dispute > between buyer and seller occurs. > * The escrow is capable of returning the buyer funds immediately as soon > as it can resolve the dispute without timing out the payment. > * Intermediate hop nodes that are not the buyer, seller, or escrow, remain > unaware of the escrowed trade (ideally, if they support the "normal" > payment points / scalars system, they should not need any special support > for escrowed trade). > > Let me sketch below something, which might not work since I have not > actually learned verifiable secret sharing at all. > In particular, if verifiable secret sharing requires that the participants > including the escrow to set up the payment point interactively, this fails > the first desired item, that the escrow only learns of the escrowed trade > in a dispute case. > (i.e. a real mathist should actually check this.) > > --- > > I will ignore here temporarily the issues of payment decorrelation, and > pretend that the same point is used in the entire path. > > Before all this, E publishes its escrow key `E`. > > First, B and S generate temporary payment points and scalars, `B = b * G` > and `S = s * G`. > Then they agree on the contract `c` describing their agreement, in a > language that E understands, e.g. "seller S will deliver 100 pieces of USA > federal reserve commemorative decoration paper in exchange for 1 satoshi > from buyer". > > Then B generates an ECDH shared secrets between escrow and buyer: > > tweak(c, P) = P + h(P | c) * G > ecdh(a, B) = h(a * B) > b' = ecdh(b, tweak(c, E)) > B' = b' * G > S' = S + B' > > The payment point used in the payment route is `S'`. > > B provides `B` and `B'` to S (this can be done using TLV in the onion > packet). > Of course, we also need to provide a proof that `B' == ecdh(b, tweak(c, > E)) * G` where `B == b * G`. > I have no idea how easy (or impossible) it is to make such a proof > (without E having to attest to it). > > If S believes it has fulfilled the contract and delivered the product or > service, it contacts B. > If B is satisfied with the product or service, it provides `b'`, allowing > S to compute `s + b'` needed to claim the payment point `S + B'`. > In the non-dispute case, E never learns that it could have been the escrow. > B receives the scalar `s + b'` from the payment, but it knows `b'` and can > compute the scalar `s` which now serves as proof-of-payment. > > If B is unsatisfied, we have a dispute condition and S contacts the escrow > E. > S provides `B` and the contract `c` to the escrow. > ECDH allows E to determine `b' = ecdh(e + h((e * G) | c), B)`. > If E decides in favor of the seller, then it reveals `b'` to S, which can > then compute `s + b'` and claim the payment point `S + B'`. > > However, note that if E decides in favor of the buyer, it cannot do > anything other than let the payment timeout lapse, which automatically > forces the seller S to fail the HTLC. > I cannot derive a way for E to force S to fail the HTLC, without revealing > to intermediate hop nodes that this is an escrow payment. > > Even if E is the only intermediate hop node between B and S (an > undesirable situation since it allows E to censor and surveil the payments > between B and S), it is not safe for E to fail its incoming PTLC until S > has failed its incoming PTLC, as otherwise B and S could be coordinating to > steal from escrow E. > > There are likely to be better schemes. > Again, the ideal scheme would provide: > > * Escrow only learns of dispute cases, never learns non-dispute case. > * Buyer can recover funds immediately as soon as escrow decides in favor > of buyer. <- this seems difficult/impossible under LN. > * Intermediate hop nodes are unaware of anything special with the payment. > > Regards, > ZmnSCPxj > _______________________________________________ > Lightning-dev mailing list > Lightning-dev at lists.linuxfoundation.org > https://www.learnbitcoin.com/archive/lists/lightning-dev >
Good morning Nadav,
Quoted text (3 lines)
> Hi ZmnSCPxj, > > I find this idea super exciting!
Thank you.
I observe that this idea involves sending a key (`b'`) from buyer (who is paying over the LN, i.e. payer) to seller (who is getting paid over the LN, i.e. payee). As it happens, with knowledge of the contract as well as a (possibly temporary) pubkey of the buyer, the escrow can also provide this key if it decides in favor of the seller.
I observe also that the Stuckless Payments proposal also involves a key being sent from payer ("buyer") to payee ("seller"). Might it be possible to reuse the same key for both escrow and stuckless? (we might have to separate the scalars used for decorrelation from the final key used in stuckless / escrow).
Quoted text (6 lines)
> > I think that the main wrinkle in what you've presented is how the Seller can verify that `B'` is indeed `ecdh(b, tweak(c, E))*G` since absent this authentication, the Escrow will be unable to provide the Seller with the necessary information to claim funds during a dispute. > > Perhaps there is some fancy ZKP that allows the Seller and Buyer to establish this alone but I don't know what that would look like. If it exists than that scheme would be better than the following but here are my thoughts: > > If we do need the Escrow to attest to the validity of `B'`, we want to make sure that the Escrow gains as little knowledge as possible. If we add a salt to the `tweak` function's hash (i.e `tweak(c, P, salt) = P + h(P | c | salt)*G`) and this salt is agreed upon by the Buyer and Seller (say for example, `salt = ecdh(s, B)`), then the Seller can tell the Escrow to compute `B'` given only `h(E | c | salt)` and `B` using `B' = ecdh(e + h(E | c | salt), B) * G`. In this way, the Escrow can validate for the Seller that `B'` is what it should be, while learning only a random hash (who's `salt` ensures no information about `c` is revealed), and a temporary public key, neither of which appear in any traceable way during a routed payment; certainly this is worse than no knowledge since the Escrow can compute `b'` and choose to cheat by giving this to the Seller, but I claim that this does not require more trust in the Escrow than is already being put in them. The only information gained by the Escrow is that a payment is happening, and assuming that the Seller contacts them over an onion-routed network (such as TOR), the Escrow doesn't even learn any information about the Buyer or Seller's identities. Although it would certainly be better to have the Escrow not even learn that they are being used, this seems like a pretty acceptable amount of information for them to learn, and has the potential benefit of ensuring that being a trustworthy Escrow platform remains a sustainable (and competitive) endeavor, even in the absence of disputes.
Indeed, this seems acceptable to me also. Thank you for working this out, it seems feasible to me.
Regards, ZmnSCPxj
Hey ZmnSCPxj,
Am I correct in understanding that this is a proposal to change the spec (maybe add a new BOLT) so that all lightning implementations can try to support this feature.
If the above is true, then I'm wondering: could a Lightning-based escrow system be implemented that doesn't require to modify the existing implementations? Maybe if we simplify the requirements a bit? Like, removing the "Escrow only learns of dispute cases, never learns non-dispute case" aspect? That is, the third-party S always knows about an escrow between A and B taking place.
I understand that the above requirement is a good to have, but if removing it allows a simpler version of escrow be implemented, then at least there could be an interim solution for non-custodial exchanges to start adopting this (otherwise they have to resort to custodial-based escrows, which is worse than lacking the escrow privacy brought by the requirement above).
Thanks
Hello,
While reading this thread I realized that my colleagues and I have been working on a construction called “Bitcoin-compatible Virtual Channels” [1] that, at a first glance, highly resembles the use case and requirements that you put forward in this thread. In a nutshell, a Virtual Channel is built on top of two payment channels and use them to construct its own “funding transaction”. Imagine that Buyer and Seller do not have a payment channel between them, but they both have a payment channel with a common node (e.g., Escrow in your example). Alice and Bob can create a Virtual Channel between them using fundings from both: channel Alice-Escrow and channel Escrow-Bob. After created, the Virtual Channel offers the same functionality as a direct payment channel between Alice and Bob (i.e., Escrow is no longer involved for payments). Our construction makes sure that no party losses funds when the Virtual Channel needs to be closed (either when Alice and Bob collaborate or any of the 3 parties cheat).
This construction is compatible with the current Bitcoin script (e.g., taproot is not required although perhaps useful when available) and with the Lightning Network. In the paper, we describe our construction assuming that a payment-channel follows the design in “Generalized Bitcoin-Compatible Channels” [2], however the Virtual Channel construction can seamlessly work using the current Lightning payment channels.
I would be glad to hear any feedback that you may have.
Cheers, Pedro Moreno-Sanchez
==
[1] https://eprint.iacr.org/2020/554 [2] https://eprint.iacr.org/2020/476.pdf
Quoted text (15 lines)
> On Feb 8, 2021, at 9:09 AM, Andrés G. Aragoneses <knocte at gmail.com> wrote: > > Hey ZmnSCPxj, > > Am I correct in understanding that this is a proposal to change the spec (maybe add a new BOLT) so that all lightning implementations can try to support this feature. > > If the above is true, then I'm wondering: could a Lightning-based escrow system be implemented that doesn't require to modify the existing implementations? Maybe if we simplify the requirements a bit? Like, removing the "Escrow only learns of dispute cases, never learns non-dispute case" aspect? That is, the third-party S always knows about an escrow between A and B taking place. > > I understand that the above requirement is a good to have, but if removing it allows a simpler version of escrow be implemented, then at least there could be an interim solution for non-custodial exchanges to start adopting this (otherwise they have to resort to custodial-based escrows, which is worse than lacking the escrow privacy brought by the requirement above). > > Thanks > _______________________________________________ > Lightning-dev mailing list > Lightning-dev at lists.linuxfoundation.org > https://www.learnbitcoin.com/archive/lists/lightning-dev
Hi Andrés,
Quoted text (3 lines)
> Am I correct in understanding that this is a proposal to change the spec (maybe add a new BOLT) so that all lightning implementations can try to support this feature.
Yes, the proposal relies on the use of PTLCs in place of HTLCs which is a popular change that will (hopefully) be brought about by Taproot. It is worth noting that this change is not specific to this protocol and that only the end nodes (buyer and seller) would need any special code in order to execute these contracts if the underlying Lightning Network was using PTLCs.
Quoted text (6 lines)
> If the above is true, then I'm wondering: could a Lightning-based escrow system be implemented that doesn't require to modify the existing implementations? Maybe if we simplify the requirements a bit? Like, removing the "Escrow only learns of dispute cases, never learns non-dispute case" aspect? That is, the third-party S always knows about an escrow between A and B taking place.
At a high level, what is required here is that the payment goes through iff [Seller AND (Buyer OR Escrow)] agree to it. Lifting restrictions so that the Escrow is allowed to be more interactive can allow the Buyer and Escrow to do an interactive shared secret generation and this secret could then be used in a spontaneous payment to the Seller (meaning the payment hash is generated by the Buyer and not the Seller) and then the Seller would have to obtain a ZKP from the Escrow that the payment hash is the hash of a secret known to the Escrow. If all of this were done, then the Seller could execute given the shared secret from either the Buyer or the Escrow. Of note, another downside to this scheme beyond Escrow involvement is that there is no proof of payment/reciept over the Lightning Network for this payment because it is a spontaneous payment.
Like ZmnSCPxj's proposal, this would only require special code for the "end nodes" (Buyer and Seller) and the underlying HTLC-based lightning network would require no changes. Also note that this scheme relies on the existence of a Zero Knowledge Proof of Knowledge (ZKPoK) of a hash which is not a trivial piece of work but certainly do-able.
Hi Pedro,
I actually did have a question for you about Virtual Channels: The first time I read the paper it struck me that while on the surface things look pretty nice for the virtual channel participants, the intermediary has to lock up a lot of collateral (in total, the size of the channel) in order to enable this and subsequently this channel could stay open for a very long time. As such, to the intermediary this seems very similar to having to route a (potentially very large) hodl HTLC which means they will be charging a very large fee for both the setup and the duration of the channel. Because of this, I'm having trouble thinking of almost any use cases where this is preferable to just routing payments the normal way other than if the in-between node is not reliable and there are no other cheap routes (in which case it might be worth it to pay a premium). Did you or your colleagues have other use cases in mind? And have you done any fee analysis for this scheme?
Best, Nadav
On Mon, Feb 8, 2021 at 2:43 AM Pedro Moreno-Sanchez < pedrorechezmailinglists at gmail.com> wrote:
Quoted text (68 lines)
> Hello, > > While reading this thread I realized that my colleagues and I have been > working on a construction called “Bitcoin-compatible Virtual Channels” [1] > that, at a first glance, highly resembles the use case and requirements > that you put forward in this thread. In a nutshell, a Virtual Channel is > built on top of two payment channels and use them to construct its own > “funding transaction”. Imagine that Buyer and Seller do not have a payment > channel between them, but they both have a payment channel with a common > node (e.g., Escrow in your example). Alice and Bob can create a Virtual > Channel between them using fundings from both: channel Alice-Escrow and > channel Escrow-Bob. After created, the Virtual Channel offers the same > functionality as a direct payment channel between Alice and Bob (i.e., > Escrow is no longer involved for payments). Our construction makes sure > that no party losses funds when the Virtual Channel needs to be closed > (either when Alice and Bob collaborate or any of the 3 parties cheat). > > This construction is compatible with the current Bitcoin script (e.g., > taproot is not required although perhaps useful when available) and with > the Lightning Network. In the paper, we describe our construction assuming > that a payment-channel follows the design in “Generalized > Bitcoin-Compatible Channels” [2], however the Virtual Channel construction > can seamlessly work using the current Lightning payment channels. > > I would be glad to hear any feedback that you may have. > > Cheers, > Pedro Moreno-Sanchez > > == > > [1] https://eprint.iacr.org/2020/554 > [2] https://eprint.iacr.org/2020/476.pdf > > > On Feb 8, 2021, at 9:09 AM, Andrés G. Aragoneses <knocte at gmail.com> > wrote: > > > > Hey ZmnSCPxj, > > > > Am I correct in understanding that this is a proposal to change the spec > (maybe add a new BOLT) so that all lightning implementations can try to > support this feature. > > > > If the above is true, then I'm wondering: could a Lightning-based escrow > system be implemented that doesn't require to modify the existing > implementations? Maybe if we simplify the requirements a bit? Like, > removing the "Escrow only learns of dispute cases, never learns non-dispute > case" aspect? That is, the third-party S always knows about an escrow > between A and B taking place. > > > > I understand that the above requirement is a good to have, but if > removing it allows a simpler version of escrow be implemented, then at > least there could be an interim solution for non-custodial exchanges to > start adopting this (otherwise they have to resort to custodial-based > escrows, which is worse than lacking the escrow privacy brought by the > requirement above). > > > > Thanks > > _______________________________________________ > > Lightning-dev mailing list > > Lightning-dev at lists.linuxfoundation.org > > https://www.learnbitcoin.com/archive/lists/lightning-dev > > _______________________________________________ > Lightning-dev mailing list > Lightning-dev at lists.linuxfoundation.org > https://www.learnbitcoin.com/archive/lists/lightning-dev >
Hi Nadav,
You are right that the intermediary (i.e., Ingrid) needs to hold a certain amount of coins to allow the virtual channel between Alice and Bob. Some comments here: - The protocol makes sure that Ingrid will get paid whatever fee she decides to charge for the service of creating a virtual channel. Note that Ingrid does not have the guarantee that enough payments would be routed through her node to gain the same fee in the same amount of time.
- If Ingrid is afraid that her coins will hold too long, one of the two modes in our construction for virtual channels offers the possibility for Ingrid to close the virtual channel at any time and get the locked coins back (plus the fee).
- On the other hand, imagine that Ingrid charges “x” as fee. Alice and Bob would be interested in opening a virtual channel if they plan to do a number of payments between them such that the total fee they would pay would be higher than “x”. (We have a more elaborated fee analysis at the end of the performance evaluation section in the paper).
We envision some use cases where virtual channels would be beneficial: - Imagine Bob is a new provider of a web service (e.g., premium news or a premium music player) that charges for each new/song that is downloaded. Alice, who has previously created all the channels that she is willing/able to manage, still wants to try this new service. Alice could open a virtual channel with Bob to try out this service.
- Same situation as before, but Bob (a router) now offers wifi connection in exchange for micropayments.
- In general, any two-party computation between Alice and Bob that can be expressed in Bitcoin scripting language in a scenario where Alice and Bob do not share a payment channel yet.
And of course could be other use cases that we have not thought about yet. I am looking forward to hearing any proposal that people in this list might have.
Cheers, Pedro.
Quoted text (8 lines)
> On 8 Feb 2021, at 20:49, Nadav Kohen <nadav at suredbits.com> wrote: > > Hi Pedro, > > I actually did have a question for you about Virtual Channels: The first time I read the paper it struck me that while on the surface things look pretty nice for the virtual channel participants, the intermediary has to lock up a lot of collateral (in total, the size of the channel) in order to enable this and subsequently this channel could stay open for a very long time. As such, to the intermediary this seems very similar to having to route a (potentially very large) hodl HTLC which means they will be charging a very large fee for both the setup and the duration of the channel. Because of this, I'm having trouble thinking of almost any use cases where this is preferable to just routing payments the normal way other than if the in-between node is not reliable and there are no other cheap routes (in which case it might be worth it to pay a premium). Did you or your colleagues have other use cases in mind? And have you done any fee analysis for this scheme? > > Best, > Nadav
Good morning Pedro,
Quoted text (4 lines)
> Hi Nadav, > > You are right that the intermediary (i.e., Ingrid) needs to hold a certain amount of coins to allow the virtual channel between Alice and Bob. Some comments here: > - The protocol makes sure that Ingrid will get paid whatever fee she decides to charge for the service of creating a virtual channel. Note that Ingrid does not have the guarantee that enough payments would be routed through her node to gain the same fee in the same amount of time.
Have not examined this deeply, but what happens if any of the *actual* Alice-Ingrid or Ingrid-Bob channels are forced unilaterally onchain before the purported lifetime of the virtual channel?
Regards, ZmnSCPxj
Good morning Nadav and Andres,
Thank you for bringing up this topic again.
Let me provide a new twist to this old idea.
This is the entire logic of the contract to the seller:
SELLER && (BUYER || ESCROW)
Now, a big issue is that simple `&&` is trivial for PTLCs, it is the `||` which is difficult and requires ECDH and proof that the ECDH was done correctly.
But we can observe the De Morgan Theorem:
A || B <=> !(!A && !B)
So how about we *invert* the logic?
So what we do is, we make *two* payments of the same amount:
* Seller -> Buyer , claimable by BUYER && ESCROW key. * Buyer -> Seller, claimable by SELLER key.
So the ritual is this:
* Seller -> Buyer claimable by BUYER && ESCROW. * Buyer -> Seller claimable by SELLER. * Seller hands over item. * Buyer judges whether to accept, or complain to Escrow.
Now let us consider our cases:
* Buyer is satisfied with the product.
* Buyer fails the Seller->Buyer payment after seller claims the Buyer->Seller payment, so Seller is paid and has no more obligations.
* Buyer is dissastisfied and wants the Escrow to judge:
* Escrow judges Buyer is right: Escrow reveals ESCROW key to Buyer, who then clawbacks the payment to the seller.
* Escrow judges Seller is right: Escrow deletes ESCROW privkey ("not ESCROW"), and the Seller->Buyer payment eventually times out, ending the obligation of the Seller.
The "reverse" payment is effectively the inversion of logic by the De Morgan theorem, and the "normal case" (buyer ultimately pays seller) has the Escrow not revealing the privkey. In addition, in the case where Buyer is satisfied (i.e. both Buyer and Seller agree the trade is beneficial) the Escrow is never involved (the Escrow might have a timeout for the temporary ESCROW keypair, which it will eventually delete; since all payments on LN need a timeout anyway, this is fine) and thus does not know about the trade, except that some trade was requested (since it must provide a temporary ESCROW pubkey).
This even provides a simple BUYER + ESCROW keypair that gives the seller a proof-of-refund, and of course the simple SELLER gives the buyer a proof-of-payment as well. It only just requires twice as much Bitcoins getting locked.
Thoughts?
Regards, ZmnSCPxj
This looks cool but would hinder UX too much for certain scenarios: e.g. if the escrow in place is part of a bitcoin exchange, then you require the bitcoin buyer to have bitcoin already, which makes it harder to on-ramp new users (which could maybe only have fiat). Am I right?
So are you saying that this is not doable without PTLCs (with simple HTLCs) unless it's done like suggested?
On Thu, 11 Feb 2021 at 14:01, ZmnSCPxj <ZmnSCPxj at protonmail.com> wrote:
Quoted text (64 lines)
> Good morning Nadav and Andres,
>
> Thank you for bringing up this topic again.
>
> Let me provide a new twist to this old idea.
>
> This is the entire logic of the contract to the seller:
>
> SELLER && (BUYER || ESCROW)
>
> Now, a big issue is that simple `&&` is trivial for PTLCs, it is the `||`
> which is difficult and requires ECDH and proof that the ECDH was done
> correctly.
>
> But we can observe the De Morgan Theorem:
>
> A || B <=> !(!A && !B)
>
> So how about we *invert* the logic?
>
> So what we do is, we make *two* payments of the same amount:
>
> * Seller -> Buyer , claimable by BUYER && ESCROW key.
> * Buyer -> Seller, claimable by SELLER key.
>
> So the ritual is this:
>
> * Seller -> Buyer claimable by BUYER && ESCROW.
> * Buyer -> Seller claimable by SELLER.
> * Seller hands over item.
> * Buyer judges whether to accept, or complain to Escrow.
>
> Now let us consider our cases:
>
> * Buyer is satisfied with the product.
> * Buyer fails the Seller->Buyer payment after seller claims the
> Buyer->Seller payment, so Seller is paid and has no more obligations.
> * Buyer is dissastisfied and wants the Escrow to judge:
> * Escrow judges Buyer is right: Escrow reveals ESCROW key to Buyer, who
> then clawbacks the payment to the seller.
> * Escrow judges Seller is right: Escrow deletes ESCROW privkey ("not
> ESCROW"), and the Seller->Buyer payment eventually times out, ending the
> obligation of the Seller.
>
> The "reverse" payment is effectively the inversion of logic by the De
> Morgan theorem, and the "normal case" (buyer ultimately pays seller) has
> the Escrow not revealing the privkey.
> In addition, in the case where Buyer is satisfied (i.e. both Buyer and
> Seller agree the trade is beneficial) the Escrow is never involved (the
> Escrow might have a timeout for the temporary ESCROW keypair, which it will
> eventually delete; since all payments on LN need a timeout anyway, this is
> fine) and thus does not know about the trade, except that some trade was
> requested (since it must provide a temporary ESCROW pubkey).
>
> This even provides a simple BUYER + ESCROW keypair that gives the seller a
> proof-of-refund, and of course the simple SELLER gives the buyer a
> proof-of-payment as well.
> It only just requires twice as much Bitcoins getting locked.
>
> Thoughts?
>
> Regards,
> ZmnSCPxj
>Good morning Andres,
Quoted text (1 line)
> This looks cool but would hinder UX too much for certain scenarios: e.g. if the escrow in place is part of a bitcoin exchange, then you require the bitcoin buyer to have bitcoin already, which makes it harder to on-ramp new users (which could maybe only have fiat). Am I right?
Correct. Though note that existing systems like Bisq, to my knowledge, have the same problem, a buyer of Bitcoin has to have a small amount of Bitcoin to offer as stake that can be revoked in case they attempt to defraud the counterparty. Without it, the counterparty takes on increased risk (which translate to larger exchange spread).
In any case, once you have that initial stake, you can then keep increasing your ability to provide stake so as to relieve your counterparties of risk and have them offer better exchange rates, so it is "only" an issue for initial onboarding. Presumably, in the later stable state, parents will provide children the initial stake needed for them to start transacting over such a system, just as they already provide their children with other "initial stakes" (education, food, shelter, etc.) anyway.
Quoted text (2 lines)
> > So are you saying that this is not doable without PTLCs (with simple HTLCs) unless it's done like suggested?
Yes, it is yet another reason we want PTLCs quickly.
An alternative would be to have dual-hash HTLCs, which would be helpful in other escrow-related cases including escrow-facilitated cross-currency swaps.
Regards, ZmnSCPxj
Quoted text (51 lines)
>
> On Thu, 11 Feb 2021 at 14:01, ZmnSCPxj <ZmnSCPxj at protonmail.com> wrote:
>
> > Good morning Nadav and Andres,
> >
> > Thank you for bringing up this topic again.
> >
> > Let me provide a new twist to this old idea.
> >
> > This is the entire logic of the contract to the seller:
> >
> > SELLER && (BUYER || ESCROW)
> >
> > Now, a big issue is that simple `&&` is trivial for PTLCs, it is the `||` which is difficult and requires ECDH and proof that the ECDH was done correctly.
> >
> > But we can observe the De Morgan Theorem:
> >
> > A || B <=> !(!A && !B)
> >
> > So how about we *invert* the logic?
> >
> > So what we do is, we make *two* payments of the same amount:
> >
> > * Seller -> Buyer , claimable by BUYER && ESCROW key.
> > * Buyer -> Seller, claimable by SELLER key.
> >
> > So the ritual is this:
> >
> > * Seller -> Buyer claimable by BUYER && ESCROW.
> > * Buyer -> Seller claimable by SELLER.
> > * Seller hands over item.
> > * Buyer judges whether to accept, or complain to Escrow.
> >
> > Now let us consider our cases:
> >
> > * Buyer is satisfied with the product.
> > * Buyer fails the Seller->Buyer payment after seller claims the Buyer->Seller payment, so Seller is paid and has no more obligations.
> > * Buyer is dissastisfied and wants the Escrow to judge:
> > * Escrow judges Buyer is right: Escrow reveals ESCROW key to Buyer, who then clawbacks the payment to the seller.
> > * Escrow judges Seller is right: Escrow deletes ESCROW privkey ("not ESCROW"), and the Seller->Buyer payment eventually times out, ending the obligation of the Seller.
> >
> > The "reverse" payment is effectively the inversion of logic by the De Morgan theorem, and the "normal case" (buyer ultimately pays seller) has the Escrow not revealing the privkey.
> > In addition, in the case where Buyer is satisfied (i.e. both Buyer and Seller agree the trade is beneficial) the Escrow is never involved (the Escrow might have a timeout for the temporary ESCROW keypair, which it will eventually delete; since all payments on LN need a timeout anyway, this is fine) and thus does not know about the trade, except that some trade was requested (since it must provide a temporary ESCROW pubkey).
> >
> > This even provides a simple BUYER + ESCROW keypair that gives the seller a proof-of-refund, and of course the simple SELLER gives the buyer a proof-of-payment as well.
> > It only just requires twice as much Bitcoins getting locked.
> >
> > Thoughts?
> >
> > Regards,
> > ZmnSCPxjHey ZmnSCPxj,
On Thu, 11 Feb 2021 at 15:33, ZmnSCPxj <ZmnSCPxj at protonmail.com> wrote:
Quoted text (15 lines)
> Good morning Andres, > > > This looks cool but would hinder UX too much for certain scenarios: e.g. > if the escrow in place is part of a bitcoin exchange, then you require the > bitcoin buyer to have bitcoin already, which makes it harder to on-ramp new > users (which could maybe only have fiat). Am I right? > > Correct. > Though note that existing systems like Bisq, to my knowledge, have the > same problem, a buyer of Bitcoin has to have a small amount of Bitcoin to > offer as stake that can be revoked in case they attempt to defraud the > counterparty. > Without it, the counterparty takes on increased risk (which translate to > larger exchange spread). >
Yeah I understand Bisq's model. However not all P2P exchanges work like this; e.g. localcryptos, hodlhodl, localbitcoins, localcryptos...
Quoted text (20 lines)
> > In any case, once you have that initial stake, you can then keep > increasing your ability to provide stake so as to relieve your > counterparties of risk and have them offer better exchange rates, so it is > "only" an issue for initial onboarding. > Presumably, in the later stable state, parents will provide children the > initial stake needed for them to start transacting over such a system, just > as they already provide their children with other "initial stakes" > (education, food, shelter, etc.) anyway. > > > > > So are you saying that this is not doable without PTLCs (with simple > HTLCs) unless it's done like suggested? > > Yes, it is yet another reason we want PTLCs quickly. > > An alternative would be to have dual-hash HTLCs, which would be helpful in > other escrow-related cases including escrow-facilitated cross-currency > swaps. >
Is there any disadvantage about using dual-hash HTLCs? Is it supported by the current LN spec?
Quoted text (74 lines)
>
> Regards,
> ZmnSCPxj
>
>
> >
> > On Thu, 11 Feb 2021 at 14:01, ZmnSCPxj <ZmnSCPxj at protonmail.com> wrote:
> >
> > > Good morning Nadav and Andres,
> > >
> > > Thank you for bringing up this topic again.
> > >
> > > Let me provide a new twist to this old idea.
> > >
> > > This is the entire logic of the contract to the seller:
> > >
> > > SELLER && (BUYER || ESCROW)
> > >
> > > Now, a big issue is that simple `&&` is trivial for PTLCs, it is the
> `||` which is difficult and requires ECDH and proof that the ECDH was done
> correctly.
> > >
> > > But we can observe the De Morgan Theorem:
> > >
> > > A || B <=> !(!A && !B)
> > >
> > > So how about we *invert* the logic?
> > >
> > > So what we do is, we make *two* payments of the same amount:
> > >
> > > * Seller -> Buyer , claimable by BUYER && ESCROW key.
> > > * Buyer -> Seller, claimable by SELLER key.
> > >
> > > So the ritual is this:
> > >
> > > * Seller -> Buyer claimable by BUYER && ESCROW.
> > > * Buyer -> Seller claimable by SELLER.
> > > * Seller hands over item.
> > > * Buyer judges whether to accept, or complain to Escrow.
> > >
> > > Now let us consider our cases:
> > >
> > > * Buyer is satisfied with the product.
> > > * Buyer fails the Seller->Buyer payment after seller claims the
> Buyer->Seller payment, so Seller is paid and has no more obligations.
> > > * Buyer is dissastisfied and wants the Escrow to judge:
> > > * Escrow judges Buyer is right: Escrow reveals ESCROW key to Buyer,
> who then clawbacks the payment to the seller.
> > > * Escrow judges Seller is right: Escrow deletes ESCROW privkey ("not
> ESCROW"), and the Seller->Buyer payment eventually times out, ending the
> obligation of the Seller.
> > >
> > > The "reverse" payment is effectively the inversion of logic by the De
> Morgan theorem, and the "normal case" (buyer ultimately pays seller) has
> the Escrow not revealing the privkey.
> > > In addition, in the case where Buyer is satisfied (i.e. both Buyer and
> Seller agree the trade is beneficial) the Escrow is never involved (the
> Escrow might have a timeout for the temporary ESCROW keypair, which it will
> eventually delete; since all payments on LN need a timeout anyway, this is
> fine) and thus does not know about the trade, except that some trade was
> requested (since it must provide a temporary ESCROW pubkey).
> > >
> > > This even provides a simple BUYER + ESCROW keypair that gives the
> seller a proof-of-refund, and of course the simple SELLER gives the buyer a
> proof-of-payment as well.
> > > It only just requires twice as much Bitcoins getting locked.
> > >
> > > Thoughts?
> > >
> > > Regards,
> > > ZmnSCPxj
>
>
>Quoted text (10 lines)
> On Feb 11, 2021, at 6:31 AM, ZmnSCPxj <ZmnSCPxj at protonmail.com> wrote: > > Good morning Pedro, > >> Hi Nadav, >> >> You are right that the intermediary (i.e., Ingrid) needs to hold a certain amount of coins to allow the virtual channel between Alice and Bob. Some comments here: >> - The protocol makes sure that Ingrid will get paid whatever fee she decides to charge for the service of creating a virtual channel. Note that Ingrid does not have the guarantee that enough payments would be routed through her node to gain the same fee in the same amount of time. > > Have not examined this deeply, but what happens if any of the *actual* Alice-Ingrid or Ingrid-Bob channels are forced unilaterally onchain before the purported lifetime of the virtual channel?
As a safe fallback, the protocol gives time to Ingrid (or Bob depending on the case) to put the other channel onchain before the punishment can be triggered.
Quoted text (3 lines)
> > Regards, > ZmnSCPxj
Good morning Andres,
Quoted text (15 lines)
> Hey ZmnSCPxj, > > On Thu, 11 Feb 2021 at 15:33, ZmnSCPxj <ZmnSCPxj at protonmail.com> wrote: > > > Good morning Andres, > > > > > This looks cool but would hinder UX too much for certain scenarios: e.g. if the escrow in place is part of a bitcoin exchange, then you require the bitcoin buyer to have bitcoin already, which makes it harder to on-ramp new users (which could maybe only have fiat). Am I right? > > > > Correct. > > Though note that existing systems like Bisq, to my knowledge, have the same problem, a buyer of Bitcoin has to have a small amount of Bitcoin to offer as stake that can be revoked in case they attempt to defraud the counterparty. > > Without it, the counterparty takes on increased risk (which translate to larger exchange spread). > > Yeah I understand Bisq's model. > However not all P2P exchanges work like this; e.g. localcryptos, hodlhodl, localbitcoins, localcryptos... >
At least localbitcoins is custodial, and this scheme is non-custodial (though the escrow must still be trusted to actually judge correctly in case of dispute, so non-custodiality might be a very thin assurance).
Quoted text (14 lines)
> > > > In any case, once you have that initial stake, you can then keep increasing your ability to provide stake so as to relieve your counterparties of risk and have them offer better exchange rates, so it is "only" an issue for initial onboarding. > > Presumably, in the later stable state, parents will provide children the initial stake needed for them to start transacting over such a system, just as they already provide their children with other "initial stakes" (education, food, shelter, etc.) anyway. > > > > > > > > So are you saying that this is not doable without PTLCs (with simple HTLCs) unless it's done like suggested? > > > > Yes, it is yet another reason we want PTLCs quickly. > > > > An alternative would be to have dual-hash HTLCs, which would be helpful in other escrow-related cases including escrow-facilitated cross-currency swaps. > > Is there any disadvantage about using dual-hash HTLCs? > Is it supported by the current LN spec?
It is no supported by current LN spec, and PTLCs are overall superior (they are equivalent to having any number of hashes, not just 2 that dual-hash HTLCs can do). So if we need to change the LN spec anyway, PTLCs are still the better choice, since they enable a lot more, and we probably want to support that in the future anyway, so we might as well do HTLC->PTLC rather than HTLC->2HTLC->PTLC.
Regards, ZmnSCPxj
Hey ZmnSCPxj,
On Fri, 12 Feb 2021 at 08:52, ZmnSCPxj <ZmnSCPxj at protonmail.com> wrote:
Quoted text (31 lines)
> Good morning Andres, > > > Hey ZmnSCPxj, > > > > On Thu, 11 Feb 2021 at 15:33, ZmnSCPxj <ZmnSCPxj at protonmail.com> wrote: > > > > > Good morning Andres, > > > > > > > This looks cool but would hinder UX too much for certain scenarios: > e.g. if the escrow in place is part of a bitcoin exchange, then you require > the bitcoin buyer to have bitcoin already, which makes it harder to on-ramp > new users (which could maybe only have fiat). Am I right? > > > > > > Correct. > > > Though note that existing systems like Bisq, to my knowledge, have the > same problem, a buyer of Bitcoin has to have a small amount of Bitcoin to > offer as stake that can be revoked in case they attempt to defraud the > counterparty. > > > Without it, the counterparty takes on increased risk (which translate > to larger exchange spread). > > > > Yeah I understand Bisq's model. > > However not all P2P exchanges work like this; e.g. localcryptos, > hodlhodl, localbitcoins, localcryptos... > > > > At least localbitcoins is custodial, and this scheme is non-custodial > (though the escrow must still be trusted to actually judge correctly in > case of dispute, so non-custodiality might be a very thin assurance). > >
True, I shouldn't have included LB in that list of examples; the other two are non-custodial though.
Quoted text (32 lines)
> > > > > > > In any case, once you have that initial stake, you can then keep > increasing your ability to provide stake so as to relieve your > counterparties of risk and have them offer better exchange rates, so it is > "only" an issue for initial onboarding. > > > Presumably, in the later stable state, parents will provide children > the initial stake needed for them to start transacting over such a system, > just as they already provide their children with other "initial stakes" > (education, food, shelter, etc.) anyway. > > > > > > > > > > > So are you saying that this is not doable without PTLCs (with simple > HTLCs) unless it's done like suggested? > > > > > > Yes, it is yet another reason we want PTLCs quickly. > > > > > > An alternative would be to have dual-hash HTLCs, which would be > helpful in other escrow-related cases including escrow-facilitated > cross-currency swaps. > > > > Is there any disadvantage about using dual-hash HTLCs? > > Is it supported by the current LN spec? > > It is no supported by current LN spec, and PTLCs are overall superior > (they are equivalent to having any number of hashes, not just 2 that > dual-hash HTLCs can do). > So if we need to change the LN spec anyway, PTLCs are still the better > choice, since they enable a lot more, and we probably want to support that > in the future anyway, so we might as well do HTLC->PTLC rather than > HTLC->2HTLC->PTLC. >
But anyway any L2 wallet that interacts with this, will need to be aware of the escrow, so developing an 2HTLC extension for it to work with the current version of bitcoin (instead of waiting for Taproot) should be doable, right?
Quoted text (4 lines)
> > Regards, > ZmnSCPxj >
Good morning Andres,
Quoted text (7 lines)
> > > Is there any disadvantage about using dual-hash HTLCs? > > > Is it supported by the current LN spec? > > > > It is no supported by current LN spec, and PTLCs are overall superior (they are equivalent to having any number of hashes, not just 2 that dual-hash HTLCs can do). > > So if we need to change the LN spec anyway, PTLCs are still the better choice, since they enable a lot more, and we probably want to support that in the future anyway, so we might as well do HTLC->PTLC rather than HTLC->2HTLC->PTLC. > > But anyway any L2 wallet that interacts with this, will need to be aware of the escrow, so developing an 2HTLC extension for it to work with the current version of bitcoin (instead of waiting for Taproot) should be doable, right?
Every forwarding node needs to support 2HTLC or PTLC, meaning it has to be a network-wide upgrade. Then once the network-wide upgrade is deployed, individual endpoints just have to understand this protocol.
Because of the need of widespread upgrade, we would prefer to just upgrade once, from HTLCs to PTLCs, rather than have multiple network-wide upgrades.
Regards, ZmnSCPxj
Hey ZmnSCPxj,
Your earlier post about how to accomplish ORing points without verifiable encryption was super interesting.
I think this contains a clever general NOT operation where you double the payment and use the point as a condition for the "cancellation payment." This is actually very similar to something that is used in my PTLC DLC scheme where many payments are failed in most cases :) But nice to add it to the toolkit, especially as a way to not use ORs for the price of over-collateralization which is acceptable in many use cases.
One comment to make though, is that this mechanism requires the atomic setup of multiple payments otherwise Seller -> Buyer will be set up after which Buyer may keep the free option and not set up the payment in return. Luckily with barrier escrows we can do atomic multi-payment setup to accomplish this!
Best, Nadav
On Fri, Feb 12, 2021 at 11:26 PM ZmnSCPxj <ZmnSCPxj at protonmail.com> wrote:
Quoted text (29 lines)
> Good morning Andres, > > > > > Is there any disadvantage about using dual-hash HTLCs? > > > > Is it supported by the current LN spec? > > > > > > It is no supported by current LN spec, and PTLCs are overall superior > (they are equivalent to having any number of hashes, not just 2 that > dual-hash HTLCs can do). > > > So if we need to change the LN spec anyway, PTLCs are still the better > choice, since they enable a lot more, and we probably want to support that > in the future anyway, so we might as well do HTLC->PTLC rather than > HTLC->2HTLC->PTLC. > > > > But anyway any L2 wallet that interacts with this, will need to be aware > of the escrow, so developing an 2HTLC extension for it to work with the > current version of bitcoin (instead of waiting for Taproot) should be > doable, right? > > Every forwarding node needs to support 2HTLC or PTLC, meaning it has to be > a network-wide upgrade. > Then once the network-wide upgrade is deployed, individual endpoints just > have to understand this protocol. > > Because of the need of widespread upgrade, we would prefer to just upgrade > once, from HTLCs to PTLCs, rather than have multiple network-wide upgrades. > > Regards, > ZmnSCPxj >
Good morning Nadav,
Quoted text (5 lines)
> Hey ZmnSCPxj, > > Your earlier post about how to accomplish ORing points without verifiable encryption was super interesting. > > I think this contains a clever general NOT operation where you double the payment and use the point as a condition for the "cancellation payment." This is actually very similar to something that is used in my PTLC DLC scheme where many payments are failed in most cases :) But nice to add it to the toolkit, especially as a way to not use ORs for the price of over-collateralization which is acceptable in many use cases.
Indeed, specifically this point of De Morgan Theorem transformation should probably be emphasized.
More generally, all Boolean logic can be converted to one of two standard forms.
* sum-of-products i.e. `||` over `&&` * product-of-sums i.e. `&&` over `||`
For example an XOR can be converted to the sum-of-products form:
A ^ B = (!A && B) || (A && !B)
If we have any complicated Boolean logic, we can consider to always use some kind of product-of-sums form. So for the example case, escrow service is the logic:
SELLER && (BUYER || ESCROW)
The above is a standard product-of-sums form.
Any sums (i.e. `||`) can be converted by De Morgan Theorem to product, and the payment can be a reversal instead.
SELLER && !(!BUYER && !ESCROW)
The `!(a && b && ...)` can be converted to a reversal of the payment. The individual `!BUYER` is just the buyer choosing not to claim the seller->buyer direction, and the individual `!ESCROW` is just the escrow choosing not to reveal its temporary scalar for this payment. And any products (i.e. `&&`) are trivially implemented in PTLCs as trivial scalar and point addition.
So it may actually be possible to express *any* Boolean logic, by the use of reversal payments and "option not to release scalar", both of which implement the NOT gate needed for the above. Boolean logic is a fairly powerful, non-Turing-complete, and consistent programming language, and if we can actually implement any kind of Boolean logic with a set of payments in various directions and Barrier Escrows we can enable some fairly complex use-cases..
For example, a simple DLC binary oracle can provide two points in such a way that it can only reveal one scalar of those two points (e.g. it has a persistent public key `P`, and two temporary points `H` and `T` such that `H = T + P`, and it can only safely reveal either `h` or `t`.). Based on the outcome of a coin flip (or other input from the mythical "real world"), it reveals either one or the other scalar. Then we can use either point as part of any `!Oracle` or `Oracle` Boolean logic we need.
Quoted text (2 lines)
> > One comment to make though, is that this mechanism requires the atomic setup of multiple payments otherwise Seller -> Buyer will be set up after which Buyer may keep the free option and not set up the payment in return. Luckily with barrier escrows we can do atomic multi-payment setup to accomplish this!
For this particular use-case, I think it is safe to just use the order "Seller->Buyer, then Buyer->Seller" rather than add a barrier escrow. Remember, the entire setup presumes that both Buyer and Seller can tr\*st the Escrow to resolve disputes, and the Seller->Buyer payment requires BUYER && ESCROW. If the buyer never makes the Buyer->Seller payment presumably the Escrow will take that into consideration during dispute resolution and not release the ESCROW scalar to the Buyer.
And if the Buyer->Seller payment (which requires only SELLER scalar) is claimed "early" by the Seller before handing off the item, the Escrow is tr\*sted to consider this also (it is substantially the same as the Seller providing substandard goods) and release the ESCROW scalar.
Of course in the most general case above where we could potentially do any arbitrary logic it probably makes most sense to use a Barrier escrow as well to ensure atomicity of the setup.
Regards, ZmnSCPxj
Good morning Nadav, and list,
Quoted text (33 lines)
> > More generally, all Boolean logic can be converted to one of two standard forms. > > - sum-of-products i.e. `||` over `&&` > - product-of-sums i.e. `&&` over `||` > > For example an XOR can be converted to the sum-of-products form: > > A ^ B = (!A && B) || (A && !B) > > If we have any complicated Boolean logic, we can consider to always use some kind of product-of-sums form. > So for the example case, escrow service is the logic: > > SELLER && (BUYER || ESCROW) > > The above is a standard product-of-sums form. > > Any sums (i.e. `||`) can be converted by De Morgan Theorem to product, and the payment can be a reversal instead. > > SELLER && !(!BUYER && !ESCROW) > > The `!(a && b && ...)` can be converted to a reversal of the payment. > The individual `!BUYER` is just the buyer choosing not to claim the seller->buyer direction, and the individual `!ESCROW` is just the escrow choosing not to reveal its temporary scalar for this payment. > > > And any products (i.e. `&&`) are trivially implemented in PTLCs as trivial scalar and point addition. > > So it may actually be possible to express any Boolean logic, by the use of reversal payments and "option not to release scalar", both of which implement the NOT gate needed for the above. > Boolean logic is a fairly powerful, non-Turing-complete, and consistent programming language, and if we can actually implement any kind of Boolean logic with a set of payments in various directions and Barrier Escrows we can enable some fairly complex use-cases.. > > For example, a simple DLC binary oracle can provide two points in such a way that it can only reveal one scalar of those two points (e.g. it has a persistent public key `P`, and two temporary points `H` and `T` such that `H = T + P`, and it can only safely reveal either `h` or `t`.). > Based on the outcome of a coin flip (or other input from the mythical "real world"), it reveals either one or the other scalar. > Then we can use either point as part of any `!Oracle` or `Oracle` Boolean logic we need.
Okay, so here is a worked example.
Suppose we have two oracles, 1 and 2. At some point, they will flip coins in the future. Based on their (independent) coin flip, oracle 1 will reveal either H1 or T1, and oracle 2 will reveal either H2 or T2.
Suppose some bettor wants to make some bet:
* Either both coins are heads (H1 && H2), or both coins are tails (T1 && T2).
So we have a Bettor, and a Bookie that facilitates this bet.
So the base logic is that the bettor wins (i.e. there is a payment Bookie->Bettor) if:
(H1 && H2) || (T1 && T2)
And the inverse of that logic (Better->Bookie) if the above is false.
We also know that `T1 = !H1` and `T2 = !H2` (i.e. the DLC oracles will only publish one scalar or the other), so:
(H1 && H2) || (!H1 && !H2)
Let us transform to product-of-sums (this can be done by computers by using a Karnaugh Map):
(H1 || !H2) && (!H1 || H2)
Let us check by Boolean table:
H1 H2 (H1 && H2) || (!H2 && !H2) (H1 || !H2) && (!H1 || H2)
0 0 1 1
0 1 0 0
1 0 0 0
1 1 1 1
So the above product-of-sums is correct.
We apply the De Morgan transform:
!(!H1 && H2) && !(H1 && !H2)
Then we return the `T`s:
!(T1 && H2) && !(H1 && T2)
Since the logic is inverted, what actually happens is that the Bettor makes two payments:
* Bettor->Bookie : (Bookie && T1 && H2) * Bettor->Bookie : (Bookie && H1 && T2)
The Bookie would also need to pay out if the Bettor wins, so the Bookie makes two payments as well:
* Bookie->Bettor : (Bettor && T1 && T2) * Bookie->Bettor : (Bettor && H1 && H2)
We can derive the above by inverting the initial `(H1 && H2) || (!H1 && !H2)` logic, then going through the same conversion to product-of-sums and De Morganizing it as for the Bettor case.
With the above, we now have a setup where either both oracles are heads, or both oracles are tails, and if so the Bettor wins, otherwise the Bookie wins. This all probably needs to be set up with some kind of Barrier Escrow, but Nadav already has that covered.
Here is a cute magical trick. What happens if for example oracle 1 has a failure where the CPU liquid cooler on its server fails, and oracle 1 is unable to find a replacement CPU cooler because the CPU socket has been obsoleted and nobody makes CPU coolers for that CPU socket anymore and the server cannot be brought up again? In that case, it will be unable to publish either `H1` or `T1`.
And note that all the payments above involve `H1` or `T1`. In that case, nobody pays out to anyone, as none of the payments are ever claimable. Thus the case where "oracle disappears" is handled "gracefully" by simply not having any monetary transfers at all. This seems to be a reasonable "fail safe" default to have when one of the oracles disappears without publishing the result of the coin toss.
Regards, ZmnSCPxj
Good morning Nadav, and list,
Quoted text (33 lines)
> > More generally, all Boolean logic can be converted to one of two standard forms. > > - sum-of-products i.e. `||` over `&&` > - product-of-sums i.e. `&&` over `||` > > For example an XOR can be converted to the sum-of-products form: > > A ^ B = (!A && B) || (A && !B) > > If we have any complicated Boolean logic, we can consider to always use some kind of product-of-sums form. > So for the example case, escrow service is the logic: > > SELLER && (BUYER || ESCROW) > > The above is a standard product-of-sums form. > > Any sums (i.e. `||`) can be converted by De Morgan Theorem to product, and the payment can be a reversal instead. > > SELLER && !(!BUYER && !ESCROW) > > The `!(a && b && ...)` can be converted to a reversal of the payment. > The individual `!BUYER` is just the buyer choosing not to claim the seller->buyer direction, and the individual `!ESCROW` is just the escrow choosing not to reveal its temporary scalar for this payment. > > > And any products (i.e. `&&`) are trivially implemented in PTLCs as trivial scalar and point addition. > > So it may actually be possible to express any Boolean logic, by the use of reversal payments and "option not to release scalar", both of which implement the NOT gate needed for the above. > Boolean logic is a fairly powerful, non-Turing-complete, and consistent programming language, and if we can actually implement any kind of Boolean logic with a set of payments in various directions and Barrier Escrows we can enable some fairly complex use-cases.. > > For example, a simple DLC binary oracle can provide two points in such a way that it can only reveal one scalar of those two points (e.g. it has a persistent public key `P`, and two temporary points `H` and `T` such that `H = T + P`, and it can only safely reveal either `h` or `t`.). > Based on the outcome of a coin flip (or other input from the mythical "real world"), it reveals either one or the other scalar. > Then we can use either point as part of any `!Oracle` or `Oracle` Boolean logic we need.
Okay, so here is a worked example.
Suppose we have two oracles, 1 and 2. At some point, they will flip coins in the future. Based on their (independent) coin flip, oracle 1 will reveal either H1 or T1, and oracle 2 will reveal either H2 or T2.
Suppose some bettor wants to make some bet:
* Either both coins are heads (H1 && H2), or both coins are tails (T1 && T2).
So we have a Bettor, and a Bookie that facilitates this bet.
So the base logic is that the bettor wins (i.e. there is a payment Bookie->Bettor) if:
(H1 && H2) || (T1 && T2)
And the inverse of that logic (Better->Bookie) if the above is false.
We also know that `T1 = !H1` and `T2 = !H2` (i.e. the DLC oracles will only publish one scalar or the other), so:
(H1 && H2) || (!H1 && !H2)
Let us transform to product-of-sums (this can be done by computers by using a Karnaugh Map):
(H1 || !H2) && (!H1 || H2)
Let us check by Boolean table:
H1 H2 (H1 && H2) || (!H2 && !H2) (H1 || !H2) && (!H1 || H2)
0 0 1 1
0 1 0 0
1 0 0 0
1 1 1 1
So the above product-of-sums is correct.
We apply the De Morgan transform:
!(!H1 && H2) && !(H1 && !H2)
Then we return the `T`s:
!(T1 && H2) && !(H1 && T2)
Since the logic is inverted, what actually happens is that the Bettor makes two payments:
* Bettor->Bookie : (Bookie && T1 && H2) * Bettor->Bookie : (Bookie && H1 && T2)
The Bookie would also need to pay out if the Bettor wins, so the Bookie makes two payments as well:
* Bookie->Bettor : (Bettor && T1 && T2) * Bookie->Bettor : (Bettor && H1 && H2)
We can derive the above by inverting the initial `(H1 && H2) || (!H1 && !H2)` logic, then going through the same conversion to product-of-sums and De Morganizing it as for the Bettor case.
With the above, we now have a setup where either both oracles are heads, or both oracles are tails, and if so the Bettor wins, otherwise the Bookie wins. This all probably needs to be set up with some kind of Barrier Escrow, but Nadav already has that covered.
Here is a cute magical trick. What happens if for example oracle 1 has a failure where the CPU liquid cooler on its server fails, and oracle 1 is unable to find a replacement CPU cooler because the CPU socket has been obsoleted and nobody makes CPU coolers for that CPU socket anymore and the server cannot be brought up again? In that case, it will be unable to publish either `H1` or `T1`.
And note that all the payments above involve `H1` or `T1`. In that case, nobody pays out to anyone, as none of the payments are ever claimable. Thus the case where "oracle disappears" is handled "gracefully" by simply not having any monetary transfers at all. This seems to be a reasonable "fail safe" default to have when one of the oracles disappears without publishing the result of the coin toss.
Regards, ZmnSCPxj
Quoted text (14 lines)
> The `!(a && b && ...)` can be converted to a reversal of the payment. > The individual `!BUYER` is just the buyer choosing not to claim the > seller->buyer direction, and the individual `!ESCROW` is just the > escrow choosing not to reveal its temporary scalar for this payment. > And any products (i.e. `&&`) are trivially implemented in PTLCs as > trivial scalar and point addition. > > So it may actually be possible to express *any* Boolean logic, by the > use of reversal payments and "option not to release scalar", both of > which implement the NOT gate needed for the above. Boolean logic is a > fairly powerful, non-Turing-complete, and consistent programming > language, and if we can actually implement any kind of Boolean logic > with a set of payments in various directions and Barrier Escrows we > can enable some fairly complex use-cases..
This got me thinking about my first year logic course and functional completeness [1], and it it trivial to prove that any boolean logic can be expressed by this construction. We can trivially build a functionally complete set by just constructing a NAND, a NOR, or {AND, NOT}, all of which you've already done in your prior mails.
The resulting expressions may not be particularly nice, and result in a multitude of payments going back and forth between the participants to represent that logic, but it is possible. So the problem should now simply be reduced to finding a minimal representation for a given expression, which then minimizes the funds committed to a particular instance of the expression.
Cheers, Christian
[1] https://en.wikipedia.org/wiki/Functional_completeness
Hey Christian,
Love this chain of thought! Back before I'd realized as ZmnSCPxj did that we have a nice general NOT operation for a given point, I had a similar thought on this thread https://www.learnbitcoin.com/archive/lists/lightning-dev/t/2019/a-payment-point-feature-family-multisig-dlc-escrow#m-30ad9d98 where we eventually figured out that verifiable encryption kind of yields a nice OR operation (where addition gives a nice AND).
I would like to note a couple of unsolved things/limitations on this front though. The current NOT operation actually isn't composable meaning If I have P_1 and P_2 we know how to construct !(P_1 AND P_2) but I don't believe we know how to do (P_1 AND !P_2). This is because NOT P is essentially an unconditional payment atomic with a reverse "cancellation" payment using P as its payment point.
Looking more closely at ZmnSCPxj's proposal for escrow contracts which we were previously thinking of as (Seller AND (Buyer OR Escrow)) I believe is actually essentially just a payment to the Seller using the point !(Buyer AND Escrow) as opposed to some actually compiled version of (Seller AND (Buyer OR Escrow)).
All of this said, I think it would be super awesome if someone thought of a way to construct some kind of negation operation which is composable in the sense that we can do (A AND NOT B) and/or (A OR NOT B) or the like!
Best, Nadav
On Sat, Feb 27, 2021 at 4:02 AM Christian Decker <decker.christian at gmail.com> wrote:
Quoted text (33 lines)
> > The `!(a && b && ...)` can be converted to a reversal of the payment.
> > The individual `!BUYER` is just the buyer choosing not to claim the
> > seller->buyer direction, and the individual `!ESCROW` is just the
> > escrow choosing not to reveal its temporary scalar for this payment.
> > And any products (i.e. `&&`) are trivially implemented in PTLCs as
> > trivial scalar and point addition.
> >
> > So it may actually be possible to express *any* Boolean logic, by the
> > use of reversal payments and "option not to release scalar", both of
> > which implement the NOT gate needed for the above. Boolean logic is a
> > fairly powerful, non-Turing-complete, and consistent programming
> > language, and if we can actually implement any kind of Boolean logic
> > with a set of payments in various directions and Barrier Escrows we
> > can enable some fairly complex use-cases..
>
> This got me thinking about my first year logic course and functional
> completeness [1], and it it trivial to prove that any boolean logic can
> be expressed by this construction. We can trivially build a functionally
> complete set by just constructing a NAND, a NOR, or {AND, NOT}, all of
> which you've already done in your prior mails.
>
> The resulting expressions may not be particularly nice, and result in a
> multitude of payments going back and forth between the participants to
> represent that logic, but it is possible. So the problem should now
> simply be reduced to finding a minimal representation for a given
> expression, which then minimizes the funds committed to a particular
> instance of the expression.
>
> Cheers,
> Christian
>
> [1] https://en.wikipedia.org/wiki/Functional_completeness
>