Skip to content
LearnBitcoin

ResearchBitcoin Dev Archive lightning-dev list

Revocations with OP_CSFS & signed sequence commitments

6 messages, Jan 30 to Feb 4, 2019. Started by James Chiang.

James Chiang (3), ZmnSCPxj (3)

Permalink First message in the Wayback Machine

James Chiang permalink original

Dear all, I am trying to understand how channel commitment transactions can be revoked with op_checksigfromstack(msg, sig, key) and signed sequence commitments.

I understand that a commitment c(n, randomness) is signed by both parties for each state, and that this signature can be verified with op_csfs(c, sig(A+B), key(A+B)). The sequence n is incremented for each new state.

Given the most recent commitment sequence signature (from both parties) and the sequence commitment opening (n++, r), an output script of an older, revoked commitment transaction can verify that a newer signed commitment sequence exists by examining: op_checksigfromstack(c++, sig(A+B), key(A+B)) c++ == commitment(n++, r) However, it must also have information about its own sequence number n, so it can verify that this is indeed lower than n++ (current). How is sequence number n committed to the nth commitment tx and accessible on-stack during script evaluation?

I learned about this concept from Johnson Lao's and Roasbeef's Talk from Scaling Bitcoin at Stanford: https://scalingbitcoin.org/stanford2017/Day1/SB2017_script_2_0.pdf

Any pointers would be very much appreciated.

Kind regards,

James

ZmnSCPxj in reply to James Chiang permalink original

Good morning James, ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐ On Thursday, January 31, 2019 6:31 AM, James Chiang <james.chiangwu at gmail.com> wrote:

Quoted text (12 lines)
> Dear all,
>  I am trying to understand how channel commitment transactions can be revoked with op_checksigfromstack(msg, sig, key) and signed sequence commitments.
>
> I understand that a commitment c(n, randomness)  is signed by both parties for each state, and that this signature can be verified with op_csfs(c, sig(A+B), key(A+B)). The sequence n is incremented for each new state.
>
> Given the most recent commitment sequence signature (from both parties) and the sequence commitment opening (n++, r), an output script of an older, revoked commitment transaction can verify that a newer signed commitment sequence exists by examining:
>
> -   op_checksigfromstack(c++, sig(A+B), key(A+B))
> -   c++ == commitment(n++, r)
>
> However, it must also have information about its own sequence number n, so it can verify that this is indeed lower than n++ (current). How is sequence number n committed to the nth commitment tx and accessible on-stack during script evaluation?

>From what little I understand, I imagine that "n++" here is a SCRIPT input (such that any "n < n++" must be given).

Then the SCRIPT itself contains the "n" it has.

So the SCRIPT above is lacking the check:

    n < n++

which I suppose can be done via

OP_DUP <n> OP_GERATERTHAN OP_VERIFY

Thus `n` is embedded in the SCRIPT directly as a constant. Now the script itself is committed via P2WSH, and the output SCRIPT is committed to in the SIGHASH algorithm used.

Regards, ZmnSCPxj

James Chiang in reply to ZmnSCPxj permalink original

Good morning ZmnSCPxj, Many thanks for your answers, those are greatly appreciated!

May I follow-up with the following questions related to <n> being in the output script of the nth commitment transaction as you described, which is required so the inequality n++ ?> n can be evaluated during the sweep of the revoked nth state.

   - Does this not imply that n & n++ will necessarily be revealed during a
   unilateral close?
   - The Stanford presentation: "The # of updates is hidden in case of a
   unilateral broadcast."

The following slide from Olaoluwa describes a prior sequence number commitment being embedded in the commitment output:

   -
   https://docs.google.com/presentation/d/14NuX5LTDSmmfYbAn0NupuXnXpfoZE0nXsG7CjzPXdlA/edit#slide=id.g2f288a09cf_0_2

How can the arguments for the evaluation of n++ ?>n be supplied without revealing either commitment sequence numbers?

Regarding Olaoluwa's proposal (slide linked above), I don't follow how the prior commitment opening and embedding of the commitment in the output script contributes to this, any commitment needs its pre-image revealed, thereby revealing n ... what am I missing?

Kind regards,

James

On Fri, Feb 1, 2019 at 6:15 AM ZmnSCPxj <ZmnSCPxj at protonmail.com> wrote:

