Skip to content
LearnBitcoin

ResearchBitcoin Dev Archive lightning-dev list

Backward deterministic R Value

12 messages, Mar 7 to 9, 2016. Started by Nicolas Dorier.

Nicolas Dorier (5), Rusty Russell (3), Mats Jerratsch (3), CJP

Permalink First message in the Wayback Machine

Nicolas Dorier permalink original

One way deterministic RValue Generation

My previous proposal, while saving space on chain, does not solve the fact that we need to save offchain one signature per commitment.

I have another proposal, so you don't need any data to store for each commitment. Keep the actual HTLC/Payment channel contracts, but make the "RValues" backward deterministic.

Choose RValue such that:

RValue(n+1) = PreImage(RValue(n)) Where n is the commitment index.

Imagine Alice cheats Bob at commitment 100, by sending revocated commitment 50.

Bob only have to remember RValue(99) from the 99th revocation, and then hash this value 49 times to find out RValue(50)

However, Bob does not know RValue(100) because RValue(100) = PreImage(99)

For Alice, she only have to generate a random number, then generate let's say, 1000 hashes. Then she use hashes 1000 for RValue(0), hashes 999 for RValue(1) etc...

Commitment Revocation is only accepted by the party if RValue(n+1) = PreImage(RValue(n))

The only downside is that Alice need to regenerate all hashes everytimes she need a new commitment. This can be mitigated by her storing some pre computed values along the path.

Nicolas,

Rusty Russell in reply to Nicolas Dorier permalink original

Nicolas Dorier <nicolas.dorier at gmail.com> writes:

Quoted text (1 line)
> One way deterministic RValue Generation

Hi Nicolas,

        Yes, in fact shachain is a variant of this which avoids
generating several million hashes in advance.  Interesting, I suggested
using hashing in the Deployable Lightning paper but didn't actually
spell out the idea.  Hmm....

Seems like it orignated from Adam Back:

https://lists.blockstream.io/pipermail/lightning-dev/2015-May/000000.html

Cheers, Rusty.

Nicolas Dorier in reply to Rusty Russell permalink original

Great, indeed we had same idea, I don't see how it solve the hashes in advance. As Alice knows

H(1000000) = <random secret seed>).

If she need the hash to the first commitment she need to hash the random secret seed 1000000 times. I think it is exactly the same problem as it is the exact same idea said differently.

On Tue, Mar 8, 2016 at 8:31 AM, Rusty Russell <rusty at rustcorp.com.au> wrote:

Quoted text (17 lines)
> Nicolas Dorier <nicolas.dorier at gmail.com> writes:
> > One way deterministic RValue Generation
>
> Hi Nicolas,
>
>         Yes, in fact shachain is a variant of this which avoids
> generating several million hashes in advance.  Interesting, I suggested
> using hashing in the Deployable Lightning paper but didn't actually
> spell out the idea.  Hmm....
>
> Seems like it orignated from Adam Back:
>
> https://lists.blockstream.io/pipermail/lightning-dev/2015-May/000000.html
>
> Cheers,
> Rusty.
>
Rusty Russell in reply to Nicolas Dorier permalink original

Nicolas Dorier <nicolas.dorier at gmail.com> writes:

Quoted text (9 lines)
> Great, indeed we had same idea, I don't see how it solve the hashes in
> advance.
> As Alice knows
>
> H(1000000) = <random secret seed>).
>
> If she need the hash to the first commitment she need to hash the random secret
> seed 1000000 times. I think it is exactly the same problem as it is the exact
> same idea said differently.

See:

        https://github.com/rustyrussell/ccan/tree/master/ccan/crypto/shachain

Cheers, Rusty.

CJP in reply to Nicolas Dorier permalink original

I was wondering: how does deriving R values from a tree structure work for larger Lightning networks? I guess it could work between two nodes, if they keep track of the same tree, but if different transactions follow different routes, does that mean the tree structure somehow has to be shared across all nodes? The alternative is that intermediate nodes still have to remember old R values.

CJP

Nicolas Dorier schreef op di 08-03-2016 om 13:53 [+0900]:

