Research/Bitcoin Dev Archive / lightning-dev list
eltoo towers and implications for settlement key derivation
11 messages, Nov 26 to Dec 4, 2019. Started by Conner Fromknecht.
ZmnSCPxj (3), Christian Decker (3), Conner Fromknecht (2), Rusty Russell (2), Anthony Towns
Hi all,
I recently revisited the eltoo paper and noticed some things related watchtowers that might affect channel construction.
Due to NOINPUT, any update transaction _can_ spend from any other, so in theory the tower only needs the most recent update txn to resolve any dispute.
In order to spend, however, the tower must also produce a witness script which when hashed matches the witness program of the input. To ensure settlement txns can only spend from exactly one update txn, each update txn uses unique keys for the settlement clause, meaning that each state has a _unique_ witness program.
Naively then a tower could store settlement keys for all states, permitting it to reconstruct arbitrary witness scripts for any given sequence of confirmed update txns.
So far, the only work around I’ve come up with to avoid this is to give the tower an extended parent pubkey for each party, and then derive non-hardened settlement keys on demand given the state numbers that get confirmed. It's not the most satisfactory solution though, since leaking one hot settlement key now compromises all sibling settlement keys.
Spending the unique witness programs is mentioned somewhat in section 4.1.4, which refers to deriving keys via state numbers, but to me it reads mostly from the PoV of the counterparties and not a third-party service. Is requiring non-hardened keys a known consequence of the construction? Are there any alternative approaches folks are aware of?
Cheers, Conner
Conner Fromknecht <conner at lightning.engineering> writes:
Quoted text (14 lines)
> Hi all, > > I recently revisited the eltoo paper and noticed some things related > watchtowers that might affect channel construction. > > Due to NOINPUT, any update transaction _can_ spend from any other, so > in theory the tower only needs the most recent update txn to resolve > any dispute. > > In order to spend, however, the tower must also produce a witness > script which when hashed matches the witness program of the input. To > ensure settlement txns can only spend from exactly one update txn, > each update txn uses unique keys for the settlement clause, meaning > that each state has a _unique_ witness program.
I didn't think this was the design. The update transaction can spend any prior, with a fixed script, due to NOINPUT.
The settlement transaction does *not* use NOINPUT, and thus can only spend the matching update.
Cheers, Rusty.
Good morning Rusty,
Quoted text (17 lines)
> > Hi all, > > I recently revisited the eltoo paper and noticed some things related > > watchtowers that might affect channel construction. > > Due to NOINPUT, any update transaction can spend from any other, so > > in theory the tower only needs the most recent update txn to resolve > > any dispute. > > In order to spend, however, the tower must also produce a witness > > script which when hashed matches the witness program of the input. To > > ensure settlement txns can only spend from exactly one update txn, > > each update txn uses unique keys for the settlement clause, meaning > > that each state has a unique witness program. > > I didn't think this was the design. The update transaction can spend > any prior, with a fixed script, due to NOINPUT. > > The settlement transaction does not use NOINPUT, and thus can only > spend the matching update.
My understanding is that this is not logically possible? The update transaction has no fixed txid until it commits to a particular output-to-be-spent, which is either the funding/kickoff txout, or a lower-`nLockTime` update transaction output. Thus a settlement transaction *must* use `NOINPUT` as well, as it has no txid it can spend, if it is constrained to spend a particular update transaction.
Unless I misunderstand how update transactions work, or what settlement transactions are.
Regards, ZmnSCPxj
Good evening,
Quoted text (3 lines)
> I didn't think this was the design. The update transaction can spend any prior, with a fixed script, due to NOINPUT. >From my reading of the final construction, each update transaction has a
unique script to bind settlement transactions to exactly one update.
Quoted text (7 lines)
> My understanding is that this is not logically possible? The update transaction has no fixed txid until it commits to a particular output-to-be-spent, which is either the funding/kickoff txout, or a lower-`nLockTime` update transaction output. > Thus a settlement transaction *must* use `NOINPUT` as well, as it has no txid it can spend, if it is constrained to spend a particular update transaction.
This is also my understanding. Any presigned descendants of a NOINPUT txn must also use NOINPUT as well. This chain must continue until a signer is online to bind a txn to a confirmed input. The unique settlement keys thus prevent rebinding of settlement txns since NOINPUT with a shared script would be too liberal.
Cheers, Conner
On Mon, Dec 2, 2019 at 18:55 ZmnSCPxj <ZmnSCPxj at protonmail.com> wrote:
Quoted text (34 lines)
> Good morning Rusty, > > > > Hi all, > > > I recently revisited the eltoo paper and noticed some things related > > > watchtowers that might affect channel construction. > > > Due to NOINPUT, any update transaction can spend from any other, so > > > in theory the tower only needs the most recent update txn to resolve > > > any dispute. > > > In order to spend, however, the tower must also produce a witness > > > script which when hashed matches the witness program of the input. To > > > ensure settlement txns can only spend from exactly one update txn, > > > each update txn uses unique keys for the settlement clause, meaning > > > that each state has a unique witness program. > > > > I didn't think this was the design. The update transaction can spend > > any prior, with a fixed script, due to NOINPUT. > > > > The settlement transaction does not use NOINPUT, and thus can only > > spend the matching update. > > My understanding is that this is not logically possible? > The update transaction has no fixed txid until it commits to a particular > output-to-be-spent, which is either the funding/kickoff txout, or a > lower-`nLockTime` update transaction output. > Thus a settlement transaction *must* use `NOINPUT` as well, as it has no > txid it can spend, if it is constrained to spend a particular update > transaction. > > Unless I misunderstand how update transactions work, or what settlement > transactions are. > > Regards, > ZmnSCPxj >
ZmnSCPxj <ZmnSCPxj at protonmail.com> writes:
Quoted text (21 lines)
> Good morning Rusty, > >> > Hi all, >> > I recently revisited the eltoo paper and noticed some things related >> > watchtowers that might affect channel construction. >> > Due to NOINPUT, any update transaction can spend from any other, so >> > in theory the tower only needs the most recent update txn to resolve >> > any dispute. >> > In order to spend, however, the tower must also produce a witness >> > script which when hashed matches the witness program of the input. To >> > ensure settlement txns can only spend from exactly one update txn, >> > each update txn uses unique keys for the settlement clause, meaning >> > that each state has a unique witness program. >> >> I didn't think this was the design. The update transaction can spend >> any prior, with a fixed script, due to NOINPUT. >> >> The settlement transaction does not use NOINPUT, and thus can only >> spend the matching update. > > My understanding is that this is not logically possible?
You're right, no wonder I missed this problem :(
OK, so we need to change the key(s) every time. Can we tweak it based on something the watchtower will know, i.e. something in the update tx itself? Obviously not the output, as that would create a circular dependency. Is there some taproot thing we can use to insert some noise in the input?
Cheers, Rusty.
Good morning Rusty,
Quoted text (30 lines)
> ZmnSCPxj ZmnSCPxj at protonmail.com writes: > > > Good morning Rusty, > > > > > > Hi all, > > > > I recently revisited the eltoo paper and noticed some things related > > > > watchtowers that might affect channel construction. > > > > Due to NOINPUT, any update transaction can spend from any other, so > > > > in theory the tower only needs the most recent update txn to resolve > > > > any dispute. > > > > In order to spend, however, the tower must also produce a witness > > > > script which when hashed matches the witness program of the input. To > > > > ensure settlement txns can only spend from exactly one update txn, > > > > each update txn uses unique keys for the settlement clause, meaning > > > > that each state has a unique witness program. > > > > > > I didn't think this was the design. The update transaction can spend > > > any prior, with a fixed script, due to NOINPUT. > > > The settlement transaction does not use NOINPUT, and thus can only > > > spend the matching update. > > > > My understanding is that this is not logically possible? > > You're right, no wonder I missed this problem :( > > OK, so we need to change the key(s) every time. Can we tweak it based > on something the watchtower will know, i.e. something in the update tx > itself? Obviously not the output, as that would create a circular > dependency. Is there some taproot thing we can use to insert some > noise in the input?
You could always add a taproot branch with a `OP_RETURN <randomness>` tapscript, which can never be used (thus has no effect on the overall security), but can inject randomness to the outer taproot key. This *is* secure, since bip-schnorr indicates that `e` is `h(R | P | m)`, with `P` being the pubkey itself, so that should be enough.
Or why not BIP32 derivation? This should be just as secure.
Regards, ZmnSCPxj
On Tue, Nov 26, 2019 at 03:41:14PM -0800, Conner Fromknecht wrote:
Quoted text (7 lines)
> I recently revisited the eltoo paper and noticed some things related > watchtowers that might affect channel construction. > In order to spend, however, the tower must also produce a witness > script which when hashed matches the witness program of the input. To > ensure settlement txns can only spend from exactly one update txn, > each update txn uses unique keys for the settlement clause, meaning > that each state has a _unique_ witness program.
I don't believe that's necessary with the ANYPREVOUT design, see
The design I'm thinking of use a common taproot internal key P=muSig(A,B) for update transactions. The tapscript paths are (with the chaperone sigs dropped):
Update n: [nLockTime = 500e6+n]
script: OP_1 CHECKSIGVERIFY [500e6+n+1] CLTV
witness: [ANYPREVOUTANYSCRIPT sig]
Settlement n: [nSequence = delay; nLockTime=500e6+n+1]
witness: [ANYPREVOUT sig]
(This relies on having the two variants of ANYPREVOUT, one of which commits to the state number via commiting to the [500e6+n+1] value in the update tx's script, so that you don't need unique keys to ensure settlement tx n can't spend settlement tx n+k)
With this you can tell which update was posted by subtracting 500e6 from the nLocktime, and use that to calculate the tapscript the update tx used, and the internal key is constant.
The watchtower only needs to post the update tx -- as long as the latest update is posted, the only tx that can spend it is the correct settlement, so you can post that whenever you're back online, even if that's weeks or months later, and likewise for actually claiming your funds from the settlement tx's outputs.
Cheers, aj
Good morning aj,
Quoted text (6 lines)
> The watchtower only needs to post the update tx -- as long as the latest > update is posted, the only tx that can spend it is the correct settlement, > so you can post that whenever you're back online, even if that's weeks > or months later, and likewise for actually claiming your funds from the > settlement tx's outputs. >
This is mildly undesirable, as one of the failure modes is total loss / destruction of your Lightning node.
If the blob contains enough information to bring the update *and* the settlement *and* a transaction that spends your output of the settlement and sends it to a cold-storage address, then at least part of your funds (the ones that are not in HTLCs you could have claimed) can be placed back by the watchtower to some cold-storage address (that is controlled by different hardware from your Lightning node).
Though this is arguably an edge case and it may be a worthwhile tradeoff to just have the watchtower handle up to update transaction only, especially since `SIGHASH_NOINPUT` use we propose expects to have fees paid by another output, not what is being used in the update transaction. This reduces the scope of watchtowers, simplifying their implementation, increasing the chance we can deploy a watchtower network feasibly.
Regards, ZmnSCPxj
(I wrote this a couple of days ago but forgot to send it, sorry for that)
Hi Conner,
thanks for looking into this. I hadn't really thought too much about watchtowers while writing the paper, so there might definitely be things I hadn't considered. I fail to see where the watchtower needs to generate the witness script if he's given the update transaction and the matching settlement transaction (see deployment option 2 below).
There are a couple of deployment options for watchtowers, from simple forward ratchetting to fully settling watchtowers. As you correctly point out if the watchtower just ratchets forward the state, all it needs is the latest update transaction that is bindable to any prior update transaction and therefore the per-channel state is a single update transaction. The channel operator would then come back at a later time, when the watchtower has ratchetted forward and prevented any cheat attempt by the counterparty and just release the latest settlement tx.
This is the model I had in mind when writing since it has constant per-channel state on the watchtower independent of the number of updates and of the size of the state (HTLCs, simple outputs, ...) attached to that settlement. This is safe since the operator knows when it has to check back in at the latest in order to settle HTLCs built on top since they have absolute locktimes (this is not true if we start building relative locktime things on top of eltoo channels, but let's keep it simple for now).
The second deployment option is to give the watchtower the settlement transaction along with the update transaction. The settlement transaction is fully signed and uses noinput/anyprevout to bind to the update, so the bundle of update and settlement transactions is broadcastable right away, no need to produce any scripts or signatures. This ensures that we at least drop the correct state on-chain, but comes at the cost of the watchtower learning intermediate states, or at least the size of the state (number of outputs) if we encrypt it.
A third deployment option would be to allow the watchtower the ability to further settle things we built on top of the base eltoo contract, such as HTLCs, but at that point we are leaking a lot of information, watchtowers become very complex and we lose the flexibility of having clear layering. If we are aiming for this third option indeed the watchtower would also need the ability to bind the HTLC settlement or whatever we build on top of eltoo, which implies they'd also use noinput/anyprevout, but that's hardly an issue, as long as the binding is unique.
Cheers, Christian
Conner Fromknecht <conner at lightning.engineering> writes:
Quoted text (38 lines)
> Hi all, > > I recently revisited the eltoo paper and noticed some things related > watchtowers that might affect channel construction. > > Due to NOINPUT, any update transaction _can_ spend from any other, so > in theory the tower only needs the most recent update txn to resolve > any dispute. > > In order to spend, however, the tower must also produce a witness > script which when hashed matches the witness program of the input. To > ensure settlement txns can only spend from exactly one update txn, > each update txn uses unique keys for the settlement clause, meaning > that each state has a _unique_ witness program. > > Naively then a tower could store settlement keys for all states, > permitting it to reconstruct arbitrary witness scripts for any given > sequence of confirmed update txns. > > So far, the only work around I’ve come up with to avoid this is to > give the tower an extended parent pubkey for each party, and then > derive non-hardened settlement keys on demand given the state numbers > that get confirmed. It's not the most satisfactory solution though, > since leaking one hot settlement key now compromises all sibling > settlement keys. > > Spending the unique witness programs is mentioned somewhat in section > 4.1.4, which refers to deriving keys via state numbers, but to me it > reads mostly from the PoV of the counterparties and not a third-party > service. Is requiring non-hardened keys a known consequence of the > construction? Are there any alternative approaches folks are aware of? > > Cheers, > Conner > _______________________________________________ > Lightning-dev mailing list > Lightning-dev at lists.linuxfoundation.org > https://www.learnbitcoin.com/archive/lists/lightning-dev
That is correct, the chain of noinput/anyprevout transactions is broken as soon as the signers are online and can interactively bind and sign without noinput/anyprevout.
Conner Fromknecht <conner at lightning.engineering> writes:
Quoted text (67 lines)
> Good evening, > >> I didn't think this was the design. The update transaction can spend any > prior, with a fixed script, due to NOINPUT. > > From my reading of the final construction, each update transaction has a > unique script to bind settlement transactions to exactly one update. > >> My understanding is that this is not logically possible? > The update transaction has no fixed txid until it commits to a particular > output-to-be-spent, which is either the funding/kickoff txout, or a > lower-`nLockTime` update transaction output. >> Thus a settlement transaction *must* use `NOINPUT` as well, as it has no > txid it can spend, if it is constrained to spend a particular update > transaction. > > This is also my understanding. Any presigned descendants of a NOINPUT txn > must also use NOINPUT as well. This chain must continue until a signer is > online to bind a txn to a confirmed input. The unique settlement keys thus > prevent rebinding of settlement txns since NOINPUT with a shared script > would be too liberal. > > Cheers, > Conner > > On Mon, Dec 2, 2019 at 18:55 ZmnSCPxj <ZmnSCPxj at protonmail.com> wrote: > >> Good morning Rusty, >> >> > > Hi all, >> > > I recently revisited the eltoo paper and noticed some things related >> > > watchtowers that might affect channel construction. >> > > Due to NOINPUT, any update transaction can spend from any other, so >> > > in theory the tower only needs the most recent update txn to resolve >> > > any dispute. >> > > In order to spend, however, the tower must also produce a witness >> > > script which when hashed matches the witness program of the input. To >> > > ensure settlement txns can only spend from exactly one update txn, >> > > each update txn uses unique keys for the settlement clause, meaning >> > > that each state has a unique witness program. >> > >> > I didn't think this was the design. The update transaction can spend >> > any prior, with a fixed script, due to NOINPUT. >> > >> > The settlement transaction does not use NOINPUT, and thus can only >> > spend the matching update. >> >> My understanding is that this is not logically possible? >> The update transaction has no fixed txid until it commits to a particular >> output-to-be-spent, which is either the funding/kickoff txout, or a >> lower-`nLockTime` update transaction output. >> Thus a settlement transaction *must* use `NOINPUT` as well, as it has no >> txid it can spend, if it is constrained to spend a particular update >> transaction. >> >> Unless I misunderstand how update transactions work, or what settlement >> transactions are. >> >> Regards, >> ZmnSCPxj >> > -- > —Sent from my Spaceship > _______________________________________________ > Lightning-dev mailing list > Lightning-dev at lists.linuxfoundation.org > https://www.learnbitcoin.com/archive/lists/lightning-dev
ZmnSCPxj via Lightning-dev <lightning-dev at lists.linuxfoundation.org> writes:
Quoted text (38 lines)
> Good morning Rusty, > >> ZmnSCPxj ZmnSCPxj at protonmail.com writes: >> >> > Good morning Rusty, >> > >> > > > Hi all, >> > > > I recently revisited the eltoo paper and noticed some things related >> > > > watchtowers that might affect channel construction. >> > > > Due to NOINPUT, any update transaction can spend from any other, so >> > > > in theory the tower only needs the most recent update txn to resolve >> > > > any dispute. >> > > > In order to spend, however, the tower must also produce a witness >> > > > script which when hashed matches the witness program of the input. To >> > > > ensure settlement txns can only spend from exactly one update txn, >> > > > each update txn uses unique keys for the settlement clause, meaning >> > > > that each state has a unique witness program. >> > > >> > > I didn't think this was the design. The update transaction can spend >> > > any prior, with a fixed script, due to NOINPUT. >> > > The settlement transaction does not use NOINPUT, and thus can only >> > > spend the matching update. >> > >> > My understanding is that this is not logically possible? >> >> You're right, no wonder I missed this problem :( >> >> OK, so we need to change the key(s) every time. Can we tweak it based >> on something the watchtower will know, i.e. something in the update tx >> itself? Obviously not the output, as that would create a circular >> dependency. Is there some taproot thing we can use to insert some >> noise in the input? > > You could always add a taproot branch with a `OP_RETURN <randomness>` tapscript, which can never be used (thus has no effect on the overall security), but can inject randomness to the outer taproot key. > This *is* secure, since bip-schnorr indicates that `e` is `h(R | P | m)`, with `P` being the pubkey itself, so that should be enough. > > Or why not BIP32 derivation? > This should be just as secure.
I still fail to see the issue, update_tx and settlement_tx are self-contained, and there is no need to recover the prevout scriptPubKey or any value therein. Are we talking about things built on top of eltoo?
If that's the case, we need to use noinput/anyprevout anyway, so why not just replicate the same logic and ship them bound correctly to the watchtower?
I'd also argue that it's not a watchtower's job to finalize the entire off-chain contract. It's main job is to watch the blockchain and react should anything trigger it, while anything we build on top likely has absolute locktimes (HTLCs have absolute timeouts), so it the client that knows when it has to check back in and settle anything that happened.
Cheers, Christian