Quoted text (48 lines)
> Good morning James,
> ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
> On Thursday, January 31, 2019 6:31 AM, James Chiang <
> james.chiangwu at gmail.com> wrote:
>
> > Dear all,
> >  I am trying to understand how channel commitment transactions can be
> revoked with op_checksigfromstack(msg, sig, key) and signed sequence
> commitments.
> >
> > I understand that a commitment c(n, randomness)  is signed by both
> parties for each state, and that this signature can be verified with
> op_csfs(c, sig(A+B), key(A+B)). The sequence n is incremented for each new
> state.
> >
> > Given the most recent commitment sequence signature (from both parties)
> and the sequence commitment opening (n++, r), an output script of an older,
> revoked commitment transaction can verify that a newer signed commitment
> sequence exists by examining:
> >
> > -   op_checksigfromstack(c++, sig(A+B), key(A+B))
> > -   c++ == commitment(n++, r)
> >
> > However, it must also have information about its own sequence number n,
> so it can verify that this is indeed lower than n++ (current). How is
> sequence number n committed to the nth commitment tx and accessible
> on-stack during script evaluation?
>
> From what little I understand, I imagine that "n++" here is a SCRIPT input
> (such that any "n < n++" must be given).
> Then the SCRIPT itself contains the "n" it has.
>
> So the SCRIPT above is lacking the check:
>
>     n < n++
>
> which I suppose can be done via
>
> OP_DUP <n> OP_GERATERTHAN OP_VERIFY
>
>
> Thus `n` is embedded in the SCRIPT directly as a constant.
> Now the script itself is committed via P2WSH, and the output SCRIPT is
> committed to in the SIGHASH algorithm used.
>
> Regards,
> ZmnSCPxj
>
ZmnSCPxj in reply to James Chiang permalink original

Good morning,

The Stamford presentation points to BOLT #3, but this obfuscates the sequence number by XOR. Unfortunately this cannot result in an obfuscated number where `<` operation is sensible.

An idea would be to *add* an obfuscating number. For instance, suppose the `n` field is 64-bit and we decide that 2^63 updates should be enough for anyone. Then at channel setup time, both sides would select a 2^63 number as base for update `n = 0`. So for example, suppose we select the random number `m` at the start of the channel setup. What we publish in-script is `m + n`. The next number would be `m + n + 1`, and so on. This allows comparison of sequence numbers, while obscuring the number of updates.

Regards, ZmnSCPxj

Sent with ProtonMail Secure Email.

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐ On Thursday, January 31, 2019 6:31 AM, James Chiang <james.chiangwu at gmail.com> wrote:

Quoted text (19 lines)
> Dear all,
>  I am trying to understand how channel commitment transactions can be revoked with op_checksigfromstack(msg, sig, key) and signed sequence commitments.
>
> I understand that a commitment c(n, randomness)  is signed by both parties for each state, and that this signature can be verified with op_csfs(c, sig(A+B), key(A+B)). The sequence n is incremented for each new state.
>
> Given the most recent commitment sequence signature (from both parties) and the sequence commitment opening (n++, r), an output script of an older, revoked commitment transaction can verify that a newer signed commitment sequence exists by examining:
>
> -   op_checksigfromstack(c++, sig(A+B), key(A+B))
> -   c++ == commitment(n++, r)
>
> However, it must also have information about its own sequence number n, so it can verify that this is indeed lower than n++ (current). How is sequence number n committed to the nth commitment tx and accessible on-stack during script evaluation?
>
> I learned about this concept from Johnson Lao's and Roasbeef's Talk from Scaling Bitcoin at Stanford:
> https://scalingbitcoin.org/stanford2017/Day1/SB2017_script_2_0.pdf
>
> Any pointers would be very much appreciated.
> Kind regards,
>
> James
James Chiang in reply to ZmnSCPxj permalink original

Hello ZmnSCPxj,