Quoted text (35 lines)
> Great, indeed we had same idea, I don't see how it solve the hashes in
> advance.
> As Alice knows
> H(1000000) = <random secret seed>).
> If she need the hash to the first commitment she need to hash the random secret
> seed 1000000 times. I think it is exactly the same problem as it is the exact
> same idea said differently.
>
> On Tue, Mar 8, 2016 at 8:31 AM, Rusty Russell <rusty at rustcorp.com.au>
> wrote:
>         Nicolas Dorier <nicolas.dorier at gmail.com> writes:
>         > One way deterministic RValue Generation
>
>         Hi Nicolas,
>
>                 Yes, in fact shachain is a variant of this which
>         avoids
>         generating several million hashes in advance.  Interesting, I
>         suggested
>         using hashing in the Deployable Lightning paper but didn't
>         actually
>         spell out the idea.  Hmm....
>
>         Seems like it orignated from Adam Back:
>
>         https://lists.blockstream.io/pipermail/lightning-dev/2015-May/000000.html
>
>         Cheers,
>         Rusty.
>
>
> _______________________________________________
> Lightning-dev mailing list
> Lightning-dev at lists.linuxfoundation.org
> https://www.learnbitcoin.com/archive/lists/lightning-dev
Mats Jerratsch in reply to CJP permalink original

What about if Alice does not want to disclose R? Bob could have taken too much fee and Alice does not agree to accept a payment too small.

While there is technically not really a security problem in disclosing the R values when the payment isn't in the current commitment, the whole idea of 'proof-of-payment'/'pay-to-contract' relies on only revealing R for an accepted payment.

Otherwise, knowing R is no longer proof of having made a payment.

Am 08/03/2016 um 07:19 schrieb CJP:

Quoted text (53 lines)
> I was wondering: how does deriving R values from a tree structure work
> for larger Lightning networks? I guess it could work between two nodes,
> if they keep track of the same tree, but if different transactions
> follow different routes, does that mean the tree structure somehow has
> to be shared across all nodes? The alternative is that intermediate
> nodes still have to remember old R values.
>
> CJP
>
>
> Nicolas Dorier schreef op di 08-03-2016 om 13:53 [+0900]:
>> Great, indeed we had same idea, I don't see how it solve the hashes in
>> advance.
>> As Alice knows
>> H(1000000) = <random secret seed>).
>> If she need the hash to the first commitment she need to hash the random secret
>> seed 1000000 times. I think it is exactly the same problem as it is the exact
>> same idea said differently.
>>
>> On Tue, Mar 8, 2016 at 8:31 AM, Rusty Russell <rusty at rustcorp.com.au>
>> wrote:
>>         Nicolas Dorier <nicolas.dorier at gmail.com> writes:
>>         > One way deterministic RValue Generation
>>
>>         Hi Nicolas,
>>
>>                 Yes, in fact shachain is a variant of this which
>>         avoids
>>         generating several million hashes in advance.  Interesting, I
>>         suggested
>>         using hashing in the Deployable Lightning paper but didn't
>>         actually
>>         spell out the idea.  Hmm....
>>
>>         Seems like it orignated from Adam Back:
>>
>>         https://lists.blockstream.io/pipermail/lightning-dev/2015-May/000000.html
>>
>>         Cheers,
>>         Rusty.
>>
>>
>> _______________________________________________
>> 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
>
Nicolas Dorier in reply to Mats Jerratsch permalink original

I'm not sure what you mean Alice don't have to disclose R if she does not want to. Bob can't know the next R because R(n+1) = PreImage(R(n))

On Wed, Mar 9, 2016 at 12:16 AM, Mats Jerratsch <mats at blockchain.com> wrote:

Quoted text (75 lines)
> What about if Alice does not want to disclose R? Bob could have taken
> too much fee and Alice does not agree to accept a payment too small.
>
> While there is technically not really a security problem in disclosing
> the R values when the payment isn't in the current commitment, the whole
> idea of 'proof-of-payment'/'pay-to-contract' relies on only revealing R
> for an accepted payment.
>
> Otherwise, knowing R is no longer proof of having made a payment.
>
> Am 08/03/2016 um 07:19 schrieb CJP:
> > I was wondering: how does deriving R values from a tree structure work
> > for larger Lightning networks? I guess it could work between two nodes,
> > if they keep track of the same tree, but if different transactions
> > follow different routes, does that mean the tree structure somehow has
> > to be shared across all nodes? The alternative is that intermediate
> > nodes still have to remember old R values.
> >
> > CJP
> >
> >
> > Nicolas Dorier schreef op di 08-03-2016 om 13:53 [+0900]:
> >> Great, indeed we had same idea, I don't see how it solve the hashes in
> >> advance.
> >> As Alice knows
> >> H(1000000) = <random secret seed>).
> >> If she need the hash to the first commitment she need to hash the
> random secret
> >> seed 1000000 times. I think it is exactly the same problem as it is the
> exact
> >> same idea said differently.
> >>
> >> On Tue, Mar 8, 2016 at 8:31 AM, Rusty Russell <rusty at rustcorp.com.au>
> >> wrote:
> >>         Nicolas Dorier <nicolas.dorier at gmail.com> writes:
> >>         > One way deterministic RValue Generation
> >>
> >>         Hi Nicolas,
> >>
> >>                 Yes, in fact shachain is a variant of this which
> >>         avoids
> >>         generating several million hashes in advance.  Interesting, I
> >>         suggested
> >>         using hashing in the Deployable Lightning paper but didn't
> >>         actually
> >>         spell out the idea.  Hmm....
> >>
> >>         Seems like it orignated from Adam Back:
> >>
> >>
> https://lists.blockstream.io/pipermail/lightning-dev/2015-May/000000.html
> >>
> >>         Cheers,
> >>         Rusty.
> >>
> >>
> >> _______________________________________________
> >> 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
> >
>
> --
> Mats Jerratsch
> Backend Engineer, Blockchain
> e: mats at blockchain.com
> PGP: https://pgp.mit.edu/pks/lookup?op=get&search=0x7F3EC6CA
>
>
Mats Jerratsch in reply to Nicolas Dorier permalink original

I'm not saying they close the channel. Alice could want to receive more money and accept other payments, but not a particular one. But by doing so, she would automatically disclose R for any old payment.

Am 08/03/2016 um 15:51 schrieb Nicolas Dorier:

Quoted text (2 lines)
> I'm not sure what you mean Alice don't have to disclose R if she does
> not want to.
Nicolas Dorier in reply to Mats Jerratsch permalink original

I don't understand your point, but that may come from me not having deep enough knowledge about the latest great things happening on Lightning.

I exposed the case of a simple bipayment channel, without HTLC in the equation, where all payments are sequential.

You can't make commitment n+2 before accepting commitment n+1.

My mental model might be incomplete as I'm followed only remotely the improvements of lightning until now.

On Wed, Mar 9, 2016 at 12:53 AM, Mats Jerratsch <mats at blockchain.com> wrote:

Quoted text (15 lines)
> I'm not saying they close the channel. Alice could want to receive more
> money and accept other payments, but not a particular one. But by doing
> so, she would automatically disclose R for any old payment.
>
> Am 08/03/2016 um 15:51 schrieb Nicolas Dorier:
> > I'm not sure what you mean Alice don't have to disclose R if she does
> > not want to.
>
> --
> Mats Jerratsch
> Backend Engineer, Blockchain
> e: mats at blockchain.com
> PGP: https://pgp.mit.edu/pks/lookup?op=get&search=0x7F3EC6CA
>
>
Mats Jerratsch in reply to Nicolas Dorier permalink original

Hah I see, I didn't knew you weren't talking about HTLCs.

But why would you use R values in the first place then? Maybe I'm a little bit confused about what exact use case we are talking here, mind elaborating? :)

Am 08/03/2016 um 16:14 schrieb Nicolas Dorier:

Quoted text (30 lines)
> I don't understand your point, but that may come from me not having
> deep enough knowledge about the latest great things happening on
> Lightning.
>
> I exposed the case of a simple bipayment channel, without HTLC in the
> equation, where all payments are sequential.
>
> You can't make commitment n+2 before accepting commitment n+1.
>
> My mental model might be incomplete as I'm followed only remotely
> the improvements of lightning until now.
>
> On Wed, Mar 9, 2016 at 12:53 AM, Mats Jerratsch <mats at blockchain.com
> <mailto:mats at blockchain.com>> wrote:
>
>     I'm not saying they close the channel. Alice could want to receive more
>     money and accept other payments, but not a particular one. But by doing
>     so, she would automatically disclose R for any old payment.
>
>     Am 08/03/2016 um 15:51 schrieb Nicolas Dorier:
>     > I'm not sure what you mean Alice don't have to disclose R if she does
>     > not want to.
>
>     --
>     Mats Jerratsch
>     Backend Engineer, Blockchain
>     e: mats at blockchain.com <mailto:mats at blockchain.com>
>     PGP: https://pgp.mit.edu/pks/lookup?op=get&search=0x7F3EC6CA
>
>
Nicolas Dorier in reply to Mats Jerratsch permalink original

That's my fault, I said "R-Value" instead of "Commit Revocation Hash". I've not yet thought about how the idea of hash chain can be used for HTLC.

On Wed, Mar 9, 2016 at 1:27 AM, Mats Jerratsch <mats at blockchain.com> wrote:

Quoted text (48 lines)
> Hah I see, I didn't knew you weren't talking about HTLCs.
>
> But why would you use R values in the first place then? Maybe I'm a
> little bit confused about what exact use case we are talking here, mind
> elaborating? :)
>
> Am 08/03/2016 um 16:14 schrieb Nicolas Dorier:
> > I don't understand your point, but that may come from me not having
> > deep enough knowledge about the latest great things happening on
> > Lightning.
> >
> > I exposed the case of a simple bipayment channel, without HTLC in the
> > equation, where all payments are sequential.
> >
> > You can't make commitment n+2 before accepting commitment n+1.
> >
> > My mental model might be incomplete as I'm followed only remotely
> > the improvements of lightning until now.
> >
> > On Wed, Mar 9, 2016 at 12:53 AM, Mats Jerratsch <mats at blockchain.com
> > <mailto:mats at blockchain.com>> wrote:
> >
> >     I'm not saying they close the channel. Alice could want to receive
> more
> >     money and accept other payments, but not a particular one. But by
> doing
> >     so, she would automatically disclose R for any old payment.
> >
> >     Am 08/03/2016 um 15:51 schrieb Nicolas Dorier:
> >     > I'm not sure what you mean Alice don't have to disclose R if she
> does
> >     > not want to.
> >
> >     --
> >     Mats Jerratsch
> >     Backend Engineer, Blockchain
> >     e: mats at blockchain.com <mailto:mats at blockchain.com>
> >     PGP: https://pgp.mit.edu/pks/lookup?op=get&search=0x7F3EC6CA
> >
> >
>
> --
> Mats Jerratsch
> Backend Engineer, Blockchain
> e: mats at blockchain.com
> PGP: https://pgp.mit.edu/pks/lookup?op=get&search=0x7F3EC6CA
>
>
Rusty Russell in reply to Mats Jerratsch permalink original

Mats Jerratsch via Lightning-dev <lightning-dev at lists.linuxfoundation.org> writes:

Quoted text (7 lines)
> What about if Alice does not want to disclose R? Bob could have taken
> too much fee and Alice does not agree to accept a payment too small.
>
> While there is technically not really a security problem in disclosing
> the R values when the payment isn't in the current commitment, the whole
> idea of 'proof-of-payment'/'pay-to-contract' relies on only revealing R
> for an accepted payment.

Nomenclature clash :(

We usually use R to mean the chained atomic swap preimage, which allows you to claim the funds (presumably R means "receipt" here).

Confusingly, we also use "revocation preimage" as the term method to invalidate old transactions, a private matter between pairs of nodes, but try to avoid abbreviating it to R.

We can't use a simple chain for R (because they need to disclose them out of order), and don't need to (since they don't care about the value once it's spent).

Cheers, Rusty.