Research/Bitcoin Dev Archive / lightning-dev list
Payment channel without timeout protected from malleability
6 messages, Nov 27, 2015. Started by Nicolas Dorier.
Nicolas Dorier (3), Anthony Towns (2), Mats Jerratsch
By adapting an idea from gmaxwell ( https://bitcointalk.org/index.php?topic=303088.0) it is possible to open a channel without suffering from malleability attack.
The process for A to open channel with B is the following:
* A asks B pubkey * A create the first commitment transaction * A extract the hash that B needs to sign to be able to broadcast the commitment * A asks B to sign the hash, but do not disclose the commitment * A broadcast the anchor * After confirmation, A announce the anchor to B.
B can't identify A's anchor before announcement because he does not know the P2SH of the multisig.
Am I missing something ?
On Fri, Nov 27, 2015 at 04:37:04PM +0900, Nicolas Dorier wrote:
Quoted text (11 lines)
> By adapting an idea from gmaxwell ( > https://bitcointalk.org/index.php?topic=303088.0) it is possible to open a > channel without suffering from malleability attack. > The process for A to open channel with B is the following: > * A asks B pubkey > * A create the first commitment transaction > * A extract the hash that B needs to sign to be able to broadcast the > commitment > * A asks B to sign the hash, but do not disclose the commitment > * A broadcast the anchor > * After confirmation, A announce the anchor to B.
A also passes the original unsigned commitment to B, who verifies that it's in the right format (ie, can be revoked), and hashes to the hash that he signed.
Quoted text (3 lines)
> B can't identify A's anchor before announcement because he does not know > the P2SH of the multisig. > Am I missing something ?
Someone other than B (ie a third party) could malleate the anchor between broadcast and confirmation just for their own amusement.
B can't reuse pubkeys between different channels with this protocol either, but that's good practice anyway.
Quoted text (1 line)
>From the same forum post, using child-pays-for-parent seems plausible.
Doing:
txA: spend 6 BTC to
5 BTC to A&B
1 BTC to A
txB: spend 1 BTC from txA:1 to
0.999 BTC to A
should be pretty safe: either someone malleates txA and mines it for 0 fee; or they mine both txA+txB for 0.001 BTC fee, and txA can't be malleated. But CPFP doesn't work yet, and segregated witness seems like it'll happen sooner anyway?
Cheers, aj
Hm interesting.
Couple of remarks:
(1) 'without timeout' is only possible with OP_CSV - not naturally with what we have currently. ;)
(2) To be able to build a valid payment channel on top of the anchor, B has to be sure that A cannot get her money back at any point in the future. Given just a hash that B should sign, B has no clue what is the output of the transaction he just signed. But I guess we can solve this by B demanding the transaction he signed before proceeding to accept any payments. B can then reassure himself that this transaction indeed resolves to the hash he signed and that it is revocable by B with any following commitments. Beside the pubkey we also need some revocation hash provided by B for creating the commitment transaction.
(3) While this is a fair setup already, it does only protect us against targeted attacks against a specific transaction. An attacker could still mine a block with all P2SH transactions (probably not even that many) changed. If you have a large amount of hashing power, you can open up channels with hundreds of parties and then start attacking the network. It can be mitigated by waiting some time before broadcasting his anchor, but even then it remains some hack, and theres some chance someone will lose money doing that.
2015-11-27 8:37 GMT+01:00 Nicolas Dorier <nicolas.dorier at gmail.com>:
Quoted text (24 lines)
> By adapting an idea from gmaxwell > (https://bitcointalk.org/index.php?topic=303088.0) it is possible to open a > channel without suffering from malleability attack. > > The process for A to open channel with B is the following: > > * A asks B pubkey > * A create the first commitment transaction > * A extract the hash that B needs to sign to be able to broadcast the > commitment > * A asks B to sign the hash, but do not disclose the commitment > * A broadcast the anchor > * After confirmation, A announce the anchor to B. > > B can't identify A's anchor before announcement because he does not know the > P2SH of the multisig. > > Am I missing something ? > > _______________________________________________ > Lightning-dev mailing list > Lightning-dev at lists.linuxfoundation.org > https://www.learnbitcoin.com/archive/lists/lightning-dev >
Quoted text (3 lines)
> A also passes the original unsigned commitment to B, who verifies that > it's in the right format (ie, can be revoked), and hashes to the hash > that he signed.
No, if A pass the unsigned commitment to B then B can malleate the anchor. (because B would know the txid of the anchor at broadcast time) B does not have to verify it is in right format, because he does not have anything to loose by signing a random hash. B can verify he signed the hash of the first commitment after A announce his already confirmed anchor.
Quoted text (2 lines)
> Someone other than B (ie a third party) could malleate the anchor between > broadcast and confirmation just for their own amusement.
Yes, actually the only malleability vector which B can use to his advantage is HighS, not all BIP62 vectors. Knowing miners will most likely run at least 0.11.2 (if CLTV is acceepted) HighS should be more likely rejected.
Quoted text (2 lines)
> B can't reuse pubkeys between different channels with this protocol > either, but that's good practice anyway.
Right, neither A should. If A reuse a key, then B can guess the redeem hash, then would identify the transaction to malleate at broadcast time, before A's announcement.
I'd prefer seggregated witness to fix the problem cleanly, but I think that opening the channel as I said is a good enough workaround until it happen. The only attack B can try is malleate all transaction to HighS. When CLTV will pass, there is not lot of probability of such attack to succeed, because bitcoind should block HighS.
Quoted text (2 lines)
> 'without timeout' is only possible with OP_CSV - not naturally with what we have currently. ;)
The anchor does not have to use OP_CSV at all. But yes, for commitment, I'm assuming OP_CSV passed.
Quoted text (4 lines)
> To be able to build a valid payment channel on top of the anchor, B has to be sure that A cannot get her money back at any point in the future. Given just a hash that B should sign, B has no clue what is the output of the transaction he just signed.
Actually B do not care about it. Remember I am separating "A's anchor broadcast" from "A's announcement of anchor to B". When A announce the anchor, then B can check if he really signed the first commitment or something else, but he can't malleate anything since the anchor is already confirmed. B does not have anything to loose by signing unknown hash. (if he use a non reusable key)
Again, yes, a network-wide HighS attack would be the only way to malleate the anchor. If CLTV fork pass, then it is fair to consider that the odd of such attack succeeding is very low. HighS should be blocked from 0.11.1 if I remember well.
On Fri, Nov 27, 2015 at 6:09 PM, Anthony Towns <aj at erisian.com.au> wrote:
Quoted text (47 lines)
> On Fri, Nov 27, 2015 at 04:37:04PM +0900, Nicolas Dorier wrote: > > By adapting an idea from gmaxwell ( > > https://bitcointalk.org/index.php?topic=303088.0) it is possible to > open a > > channel without suffering from malleability attack. > > The process for A to open channel with B is the following: > > * A asks B pubkey > > * A create the first commitment transaction > > * A extract the hash that B needs to sign to be able to broadcast the > > commitment > > * A asks B to sign the hash, but do not disclose the commitment > > * A broadcast the anchor > > * After confirmation, A announce the anchor to B. > > A also passes the original unsigned commitment to B, who verifies that > it's in the right format (ie, can be revoked), and hashes to the hash > that he signed. > > > B can't identify A's anchor before announcement because he does not know > > the P2SH of the multisig. > > Am I missing something ? > > Someone other than B (ie a third party) could malleate the anchor between > broadcast and confirmation just for their own amusement. > > B can't reuse pubkeys between different channels with this protocol > either, but that's good practice anyway. > > From the same forum post, using child-pays-for-parent seems plausible. > Doing: > > txA: spend 6 BTC to > 5 BTC to A&B > 1 BTC to A > > txB: spend 1 BTC from txA:1 to > 0.999 BTC to A > > should be pretty safe: either someone malleates txA and mines it for > 0 fee; or they mine both txA+txB for 0.001 BTC fee, and txA can't be > malleated. But CPFP doesn't work yet, and segregated witness seems like > it'll happen sooner anyway? > > Cheers, > aj > >
On Sat, Nov 28, 2015 at 01:18:21AM +0900, Nicolas Dorier wrote:
Quoted text (4 lines)
> > A also passes the original unsigned commitment to B, who verifies that > > it's in the right format (ie, can be revoked), and hashes to the hash > > that he signed. > No, if A pass the unsigned commitment to B then B can malleate the anchor.
Sorry, I meant the above needs to happen after the anchor's confirmed in the blockchain (and A's told B about the anchor).
Quoted text (5 lines)
> > B can't reuse pubkeys between different channels with this protocol > > either, but that's good practice anyway. > Right, neither A should. If A reuse a key, then B can guess the redeem > hash, then would identify the transaction to malleate at broadcast time, > before A's announcement.
B will be providing a signature for a tx that:
- has the anchor as input
- has a single refund output payable to
(A && OP_CSV) | (B && OP_HASH <revoke> OP_EQUALVERIFY)
But B won't be able to guess what the <revoke> hash is, so won't be able to correlate with potential anchor transactions at all, afaics, even if pubkeys <A> and <B> are both known to B?
Quoted text (2 lines)
> I'd prefer seggregated witness to fix the problem cleanly, but I think that > opening the channel as I said is a good enough workaround until it happen.
Yeah, it's 99% of the way there; I just worry about random vandalism, personally.
Cheers, aj
Quoted text (3 lines)
> But B won't be able to guess what the <revoke> hash is, so won't be > able to correlate with potential anchor transactions at all, afaics, > even if pubkeys <A> and <B> are both known to B?
Did not thought about that, yes you are right.
Quoted text (2 lines)
> Yeah, it's 99% of the way there; I just worry about random vandalism, > personally.
Yes, I was worrying about B pro actively malleating everything. But since A controls broadcast time, he can choose to delay the broadcast when a vast malleability attack happens.
On Sat, Nov 28, 2015 at 5:11 AM, Anthony Towns <aj at erisian.com.au> wrote:
Quoted text (38 lines)
> On Sat, Nov 28, 2015 at 01:18:21AM +0900, Nicolas Dorier wrote: > > > A also passes the original unsigned commitment to B, who verifies that > > > it's in the right format (ie, can be revoked), and hashes to the hash > > > that he signed. > > No, if A pass the unsigned commitment to B then B can malleate the > anchor. > > Sorry, I meant the above needs to happen after the anchor's confirmed > in the blockchain (and A's told B about the anchor). > > > > B can't reuse pubkeys between different channels with this protocol > > > either, but that's good practice anyway. > > Right, neither A should. If A reuse a key, then B can guess the redeem > > hash, then would identify the transaction to malleate at broadcast time, > > before A's announcement. > > B will be providing a signature for a tx that: > > - has the anchor as input > - has a single refund output payable to > (A && OP_CSV) | (B && OP_HASH <revoke> OP_EQUALVERIFY) > > But B won't be able to guess what the <revoke> hash is, so won't be > able to correlate with potential anchor transactions at all, afaics, > even if pubkeys <A> and <B> are both known to B? > > > I'd prefer seggregated witness to fix the problem cleanly, but I think > that > > opening the channel as I said is a good enough workaround until it > happen. > > Yeah, it's 99% of the way there; I just worry about random vandalism, > personally. > > Cheers, > aj > >