<blockquote>
  <p>Are these two problems effectively solved with segregated witness?</p>
</blockquote>

<p>One is; one is not.  Specifically:</p>

<blockquote>
  <p>(1) The anchor transation id required for the commitment input will only be known once the anchor is signed.</p>
</blockquote>

<p>Segwit fixes this.  If the anchor transaction contains only segwit inputs, then its transaction identify (txid) does not change when signatures are added.  This allows other transactions (such as the Lightning commitment transaction) to refer to its outputs regardless of whether or not it has been signed.</p>

<blockquote>
  <p>(2) The anchor transaction can be malleated by either party before entering the blockchain, rendering the commitment input unusable.</p>
</blockquote>

<p>Segwit does not fix this specific problem, but it does fix an important related problem.  As the paper you cite says, "The last of these is particularly pernicious, as BIP62 doesn't solve it: signatories can always re-sign a transaction, hence altering its transaction ID."</p>

<p>The anchor transaction is created with inputs each user unilaterally controls (or shares control with a third-party to the Lightning channel currently being opened, an irrelevant detail to this discussion).  Because of this, each user has the ability to create a full double spend of their part of the anchor transaction; if that double spend is what's included in the block chain, then any children of earlier versions of the transaction (such as the commitment transactions) are invalid.</p>

<p>The important related problem segwit does solve is useful to Lightning and required by other smart contract protocols.  A payment in a payment channel (including Lightning) uses multisig to require both parties sign the payment under regular circumstances, called 2-of-2 multisig. Because signatures sign all of the non-signature data in a transaction (normal SIGHASH_ALL) but are currently included when generating the txid, either party can unilaterally malleate a transaction by changing his signature.</p>

<p>But with segwit, all non-signature data in a transaction is still signed but the signatures are not covered by the txid, so neither party can unilaterally change the txid without invaliding the other party's (or parties) signature or signatures.  In other words, it requires both 2-of-2 to change a txid or, more generically for m-of-n, segwit requires at least m participants to change the txid.</p>

<p>This simplifies the design of Lightning-style Hashed TimeLock Contracts (HTLCs) and also improves the privacy of outsourcing channel enforcement, but is not required for Lightning.  However, it is required for some other smart contract protocols that use sequences of transactions.  For example, a Spillman-style payment channel would be secure using segwit but today it is vulnerable to malleability.</p>

CC BY-SA 3.0
2017-05-10T11:01:22.963Z
2017-05-10T11:01:22.963Z
David A. Harding
<p>In <a href="https://github.com/ElementsProject/lightning/blob/master/doc/deployable-lightning.pdf" rel="noreferrer">Rusty Russell's paper</a> about the simplified version of the Lightning Network, some problems about the practical implementation of the opening channel method from the original LN paper are mentioned:</p>

<blockquote>
  <ol>
  <li>The anchor transation id required for the commitment input will only be known once the anchor is signed.</li>
  <li>The anchor transation can be malleated by either party before entering the blockchain, rendering the commitment input unusable.</li>
  </ol>
</blockquote>

<p>The paper mentions mentions how problem 2 is not solved by BIP62, but does not talk about segregated witness. Are these two problems effectively solved with segregated witness?</p>

<lightning-network><segregated-witness><ln-opening-channels>
Does segregated witness allow to securely create LN channel opening transactions?
cpsola
# Does segregated witness allow to securely create LN channel opening transactions?

(Asked by: username_0 on 2016-10-11)

In [Rusty Russell's paper](https://github.com/ElementsProject/lightning/blob/master/doc/deployable-lightning.pdf) about the simplified version of the Lightning Network, some problems about the practical implementation of the opening channel method from the original LN paper are mentioned:

> 1. The anchor transation id required for the commitment input will only be known once the anchor is signed.
> 2. The anchor transation can be malleated by either party before entering the blockchain, rendering the commitment input unusable.

The paper mentions mentions how problem 2 is not solved by BIP62, but does not talk about segregated witness. Are these two problems effectively solved with segregated witness?

**Tags:** lightning-network, segregated-witness, ln-opening-channels


---

## 1 answers

### Answer by username_1 on 2017-05-10. Score: 3 | Accepted answer

> Are these two problems effectively solved with segregated witness?

One is; one is not. Specifically:

> (1) The anchor transation id required for the commitment input will only be known once the anchor is signed.

Segwit fixes this. If the anchor transaction contains only segwit inputs, then its transaction identify (txid) does not change when signatures are added. This allows other transactions (such as the Lightning commitment transaction) to refer to its outputs regardless of whether or not it has been signed.

> (2) The anchor transaction can be malleated by either party before entering the blockchain, rendering the commitment input unusable.

Segwit does not fix this specific problem, but it does fix an important related problem. As the paper you cite says, "The last of these is particularly pernicious, as BIP62 doesn't solve it: signatories can always re-sign a transaction, hence altering its transaction ID."

The anchor transaction is created with inputs each user unilaterally controls (or shares control with a third-party to the Lightning channel currently being opened, an irrelevant detail to this discussion). Because of this, each user has the ability to create a full double spend of their part of the anchor transaction; if that double spend is what's included in the block chain, then any children of earlier versions of the transaction (such as the commitment transactions) are invalid.

The important related problem segwit does solve is useful to Lightning and required by other smart contract protocols. A payment in a payment channel (including Lightning) uses multisig to require both parties sign the payment under regular circumstances, called 2-of-2 multisig. Because signatures sign all of the non-signature data in a transaction (normal SIGHASH\_ALL) but are currently included when generating the txid, either party can unilaterally malleate a transaction by changing his signature.

But with segwit, all non-signature data in a transaction is still signed but the signatures are not covered by the txid, so neither party can unilaterally change the txid without invaliding the other party's (or parties) signature or signatures. In other words, it requires both 2-of-2 to change a txid or, more generically for m-of-n, segwit requires at least m participants to change the txid.

This simplifies the design of Lightning-style Hashed TimeLock Contracts (HTLCs) and also improves the privacy of outsourcing channel enforcement, but is not required for Lightning. However, it is required for some other smart contract protocols that use sequences of transactions. For example, a Spillman-style payment channel would be secure using segwit but today it is vulnerable to malleability.


---