So you suggest obfuscating the initial `n=0` with an initial pre-negotiated m, and applying some kind of deterministic step to this obscured initial state number. Potentially the deterministic sequence step sizes could be determined via pre-negotiated parameters which also obscure the number of states between most current and broadcast...

   - m + a*n
   - (m, a pre-negotiated)
   - (Though this would affect # of possible updates.)

Very cool, thanks so much for your answer(s)!

Kind regards,

James

On Fri, Feb 1, 2019 at 10:34 AM ZmnSCPxj <ZmnSCPxj at protonmail.com> wrote:

Quoted text (63 lines)
> Good morning,
>
> The Stamford presentation points to BOLT #3, but this obfuscates the
> sequence number by XOR.
> Unfortunately this cannot result in an obfuscated number where `<`
> operation is sensible.
>
> An idea would be to *add* an obfuscating number.
> For instance, suppose the `n` field is 64-bit and we decide that 2^63
> updates should be enough for anyone.
> Then at channel setup time, both sides would select a 2^63 number as base
> for update `n = 0`.
> So for example, suppose we select the random number `m` at the start of
> the channel setup.
> What we publish in-script is `m + n`.
> The next number would be `m + n + 1`, and so on.
> This allows comparison of sequence numbers, while obscuring the number of
> updates.
>
> Regards,
> ZmnSCPxj
>
>
> Sent with ProtonMail Secure Email.
>
> ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
> On Thursday, January 31, 2019 6:31 AM, James Chiang <
> james.chiangwu at gmail.com> wrote:
>
> > Dear all,
> >  I am trying to understand how channel commitment transactions can be
> revoked with op_checksigfromstack(msg, sig, key) and signed sequence
> commitments.
> >
> > I understand that a commitment c(n, randomness)  is signed by both
> parties for each state, and that this signature can be verified with
> op_csfs(c, sig(A+B), key(A+B)). The sequence n is incremented for each new
> state.
> >
> > Given the most recent commitment sequence signature (from both parties)
> and the sequence commitment opening (n++, r), an output script of an older,
> revoked commitment transaction can verify that a newer signed commitment
> sequence exists by examining:
> >
> > -   op_checksigfromstack(c++, sig(A+B), key(A+B))
> > -   c++ == commitment(n++, r)
> >
> > However, it must also have information about its own sequence number n,
> so it can verify that this is indeed lower than n++ (current). How is
> sequence number n committed to the nth commitment tx and accessible
> on-stack during script evaluation?
> >
> > I learned about this concept from Johnson Lao's and Roasbeef's Talk from
> Scaling Bitcoin at Stanford:
> > https://scalingbitcoin.org/stanford2017/Day1/SB2017_script_2_0.pdf
> >
> > Any pointers would be very much appreciated.
> > Kind regards,
> >
> > James
>
>
>
ZmnSCPxj in reply to James Chiang permalink original

Good morning James,

It is helpful to also remember that the only requirement be that the sequence number be monotonically increasing. There is no requirement that the step size be *the same* at every update.

Note however that the step size being anything other than 1 is not very useful as long as the blinding initial number `m` is truly selected at random. That should be sufficient to blind the actual number of updates.

Regards, ZmnSCPxj

Sent with ProtonMail Secure Email.

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐ On Friday, February 1, 2019 6:18 PM, James Chiang <james.chiangwu at gmail.com> wrote:

Quoted text (56 lines)
> Hello ZmnSCPxj,
>
> So you suggest obfuscating the initial `n=0` with an initial pre-negotiated m, and applying some kind of deterministic step to this obscured initial state number. Potentially the deterministic sequence step sizes could be determined via pre-negotiated parameters which also obscure the number of states between most current and broadcast...
>
> -   m + a*n
> -   (m, a pre-negotiated)
> -   (Though this would affect # of possible updates.)
>
> Very cool, thanks so much for your answer(s)!
>
> Kind regards,
>
> James
>
> On Fri, Feb 1, 2019 at 10:34 AM ZmnSCPxj <ZmnSCPxj at protonmail.com> wrote:
>
> > Good morning,
> >
> > The Stamford presentation points to BOLT #3, but this obfuscates the sequence number by XOR.
> > Unfortunately this cannot result in an obfuscated number where `<` operation is sensible.
> >
> > An idea would be to *add* an obfuscating number.
> > For instance, suppose the `n` field is 64-bit and we decide that 2^63 updates should be enough for anyone.
> > Then at channel setup time, both sides would select a 2^63 number as base for update `n = 0`.
> > So for example, suppose we select the random number `m` at the start of the channel setup.
> > What we publish in-script is `m + n`.
> > The next number would be `m + n + 1`, and so on.
> > This allows comparison of sequence numbers, while obscuring the number of updates.
> >
> > Regards,
> > ZmnSCPxj
> >
> > Sent with ProtonMail Secure Email.
> >
> > ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
> > On Thursday, January 31, 2019 6:31 AM, James Chiang <james.chiangwu at gmail.com> wrote:
> >
> > > Dear all,
> > >  I am trying to understand how channel commitment transactions can be revoked with op_checksigfromstack(msg, sig, key) and signed sequence commitments.
> > >
> > > I understand that a commitment c(n, randomness)  is signed by both parties for each state, and that this signature can be verified with op_csfs(c, sig(A+B), key(A+B)). The sequence n is incremented for each new state.
> > >
> > > Given the most recent commitment sequence signature (from both parties) and the sequence commitment opening (n++, r), an output script of an older, revoked commitment transaction can verify that a newer signed commitment sequence exists by examining:
> > >
> > > -   op_checksigfromstack(c++, sig(A+B), key(A+B))
> > > -   c++ == commitment(n++, r)
> > >
> > > However, it must also have information about its own sequence number n, so it can verify that this is indeed lower than n++ (current). How is sequence number n committed to the nth commitment tx and accessible on-stack during script evaluation?
> > >
> > > I learned about this concept from Johnson Lao's and Roasbeef's Talk from Scaling Bitcoin at Stanford:
> > > https://scalingbitcoin.org/stanford2017/Day1/SB2017_script_2_0.pdf
> > >
> > > Any pointers would be very much appreciated.
> > > Kind regards,
> > >
> > > James