Research/Bitcoin Dev Archive / lightning-dev list
DRAFT: interactive tx construction protocol
26 messages, Jan 28 to Feb 20, 2020. Started by lisa neigut.
ZmnSCPxj (8), lisa neigut (7), Antoine Poinsot (6), Antoine Riard (3), Rusty Russell (2)
Some of the feedback I received from the check-in for the dual-funding proposal this past Monday was along the lines that we look at simplifying for breaking it into smaller, more manageable chunks.
The biggest piece of the dual-funding protocol update is definitely the move from a single peer constructing a transaction to two participants. We're also going to likely want to reuse this portion of the protocol for batched closings and splicing. To that extent, it seemed useful to highlight it in a separate email.
This is a change from the existing proposal in the dual-funding PR #524 <https://github.com/lightningnetwork/lightning-rfc/pull/524> -- it allows for the removal of inputs and outputs.
The set of messages are as follows.
Note that the 'initiation' of this protocol will be different depending on the case of the transaction (open, close or splice):
1. type: 440 `tx_add_input`
2. data:
* [`32*byte`:`channel_identifier`]
* [`u64`:`sats`]
* [`sha256`:`prevtx_txid`]
* [`u32`:`prevtx_vout`]
* [`u16`:`prevtx_scriptpubkey_len`]
* [`prevtx_scriptpubkey_len*byte`:`prevtx_scriptpubkey`]
* [`u16`:`max_witness_len`]
* [`u16`:`scriptlen`]
* [`scriptlen*byte`:`script`]
* [`byte`:`signal_rbf`]
1. type: 442 `tx_add_output`
2. data:
* [`32*byte`:`channel_identifier`]
* [`u64`:`sats`]
* [`u16`:`scriptlen`]
* [`scriptlen*byte`:`script`]
1. type: 444 `tx_remove_input`
2. data:
* [`32*byte`:`channel_identifier`]
* [`sha256`:`prevtx_txid`]
* [`u32`:`prevtx_vout`]
1. type: 446 `tx_remove_output`
2. data:
* [`32*byte`:`channel_identifier`]
* [`u64`:`sats`]
* [`u16`:`scriptlen`]
* [`scriptlen*byte`:`script`]
1. type: 448 `tx_complete`
2. data:
* [`32*byte`:`channel_identifier`]
* [`u16`:`num_inputs`]
* [`u16`:`num_outputs`]
1. type: 448 `tx_sigs`
2. data:
* [`channel_id`:`channel_identifier`]
* [`u16`:`num_witnesses`]
* [`num_witnesses*witness_stack`:`witness_stack`]
1. subtype: `witness_stack`
2. data:
* [`sha256`:`prevtx_txid`]
* [`u32`:`prevtx_vout`]
* [`u16`:`num_input_witness`]
* [`num_input_witness*witness_element`:`witness_element`]
1. subtype: `witness_element`
2. data:
* [`u16`:`len`]
* [`len*byte`:`witness`]
## General Notes
- Validity of inputs/outputs is not checked until both peers have sent consecutive `tx_complete` messages.
- Duplicate inputs or outputs is a protocol error.
- Feerate is set by the initiator, or in the case of a closing transaction, negotiated before the transaction construction is initiated.
- Every peer pays fees for the inputs + outputs they contribute, plus enough to cover the maximum estimate of their witnesses. Overpayment of fees is permissible.
- Initiator is responsible for contributing the output/input in question, i.e. the
funding output in the case of an opening, or the funding input in the case of a close.
(This means that the opener will pay for the opening output). In the case of a splice,
the initiator of the splice pays for the funding tx's inclusion as an input and the
new 'funding tx' output.
- Any contributor may signal that their input is RBF'able. The nSequence for this input should be set to 0xFEFF FFFF, 0xFFFFFFFF otherwise.
- The initiating peer is understood to be paying the fee for the shared transaction fields (nVersion [4], segwit marker + flag [2], input + output counts [2-18], witness count [1-9], nLocktime [4]; total [13-40bytes])
- Inputs MUST be segwit compatible (PW* or P2SH-PW*)
- All output scripts must be standard
- nLocktime is always set to 0x00000000.
- The `num_inputs` and `num_outputs` in `tx_complete` is a count of that peer’s final input and output contributions, net any removals.
- Either peer may add or remove inputs and outputs until both peers have successfully
exchanged a `tx_complete` message in succession.
- Either peer may only add or remove their own input or output.
- In the case that a `tx_complete` agreement cannot be reached, either peer may
fail the channel or open protocol (whatever is reasonable for the particular case)
- In the case of a splice, this would be a soft error (channel returns to normal operation until
otherwise failed or closed.)
- In the case of an open, this would be a failure to open the channel.
- In the case of a close, a failed collaborative close would result in an error and a unilateral close.
### Considering the Simple Open case (2 parties)
- Both peers signal `opt_dual_fund`
- Opener initiates a channel open with `open_channel2` message, indicating the feerate for the opening transaction
- Accepter signals acceptance of channel open as proposed, including proposed feerate, via `accept_channel2`
- Opener sends `tx_add_output`, with the funding output for the sum of both peer’s funding_amount
- Opener sends `tx_add_input` for each input the wish to add to the funding transaction
- Opener sends `tx_add_output` for their change
- Opener sends `tx_complete`
- Accepter sends `tx_add_input` for each input they wish to add to the funding transaction
- Accepter sends `tx_add_output` for their change.
- Accepter sends `tx_complete`
- Opener sends `tx_complete`
- Opener and accepter exchange commitment signatures; etc.
### Considering the Splice case:
- Both peers signal `opt_splice_ok`
- One peer initiates a splice, also signaling the feerate for the transaction. Exact protocol unspecified herein.
- Initiator sends `tx_add_input` with the original funding output
- Initiator sends `tx_add_output` with the new, post-splice funding output
- Initiator sends `tx_add_input/output` as needed to add all desired inputs + outputs
- Initiator sends `tx_complete`
- Peer sends `tx_add_input/output` as needed to add all desired inputs + outputs
- Initiator sends `tx_complete`
- Peer sends `tx_complete`
- Initiator + peer exchange commitment signatures, etc.
### Considering the Close case:
- Both peers signal `opt_collaborative_close` in their `node_announcement`.
- A peer initiates a close sending a `shutdown`, as per usual.
- A feerate is negotiated. Out of band for this particular portion of the protocol.
-The closing initiator (peer which first sent `shutdown`), sends `tx_add_input` to spend the funding output and `tx_add_output` to add their output for the channel closure.
- The peer responds with `tx_add_output`, adding their output to the close transaction.
- If `option_upfront_shutdown_script` is flagged but no such output with a value at or within a reasonable feerate gap of the peer's funding output is present, then the peer must fail the channel.
## Updating a collaborative transaction with RBF:
- If any input is flagged as RBF’able, then the transaction is considered eligible for RBF
- RBF can be initiated by either party, and serves as an initiation for another round of transaction composition, as outlined above.
- Note that this section has been cribbed and re-purposed from the original RBF proposal for splicing, see https://www.learnbitcoin.com/archive/lists/lightning-dev/t/2018/splicing-proposal-now-with-rbf#m-41bd6437
1. type: 45 (`init_rbf`) (`option_collaborative_rbf`)
2. data:
* [`32`:`channel_id`]
* [`4`:`fee_step`]
Each `fee_step` adds 1/4 (rounded down) to the initial
transaction feerate. eg. if the initial feerate was 512 satoshis per kiloweight, `fee_step` 1
is 512 + 512 / 4 = 640, `fee_step` 2 is 640 + 640 / 4 = 800.
The sender:
- MUST set `fee_step` greater than zero and greater than any prior `fee_step`.
The recipient:
- if the new fee exceeds the sender's current balance minus reserve
after it is applied to the splice transaction:
- MUST error.
NOTES:
1. 1/4 is a reasonable minimal RBF, but as each one requires more
tracking by the recipient, serves to limit the number you can create.
2. Rule 4 of BIP125 requires a feerate increase to at least surpass the minimum transaction relay setting. Ratcheting by 25% should satisfy this requirement
3. An additional rule will be added to the checks of an RBF transaction that it must include at least one identical, replaceable input as the original transaction.
Hey thanks for this proposal!
2 high-level questions:
What about multi-party tx construction ? By multi-party, let's define Alice initiate a tx construction to Bob and then Bob announce a construction to Caroll and "bridge" all inputs/outputs additions/substractions in both directions. I think the current proposal hold, if you are a bit more tolerant and bridge peer don't send a tx_complete before receiving ones from all its peers.
What about transactions format ? I think we should coordinate with Coinjoin people to converge to a common one to avoid leaking protocol usage when we can hinder under Taproot. Like setting the nLocktime or sorting inputs in some protocol-specific fashion. Ideally we should have a BIP for format but every layer 2 protocols its own set of messages concerning the construction.
Quoted text (1 line)
> nLocktime is always set to 0x000000
Maybe we can implement anti-fee sniping and mask among wallet core txn set: https://github.com/bitcoin/bitcoin/blob/aabec94541e23a67a9f30dc2c80dab3383a01737/src/wallet/wallet.cpp#L2519 ?
Quoted text (1 line)
> In the case of a close, a failed collaborative close would result in an
error and a uninlateral close" Or can we do first a mutual closing tx, hold tx broadcast for a bit if "opt_dual_fund" is signaled to see if a tx_construction + add_funding_input for the channel is received soon ? At least that would be a dual opt-in to know than one party can submit a funding-outpoint as part of a composed tx ?
Antoine
Le lun. 27 janv. 2020 à 20:51, lisa neigut <niftynei at gmail.com> a écrit :
Quoted text (325 lines)
> Some of the feedback I received from the check-in for the dual-funding > proposal this past Monday was along the lines that we look at simplifying > for breaking it into smaller, more manageable chunks. > > The biggest piece of the dual-funding protocol update is definitely the > move from a single peer constructing a transaction to two participants. > We're also going to likely want to reuse this portion of the protocol for > batched closings and splicing. To that extent, it seemed useful to > highlight it in a separate email. > > This is a change from the existing proposal in the dual-funding PR #524 > <https://github.com/lightningnetwork/lightning-rfc/pull/524> -- it allows > for the removal of inputs and outputs. > > The set of messages are as follows. > > > Note that the 'initiation' of this protocol will be different depending > on the case of the transaction (open, close or splice): > > 1. type: 440 `tx_add_input` > > 2. data: > > * [`32*byte`:`channel_identifier`] > > * [`u64`:`sats`] > > * [`sha256`:`prevtx_txid`] > > * [`u32`:`prevtx_vout`] > > * [`u16`:`prevtx_scriptpubkey_len`] > > * [`prevtx_scriptpubkey_len*byte`:`prevtx_scriptpubkey`] > > * [`u16`:`max_witness_len`] > > * [`u16`:`scriptlen`] > > * [`scriptlen*byte`:`script`] > > * [`byte`:`signal_rbf`] > > 1. type: 442 `tx_add_output` > > 2. data: > > * [`32*byte`:`channel_identifier`] > > * [`u64`:`sats`] > > * [`u16`:`scriptlen`] > > * [`scriptlen*byte`:`script`] > > 1. type: 444 `tx_remove_input` > > 2. data: > > * [`32*byte`:`channel_identifier`] > > * [`sha256`:`prevtx_txid`] > > * [`u32`:`prevtx_vout`] > > 1. type: 446 `tx_remove_output` > > 2. data: > > * [`32*byte`:`channel_identifier`] > > * [`u64`:`sats`] > > * [`u16`:`scriptlen`] > > * [`scriptlen*byte`:`script`] > > 1. type: 448 `tx_complete` > > 2. data: > > * [`32*byte`:`channel_identifier`] > > * [`u16`:`num_inputs`] > > * [`u16`:`num_outputs`] > > 1. type: 448 `tx_sigs` > > 2. data: > > * [`channel_id`:`channel_identifier`] > > * [`u16`:`num_witnesses`] > > * [`num_witnesses*witness_stack`:`witness_stack`] > > 1. subtype: `witness_stack` > > 2. data: > > * [`sha256`:`prevtx_txid`] > > * [`u32`:`prevtx_vout`] > > * [`u16`:`num_input_witness`] > > * [`num_input_witness*witness_element`:`witness_element`] > > 1. subtype: `witness_element` > > 2. data: > > * [`u16`:`len`] > > * [`len*byte`:`witness`] > > > > ## General Notes > > - Validity of inputs/outputs is not checked until both peers have sent > consecutive `tx_complete` messages. > > - Duplicate inputs or outputs is a protocol error. > > - Feerate is set by the initiator, or in the case of a closing > transaction, negotiated before the transaction construction is initiated. > > - Every peer pays fees for the inputs + outputs they contribute, plus > enough to cover the maximum estimate of their witnesses. Overpayment of > fees is permissible. > > - Initiator is responsible for contributing the output/input in question, > i.e. the > > funding output in the case of an opening, or the funding input in the > case of a close. > > (This means that the opener will pay for the opening output). In the > case of a splice, > > the initiator of the splice pays for the funding tx's inclusion as an > input and the > > new 'funding tx' output. > > - Any contributor may signal that their input is RBF'able. The nSequence > for this input should be set to 0xFEFF FFFF, 0xFFFFFFFF otherwise. > > - The initiating peer is understood to be paying the fee for the shared > transaction fields (nVersion [4], segwit marker + flag [2], input + output > counts [2-18], witness count [1-9], nLocktime [4]; total [13-40bytes]) > > - Inputs MUST be segwit compatible (PW* or P2SH-PW*) > > - All output scripts must be standard > > - nLocktime is always set to 0x00000000. > > - The `num_inputs` and `num_outputs` in `tx_complete` is a count of that > peer’s final input and output contributions, net any removals. > > - Either peer may add or remove inputs and outputs until both peers have > successfully > > exchanged a `tx_complete` message in succession. > > - Either peer may only add or remove their own input or output. > > - In the case that a `tx_complete` agreement cannot be reached, either > peer may > > fail the channel or open protocol (whatever is reasonable for the > particular case) > > - In the case of a splice, this would be a soft error (channel returns > to normal operation until > > otherwise failed or closed.) > > - In the case of an open, this would be a failure to open the channel. > > - In the case of a close, a failed collaborative close would result in > an error and a unilateral close. > > ### Considering the Simple Open case (2 parties) > > - Both peers signal `opt_dual_fund` > > - Opener initiates a channel open with `open_channel2` message, indicating > the feerate for the opening transaction > > - Accepter signals acceptance of channel open as proposed, including > proposed feerate, via `accept_channel2` > > - Opener sends `tx_add_output`, with the funding output for the sum of > both peer’s funding_amount > > - Opener sends `tx_add_input` for each input the wish to add to the > funding transaction > > - Opener sends `tx_add_output` for their change > > - Opener sends `tx_complete` > > - Accepter sends `tx_add_input` for each input they wish to add to the > funding transaction > > - Accepter sends `tx_add_output` for their change. > > - Accepter sends `tx_complete` > > - Opener sends `tx_complete` > > - Opener and accepter exchange commitment signatures; etc. > > ### Considering the Splice case: > > - Both peers signal `opt_splice_ok` > > - One peer initiates a splice, also signaling the feerate for the > transaction. Exact protocol unspecified herein. > > - Initiator sends `tx_add_input` with the original funding output > > - Initiator sends `tx_add_output` with the new, post-splice funding output > > - Initiator sends `tx_add_input/output` as needed to add all desired > inputs + outputs > > - Initiator sends `tx_complete` > > - Peer sends `tx_add_input/output` as needed to add all desired inputs + > outputs > > - Initiator sends `tx_complete` > > - Peer sends `tx_complete` > > - Initiator + peer exchange commitment signatures, etc. > > ### Considering the Close case: > > - Both peers signal `opt_collaborative_close` in their `node_announcement`. > > - A peer initiates a close sending a `shutdown`, as per usual. > > - A feerate is negotiated. Out of band for this particular portion of the > protocol. > > -The closing initiator (peer which first sent `shutdown`), sends > `tx_add_input` to spend the funding output and `tx_add_output` to add their > output for the channel closure. > > - The peer responds with `tx_add_output`, adding their output to the close > transaction. > > - If `option_upfront_shutdown_script` is flagged but no such output with a > value at or within a reasonable feerate gap of the peer's funding output is > present, then the peer must fail the channel. > > > ## Updating a collaborative transaction with RBF: > > - If any input is flagged as RBF’able, then the transaction is considered > eligible for RBF > > - RBF can be initiated by either party, and serves as an initiation for > another round of transaction composition, as outlined above. > > - Note that this section has been cribbed and re-purposed from the > original RBF proposal for splicing, see > https://www.learnbitcoin.com/archive/lists/lightning-dev/t/2018/splicing-proposal-now-with-rbf#m-41bd6437 > > 1. type: 45 (`init_rbf`) (`option_collaborative_rbf`) > > 2. data: > > * [`32`:`channel_id`] > > * [`4`:`fee_step`] > > Each `fee_step` adds 1/4 (rounded down) to the initial > > transaction feerate. eg. if the initial feerate was 512 satoshis per > kiloweight, `fee_step` 1 > > is 512 + 512 / 4 = 640, `fee_step` 2 is 640 + 640 / 4 = 800. > > The sender: > > - MUST set `fee_step` greater than zero and greater than any prior > `fee_step`. > > The recipient: > > - if the new fee exceeds the sender's current balance minus reserve > > after it is applied to the splice transaction: > > - MUST error. > > > > NOTES: > > 1. 1/4 is a reasonable minimal RBF, but as each one requires more > > tracking by the recipient, serves to limit the number you can create. > > 2. Rule 4 of BIP125 requires a feerate increase to at least surpass the > minimum transaction relay setting. Ratcheting by 25% should satisfy this > requirement > > 3. An additional rule will be added to the checks of an RBF transaction > that it must include at least one identical, replaceable input as the > original transaction. > > _______________________________________________ > Lightning-dev mailing list > Lightning-dev at lists.linuxfoundation.org > https://www.learnbitcoin.com/archive/lists/lightning-dev >
Hi Antoine and all,
About nLockTime fun thing is Lisa, Cdecker and I had this conversation to integrate it to C-lightning just yesterday.
Unfortunately you need to add a "My tip is xxxx" to the openchannel msg, otherwise if you set nLockTime to tip. (cdecker)
Moreover in case of reorg the funding tx (now non-final) would be dropped from mempool ? But you could set nLockTime to, say, tip - 6. (niftynei)
Antoine
\-------- Original Message -------- On Jan 30, 2020, 01:21, Antoine Riard < antoine.riard at gmail.com> wrote:
Quoted text (411 lines)
> > > > Hey thanks for this proposal! > > > > 2 high-level questions: > > > > > > What about multi-party tx construction ? By multi-party, let's define > > Alice initiate a tx construction to Bob and then Bob announce a > > > construction to Caroll and "bridge" all inputs/outputs additions/substractions > > > in both directions. I think the current proposal hold, if you are a bit more > > > tolerant and bridge peer don't send a tx\_complete before receiving ones > > > from all its peers. > > > > > > What about transactions format ? I think we should coordinate with Coinjoin > > > people to converge to a common one to avoid leaking protocol usage when > we can hinder under Taproot. Like setting the nLocktime or sorting inputs > > > in some protocol-specific fashion. Ideally we should have a BIP for format > > > but every layer 2 protocols its own set of messages concerning the construction. > > > nLocktime is always set to 0x000000 > Maybe we can implement anti-fee sniping and mask among wallet core > txn set: [https://github.com/bitcoin/bitcoin/blob/aabec94541e23a67a9f30dc2c80dab3383a01737/src/wallet/wallet.cpp\#L2519][https_github.com_bitcoin_bitcoin_blob_aabec94541e23a67a9f30dc2c80dab3383a01737_src_wallet_wallet.cpp_L2519] ? > > > In the case of a close, a failed collaborative close would result in an error and a uninlateral close" > Or can we do first a mutual closing tx, hold tx broadcast for a bit if "opt\_dual\_fund" > is signaled to see if a tx\_construction + add\_funding\_input for the channel is received > soon ? At least that would be a dual opt-in to know than one party can submit a funding-outpoint > as part of a composed tx ? > > > > > Antoine > > > > > > Le lun. 27 janv. 2020 à 20:51, lisa neigut <[niftynei at gmail.com][niftynei_gmail.com]> a écrit : > > > > Some of the feedback I received from the check-in for the dual-funding proposal this past Monday was along the lines that we look at simplifying for breaking it into smaller, more manageable chunks. > > > > > > > > > > The biggest piece of the dual-funding protocol update is definitely the move from a single peer constructing a transaction to two participants. We're also going to likely want to reuse this portion of the protocol for batched closings and splicing. To that extent, it seemed useful to highlight it in a separate email. > > > > > > > > > > This is a change from the existing proposal in the dual-funding [PR \#524][PR _524] \-- it allows for the removal of inputs and outputs. > > > > > > > > > > The set of messages are as follows. > > > > > > > > > > Note that the 'initiation' of this protocol will be different depending on the case of the transaction (open, close or splice): > > > > > > > > > > 1. type: 440 \`tx\_add\_input\` > > > > 2. data: > > > > \* \[\`32\*byte\`:\`channel\_identifier\`\] > > > > \* \[\`u64\`:\`sats\`\] > > > > \* \[\`sha256\`:\`prevtx\_txid\`\] > > > > \* \[\`u32\`:\`prevtx\_vout\`\] > > > > \* \[\`u16\`:\`prevtx\_scriptpubkey\_len\`\] > > > > \* \[\`prevtx\_scriptpubkey\_len\*byte\`:\`prevtx\_scriptpubkey\`\] > > > > \* \[\`u16\`:\`max\_witness\_len\`\] > > > > \* \[\`u16\`:\`scriptlen\`\] > > > > \* \[\`scriptlen\*byte\`:\`script\`\] > > > > \* \[\`byte\`:\`signal\_rbf\`\] > > > > > > > > > > 1. type: 442 \`tx\_add\_output\` > > > > 2. data: > > > > \* \[\`32\*byte\`:\`channel\_identifier\`\] > > > > \* \[\`u64\`:\`sats\`\] > > > > \* \[\`u16\`:\`scriptlen\`\] > > > > \* \[\`scriptlen\*byte\`:\`script\`\] > > > > > > > > > > 1. type: 444 \`tx\_remove\_input\` > > > > 2. data: > > > > \* \[\`32\*byte\`:\`channel\_identifier\`\] > > > > \* \[\`sha256\`:\`prevtx\_txid\`\] > > > > \* \[\`u32\`:\`prevtx\_vout\`\] > > > > > > > > > > 1. type: 446 \`tx\_remove\_output\` > > > > 2. data: > > > > \* \[\`32\*byte\`:\`channel\_identifier\`\] > > > > \* \[\`u64\`:\`sats\`\] > > > > \* \[\`u16\`:\`scriptlen\`\] > > > > \* \[\`scriptlen\*byte\`:\`script\`\] > > > > > > > > > > 1. type: 448 \`tx\_complete\` > > > > 2. data: > > > > \* \[\`32\*byte\`:\`channel\_identifier\`\] > > > > \* \[\`u16\`:\`num\_inputs\`\] > > > > \* \[\`u16\`:\`num\_outputs\`\] > > > > > > > > > > 1. type: 448 \`tx\_sigs\` > > > > 2. data: > > > > \* \[\`channel\_id\`:\`channel\_identifier\`\] > > > > \* \[\`u16\`:\`num\_witnesses\`\] > > > > \* \[\`num\_witnesses\*witness\_stack\`:\`witness\_stack\`\] > > > > > > > > > > 1. subtype: \`witness\_stack\` > > > > 2. data: > > > > \* \[\`sha256\`:\`prevtx\_txid\`\] > > > > \* \[\`u32\`:\`prevtx\_vout\`\] > > > > \* \[\`u16\`:\`num\_input\_witness\`\] > > > > \* \[\`num\_input\_witness\*witness\_element\`:\`witness\_element\`\] > > > > > > > > > > 1. subtype: \`witness\_element\` > > > > 2. data: > > > > \* \[\`u16\`:\`len\`\] > > > > \* \[\`len\*byte\`:\`witness\`\] > > > > > > > > > > > > > > > > \#\# General Notes > > > > \- Validity of inputs/outputs is not checked until both peers have sent consecutive \`tx\_complete\` messages. > > > > \- Duplicate inputs or outputs is a protocol error. > > > > \- Feerate is set by the initiator, or in the case of a closing transaction, negotiated before the transaction construction is initiated. > > > > \- Every peer pays fees for the inputs + outputs they contribute, plus enough to cover the maximum estimate of their witnesses. Overpayment of fees is permissible. > > > > \- Initiator is responsible for contributing the output/input in question, i.e. the > > > > funding output in the case of an opening, or the funding input in the case of a close. > > > > (This means that the opener will pay for the opening output). In the case of a splice, > > > > the initiator of the splice pays for the funding tx's inclusion as an input and the > > > > new 'funding tx' output. > > > > \- Any contributor may signal that their input is RBF'able. The nSequence for this input should be set to 0xFEFF FFFF, 0xFFFFFFFF otherwise. > > > > \- The initiating peer is understood to be paying the fee for the shared transaction fields (nVersion \[4\], segwit marker + flag \[2\], input + output counts \[2-18\], witness count \[1-9\], nLocktime \[4\]; total \[13-40bytes\]) > > > > \- Inputs MUST be segwit compatible (PW\* or P2SH-PW\*) > > > > \- All output scripts must be standard > > > > \- nLocktime is always set to 0x00000000. > > > > \- The \`num\_inputs\` and \`num\_outputs\` in \`tx\_complete\` is a count of that peer’s final input and output contributions, net any removals. > > > > > > > > > > \- Either peer may add or remove inputs and outputs until both peers have successfully > > > > exchanged a \`tx\_complete\` message in succession. > > > > \- Either peer may only add or remove their own input or output. > > > > \- In the case that a \`tx\_complete\` agreement cannot be reached, either peer may > > > > fail the channel or open protocol (whatever is reasonable for the particular case) > > > > - In the case of a splice, this would be a soft error (channel returns to normal operation until > > > > otherwise failed or closed.) > > > > - In the case of an open, this would be a failure to open the channel. > > > > - In the case of a close, a failed collaborative close would result in an error and a unilateral close. > > > > > > > > > > \#\#\# Considering the Simple Open case (2 parties) > > > > \- Both peers signal \`opt\_dual\_fund\` > > > > \- Opener initiates a channel open with \`open\_channel2\` message, indicating the feerate for the opening transaction > > > > \- Accepter signals acceptance of channel open as proposed, including proposed feerate, via \`accept\_channel2\` > > > > \- Opener sends \`tx\_add\_output\`, with the funding output for the sum of both peer’s funding\_amount > > > > \- Opener sends \`tx\_add\_input\` for each input the wish to add to the funding transaction > > > > \- Opener sends \`tx\_add\_output\` for their change > > > > \- Opener sends \`tx\_complete\` > > > > \- Accepter sends \`tx\_add\_input\` for each input they wish to add to the funding transaction > > > > \- Accepter sends \`tx\_add\_output\` for their change. > > > > \- Accepter sends \`tx\_complete\` > > > > \- Opener sends \`tx\_complete\` > > > > \- Opener and accepter exchange commitment signatures; etc. > > > > > > > > > > \#\#\# Considering the Splice case: > > > > \- Both peers signal \`opt\_splice\_ok\` > > > > \- One peer initiates a splice, also signaling the feerate for the transaction. Exact protocol unspecified herein. > > > > \- Initiator sends \`tx\_add\_input\` with the original funding output > > > > \- Initiator sends \`tx\_add\_output\` with the new, post-splice funding output > > > > \- Initiator sends \`tx\_add\_input/output\` as needed to add all desired inputs + outputs > > > > \- Initiator sends \`tx\_complete\` > > > > \- Peer sends \`tx\_add\_input/output\` as needed to add all desired inputs + outputs > > > > \- Initiator sends \`tx\_complete\` > > > > \- Peer sends \`tx\_complete\` > > > > \- Initiator + peer exchange commitment signatures, etc. > > > > > > > > > > \#\#\# Considering the Close case: > > > > \- Both peers signal \`opt\_collaborative\_close\` in their \`node\_announcement\`. > > > > \- A peer initiates a close sending a \`shutdown\`, as per usual. > > > > \- A feerate is negotiated. Out of band for this particular portion of the protocol. > > > > \-The closing initiator (peer which first sent \`shutdown\`), sends \`tx\_add\_input\` to spend the funding output and \`tx\_add\_output\` to add their output for the channel closure. > > > > \- The peer responds with \`tx\_add\_output\`, adding their output to the close transaction. > > > > \- If \`option\_upfront\_shutdown\_script\` is flagged but no such output with a value at or within a reasonable feerate gap of the peer's funding output is present, then the peer must fail the channel. > > > > > > > > > > > > \#\# Updating a collaborative transaction with RBF: > > > > \- If any input is flagged as RBF’able, then the transaction is considered eligible for RBF > > > > \- RBF can be initiated by either party, and serves as an initiation for another round of transaction composition, as outlined above. > > > > \- Note that this section has been cribbed and re-purposed from the original RBF proposal for splicing, see https://www.learnbitcoin.com/archive/lists/lightning-dev/t/2018/splicing-proposal-now-with-rbf#m-41bd6437 > > > > > > > > > > 1. type: 45 (\`init\_rbf\`) (\`option\_collaborative\_rbf\`) > > > > 2. data: > > > > \* \[\`32\`:\`channel\_id\`\] > > > > \* \[\`4\`:\`fee\_step\`\] > > > > > > > > > > Each \`fee\_step\` adds 1/4 (rounded down) to the initial > > > > transaction feerate. eg. if the initial feerate was 512 satoshis per kiloweight, \`fee\_step\` 1 > > > > is 512 + 512 / 4 = 640, \`fee\_step\` 2 is 640 + 640 / 4 = 800. > > > > > > > > > > The sender: > > > > - MUST set \`fee\_step\` greater than zero and greater than any prior \`fee\_step\`. > > > > > > > > > > The recipient: > > > > - if the new fee exceeds the sender's current balance minus reserve > > > > after it is applied to the splice transaction: > > > > - MUST error. > > > > > > > > NOTES: > > > > 1. 1/4 is a reasonable minimal RBF, but as each one requires more > > > > tracking by the recipient, serves to limit the number you can create. > > > > 2. Rule 4 of BIP125 requires a feerate increase to at least surpass the minimum transaction relay setting. Ratcheting by 25% should satisfy this requirement > > > > 3. An additional rule will be added to the checks of an RBF transaction that it must include at least one identical, replaceable input as the original transaction. > > > > > > > > > > \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_ > > Lightning-dev mailing list > > [Lightning-dev at lists.linuxfoundation.org][Lightning-dev_lists.linuxfoundation.org] > > https://www.learnbitcoin.com/archive/lists/lightning-dev > >
[https_github.com_bitcoin_bitcoin_blob_aabec94541e23a67a9f30dc2c80dab3383a01737_src_wallet_wallet.cpp_L2519]: https://github.com/bitcoin/bitcoin/blob/aabec94541e23a67a9f30dc2c80dab3383a01737/src/wallet/wallet.cpp#L2519 [niftynei_gmail.com]: mailto:niftynei at gmail.com [PR _524]: https://github.com/lightningnetwork/lightning-rfc/pull/524 [Lightning-dev_lists.linuxfoundation.org]: mailto:Lightning-dev at lists.linuxfoundation.org
Hi Lisa and all,
Given the discussion about utxos snooping, I wondered if there was any obvious drawbacks of using a transaction chain construction ?
Since the obvious target of the probing is the accepter, it seems that the opener needs to at least have something at stake in order to be revealed some of the accepter's utxos. Thus, the opener giving the accepter a signed transaction commited to the channel opening is one way of avoiding the opener to probe gratuitously. I was thinking of something like:
A is opener, B is accepter. A could sign the first input (and accordingly the 2of2 output) with SIGHASH_SINGLE|SIGHASH_ANYONECANPAY. Unfortunately this doesn't handle A's change, but it can be solved using a chain of transaction. A creates a first transaction txA1:
txA1 (SIGHASH_ALL)
_________________ __________________________
| A's input 1 | A's channel participation |
|----------------|---------------------------
| A's input 2 | A's change |
|----------------|---------------------------
| A's input n |
|________________|
And then creates /signs the funding transaction out of the first output of txA1:
txA2 (SIGHASH_SINGLE|SIGHASH_ANYONECANPAY)
_________________ _______________
| txA1 vout 0 | 2of2 with B |
|________________|________________
Since txA2 is signed with SINGLE|ANYONECANPAY, B can add inputs to fulfill the value requirement of the 2of2, and add outputs for its own change.
This comes at the cost of more setup fees opener-side, but avoids the accepter to be gratuitously probed, so this is arguably a far lesser evil. Is there any other downside I'm missing here ?
Antoine
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐ Le mardi, janvier 28, 2020 2:51 AM, lisa neigut <niftynei at gmail.com> a écrit :
Quoted text (263 lines)
> Some of the feedback I received from the check-in for the dual-funding proposal this past Monday was along the lines that we look at simplifying for breaking it into smaller, more manageable chunks. > > The biggest piece of the dual-funding protocol update is definitely the move from a single peer constructing a transaction to two participants. We're also going to likely want to reuse this portion of the protocol for batched closings and splicing. To that extent, it seemed useful to highlight it in a separate email. > > This is a change from the existing proposal in the dual-funding PR #524 -- it allows for the removal of inputs and outputs. > > The set of messages are as follows. > > Note that the 'initiation' of this protocol will be different depending on the case of the transaction (open, close or splice): > > 1. type: 440 `tx_add_input` > > 2. data: > > * [`32*byte`:`channel_identifier`] > > * [`u64`:`sats`] > > * [`sha256`:`prevtx_txid`] > > * [`u32`:`prevtx_vout`] > > * [`u16`:`prevtx_scriptpubkey_len`] > > * [`prevtx_scriptpubkey_len*byte`:`prevtx_scriptpubkey`] > > * [`u16`:`max_witness_len`] > > * [`u16`:`scriptlen`] > > * [`scriptlen*byte`:`script`] > > * [`byte`:`signal_rbf`] > > 1. type: 442 `tx_add_output` > > 2. data: > > * [`32*byte`:`channel_identifier`] > > * [`u64`:`sats`] > > * [`u16`:`scriptlen`] > > * [`scriptlen*byte`:`script`] > > 1. type: 444 `tx_remove_input` > > 2. data: > > * [`32*byte`:`channel_identifier`] > > * [`sha256`:`prevtx_txid`] > > * [`u32`:`prevtx_vout`] > > 1. type: 446 `tx_remove_output` > > 2. data: > > * [`32*byte`:`channel_identifier`] > > * [`u64`:`sats`] > > * [`u16`:`scriptlen`] > > * [`scriptlen*byte`:`script`] > > 1. type: 448 `tx_complete` > > 2. data: > > * [`32*byte`:`channel_identifier`] > > * [`u16`:`num_inputs`] > > * [`u16`:`num_outputs`] > > 1. type: 448 `tx_sigs` > > 2. data: > > * [`channel_id`:`channel_identifier`] > > * [`u16`:`num_witnesses`] > > * [`num_witnesses*witness_stack`:`witness_stack`] > > 1. subtype: `witness_stack` > > 2. data: > > * [`sha256`:`prevtx_txid`] > > * [`u32`:`prevtx_vout`] > > * [`u16`:`num_input_witness`] > > * [`num_input_witness*witness_element`:`witness_element`] > > 1. subtype: `witness_element` > > 2. data: > > * [`u16`:`len`] > > * [`len*byte`:`witness`] > > ## General Notes > > - Validity of inputs/outputs is not checked until both peers have sent consecutive `tx_complete` messages. > > - Duplicate inputs or outputs is a protocol error. > > - Feerate is set by the initiator, or in the case of a closing transaction, negotiated before the transaction construction is initiated. > > - Every peer pays fees for the inputs + outputs they contribute, plus enough to cover the maximum estimate of their witnesses. Overpayment of fees is permissible. > > - Initiator is responsible for contributing the output/input in question, i.e. the > > funding output in the case of an opening, or the funding input in the case of a close. > > (This means that the opener will pay for the opening output). In the case of a splice, > > the initiator of the splice pays for the funding tx's inclusion as an input and the > > new 'funding tx' output. > > - Any contributor may signal that their input is RBF'able. The nSequence for this input should be set to 0xFEFF FFFF, 0xFFFFFFFF otherwise. > > - The initiating peer is understood to be paying the fee for the shared transaction fields (nVersion [4], segwit marker + flag [2], input + output counts [2-18], witness count [1-9], nLocktime [4]; total [13-40bytes]) > > - Inputs MUST be segwit compatible (PW* or P2SH-PW*) > > - All output scripts must be standard > > - nLocktime is always set to 0x00000000. > > - The `num_inputs` and `num_outputs` in `tx_complete` is a count of that peer’s final input and output contributions, net any removals. > > - Either peer may add or remove inputs and outputs until both peers have successfully > > exchanged a `tx_complete` message in succession. > > - Either peer may only add or remove their own input or output. > > - In the case that a `tx_complete` agreement cannot be reached, either peer may > > fail the channel or open protocol (whatever is reasonable for the particular case) > > - In the case of a splice, this would be a soft error (channel returns to normal operation until > > otherwise failed or closed.) > > - In the case of an open, this would be a failure to open the channel. > > - In the case of a close, a failed collaborative close would result in an error and a unilateral close. > > ### Considering the Simple Open case (2 parties) > > - Both peers signal `opt_dual_fund` > > - Opener initiates a channel open with `open_channel2` message, indicating the feerate for the opening transaction > > - Accepter signals acceptance of channel open as proposed, including proposed feerate, via `accept_channel2` > > - Opener sends `tx_add_output`, with the funding output for the sum of both peer’s funding_amount > > - Opener sends `tx_add_input` for each input the wish to add to the funding transaction > > - Opener sends `tx_add_output` for their change > > - Opener sends `tx_complete` > > - Accepter sends `tx_add_input` for each input they wish to add to the funding transaction > > - Accepter sends `tx_add_output` for their change. > > - Accepter sends `tx_complete` > > - Opener sends `tx_complete` > > - Opener and accepter exchange commitment signatures; etc. > > ### Considering the Splice case: > > - Both peers signal `opt_splice_ok` > > - One peer initiates a splice, also signaling the feerate for the transaction. Exact protocol unspecified herein. > > - Initiator sends `tx_add_input` with the original funding output > > - Initiator sends `tx_add_output` with the new, post-splice funding output > > - Initiator sends `tx_add_input/output` as needed to add all desired inputs + outputs > > - Initiator sends `tx_complete` > > - Peer sends `tx_add_input/output` as needed to add all desired inputs + outputs > > - Initiator sends `tx_complete` > > - Peer sends `tx_complete` > > - Initiator + peer exchange commitment signatures, etc. > > ### Considering the Close case: > > - Both peers signal `opt_collaborative_close` in their `node_announcement`. > > - A peer initiates a close sending a `shutdown`, as per usual. > > - A feerate is negotiated. Out of band for this particular portion of the protocol. > > -The closing initiator (peer which first sent `shutdown`), sends `tx_add_input` to spend the funding output and `tx_add_output` to add their output for the channel closure. > > - The peer responds with `tx_add_output`, adding their output to the close transaction. > > - If `option_upfront_shutdown_script` is flagged but no such output with a value at or within a reasonable feerate gap of the peer's funding output is present, then the peer must fail the channel. > > ## Updating a collaborative transaction with RBF: > > - If any input is flagged as RBF’able, then the transaction is considered eligible for RBF > > - RBF can be initiated by either party, and serves as an initiation for another round of transaction composition, as outlined above. > > - Note that this section has been cribbed and re-purposed from the original RBF proposal for splicing, see https://www.learnbitcoin.com/archive/lists/lightning-dev/t/2018/splicing-proposal-now-with-rbf#m-41bd6437 > > 1. type: 45 (`init_rbf`) (`option_collaborative_rbf`) > > 2. data: > > * [`32`:`channel_id`] > > * [`4`:`fee_step`] > > Each `fee_step` adds 1/4 (rounded down) to the initial > > transaction feerate. eg. if the initial feerate was 512 satoshis per kiloweight, `fee_step` 1 > > is 512 + 512 / 4 = 640, `fee_step` 2 is 640 + 640 / 4 = 800. > > The sender: > > - MUST set `fee_step` greater than zero and greater than any prior `fee_step`. > > The recipient: > > - if the new fee exceeds the sender's current balance minus reserve > > after it is applied to the splice transaction: > > - MUST error. > > NOTES: > > 1. 1/4 is a reasonable minimal RBF, but as each one requires more > > tracking by the recipient, serves to limit the number you can create. > > 2. Rule 4 of BIP125 requires a feerate increase to at least surpass the minimum transaction relay setting. Ratcheting by 25% should satisfy this requirement > > 3. An additional rule will be added to the checks of an RBF transaction that it must include at least one identical, replaceable input as the original transaction.
Good morning darosior,
Quoted text (32 lines)
> Hi Lisa and all, > > Given the discussion about utxos snooping, I wondered if there was any obvious drawbacks of using a transaction chain construction ? > > Since the obvious target of the probing is the accepter, it seems that the opener needs to at least have something at stake in order to be revealed some of the accepter's utxos. > Thus, the opener giving the accepter a signed transaction commited to the channel opening is one way of avoiding the opener to probe gratuitously. I was thinking of something like: > > A is opener, B is accepter. > A could sign the first input (and accordingly the 2of2 output) with SIGHASH_SINGLE|SIGHASH_ANYONECANPAY. Unfortunately this doesn't handle A's change, but it can be solved using a chain of transaction. > A creates a first transaction txA1: > > txA1 (SIGHASH_ALL) > _________________ __________________________ > | A's input 1 | A's channel participation | > |----------------|--------------------------- > | A's input 2 | A's change | > |----------------|--------------------------- > | A's input n | > |________________| > > > And then creates /signs the funding transaction out of the first output of txA1: > > txA2 (SIGHASH_SINGLE|SIGHASH_ANYONECANPAY) > _________________ _______________ > | txA1 vout 0 | 2of2 with B | > |________________|________________ > > Since txA2 is signed with SINGLE|ANYONECANPAY, B can add inputs to fulfill the value requirement of the 2of2, and add outputs for its own change. > > This comes at the cost of more setup fees opener-side, but avoids the accepter to be gratuitously probed, so this is arguably a far lesser evil. > Is there any other downside I'm missing here ?
This is an excellent idea. A drawback is that anything that is not `SIGHASH_ALL` sticks out in chain analysis. This is not an issue currently with Lightning since every 2-of-2 is (almost) definitely a Lightning Channel, but future improvements (Schnorr, Taproot) let us get better hiding, so the `SIGHASH_SINGLE | SIGHASH_ANYONECANPAY` is a massive flag. As the point of protecting against this kind of probing is privacy, this is not a perfect privacy solution.
We could also consider PoDLE as used in JoinMarket, which solves a similar problem. https://gist.github.com/AdamISZ/9cbba5e9408d23813ca8#defence-2-committing-to-a-utxo-in-publicplaintext-at-the-start-of-the-handshake Basically, a PoDLE commits to a UTXO, without being trivially grindable from the UTXO set and also including a proof that the creator of the PoDLE knows the secret key behind it. It can later be opened to reveal which UTXO the opener allocated. If the opener aborts (i.e. does not provide its signatures to the funding transaction) then the acceptor can gossip the UTXO and the revealed PoDLE as well to the rest of Lightning, so that the opener at least cannot reuse the same UTXO to probe other potential acceptors. (though, my understanding, there is no clear way to determine *when* we can safely delete old PoDLEs: maybe each node can keep it around for a month, which might be good enough to limit the practical ability of a snoop to probe other nodes) I believe JoinMarket also has solved the issue of allowing a UTXO to be used at most N times (for example due to "honest" failures, such as connectivity interruptions which might cause an abort of the protocol); I think it involves appending a single byte to something that is hashed, and ensuring its value is less than N, so that it can only be used from 0 to N - 1 (and thus allow a UTXO to be used at most N times).
Getting into contact with waxwing / Adam Gibson for this might be useful to fill out how PoDLE works and so on; basically, I believe this issue is a practically solved problem already for JoinMarket, though waxwing may be able to provide a more nuanced opinion.
Regards, ZmnSCPxj
Hey Darosior,
You don't need a strict synchronization between both peers, just let nLocktime picked up by initiator and announce it at same time than feerate or at `tx_complete`. Worst-case, a slow-block-processing receiver may not be able to get the transaction accepted by its local mempool, but IMO that's fine if at least the initiator is able to do so. We are requiring peers to be weakly in sync before operating channel anyway (`funding_locked` exchange).
Funding_tx can already be drop from mempool for others reasons like mempool shrinks or expiry so broadcaster should always be ready to re-send it or bump feerate.
Or are you describing another issue ?
Le jeu. 30 janv. 2020 à 04:06, darosior <darosior at protonmail.com> a écrit :
Quoted text (389 lines)
> Hi Antoine and all, > > > About nLockTime fun thing is Lisa, Cdecker and I had this conversation to > integrate it to C-lightning just yesterday. > > > Unfortunately you need to add a "My tip is xxxx" to the openchannel msg, > otherwise if you set nLockTime to tip. (cdecker) > > > Moreover in case of reorg the funding tx (now non-final) would be dropped > from mempool ? But you could set nLockTime to, say, tip - 6. (niftynei) > > > Antoine > > > -------- Original Message -------- > On Jan 30, 2020, 01:21, Antoine Riard < antoine.riard at gmail.com> wrote: > > > Hey thanks for this proposal! > > 2 high-level questions: > > What about multi-party tx construction ? By multi-party, let's define > Alice initiate a tx construction to Bob and then Bob announce a > construction to Caroll and "bridge" all inputs/outputs > additions/substractions > in both directions. I think the current proposal hold, if you are a bit > more > tolerant and bridge peer don't send a tx_complete before receiving ones > from all its peers. > > What about transactions format ? I think we should coordinate with Coinjoin > people to converge to a common one to avoid leaking protocol usage when > we can hinder under Taproot. Like setting the nLocktime or sorting inputs > in some protocol-specific fashion. Ideally we should have a BIP for format > but every layer 2 protocols its own set of messages concerning the > construction. > > > nLocktime is always set to 0x000000 > Maybe we can implement anti-fee sniping and mask among wallet core > txn set: > https://github.com/bitcoin/bitcoin/blob/aabec94541e23a67a9f30dc2c80dab3383a01737/src/wallet/wallet.cpp#L2519 > ? > > > In the case of a close, a failed collaborative close would result in an > error and a uninlateral close" > Or can we do first a mutual closing tx, hold tx broadcast for a bit if > "opt_dual_fund" > is signaled to see if a tx_construction + add_funding_input for the > channel is received > soon ? At least that would be a dual opt-in to know than one party can > submit a funding-outpoint > as part of a composed tx ? > > Antoine > > Le lun. 27 janv. 2020 à 20:51, lisa neigut <niftynei at gmail.com> a écrit : > >> Some of the feedback I received from the check-in for the dual-funding >> proposal this past Monday was along the lines that we look at simplifying >> for breaking it into smaller, more manageable chunks. >> >> The biggest piece of the dual-funding protocol update is definitely the >> move from a single peer constructing a transaction to two participants. >> We're also going to likely want to reuse this portion of the protocol >> for batched closings and splicing. To that extent, it seemed useful to >> highlight it in a separate email. >> >> This is a change from the existing proposal in the dual-funding PR #524 >> <https://github.com/lightningnetwork/lightning-rfc/pull/524> -- it >> allows for the removal of inputs and outputs. >> >> The set of messages are as follows. >> >> >> Note that the 'initiation' of this protocol will be different depending >> on the case of the transaction (open, close or splice): >> >> 1. type: 440 `tx_add_input` >> >> 2. data: >> >> * [`32*byte`:`channel_identifier`] >> >> * [`u64`:`sats`] >> >> * [`sha256`:`prevtx_txid`] >> >> * [`u32`:`prevtx_vout`] >> >> * [`u16`:`prevtx_scriptpubkey_len`] >> >> * [`prevtx_scriptpubkey_len*byte`:`prevtx_scriptpubkey`] >> >> * [`u16`:`max_witness_len`] >> >> * [`u16`:`scriptlen`] >> >> * [`scriptlen*byte`:`script`] >> >> * [`byte`:`signal_rbf`] >> >> 1. type: 442 `tx_add_output` >> >> 2. data: >> >> * [`32*byte`:`channel_identifier`] >> >> * [`u64`:`sats`] >> >> * [`u16`:`scriptlen`] >> >> * [`scriptlen*byte`:`script`] >> >> 1. type: 444 `tx_remove_input` >> >> 2. data: >> >> * [`32*byte`:`channel_identifier`] >> >> * [`sha256`:`prevtx_txid`] >> >> * [`u32`:`prevtx_vout`] >> >> 1. type: 446 `tx_remove_output` >> >> 2. data: >> >> * [`32*byte`:`channel_identifier`] >> >> * [`u64`:`sats`] >> >> * [`u16`:`scriptlen`] >> >> * [`scriptlen*byte`:`script`] >> >> 1. type: 448 `tx_complete` >> >> 2. data: >> >> * [`32*byte`:`channel_identifier`] >> >> * [`u16`:`num_inputs`] >> >> * [`u16`:`num_outputs`] >> >> 1. type: 448 `tx_sigs` >> >> 2. data: >> >> * [`channel_id`:`channel_identifier`] >> >> * [`u16`:`num_witnesses`] >> >> * [`num_witnesses*witness_stack`:`witness_stack`] >> >> 1. subtype: `witness_stack` >> >> 2. data: >> >> * [`sha256`:`prevtx_txid`] >> >> * [`u32`:`prevtx_vout`] >> >> * [`u16`:`num_input_witness`] >> >> * [`num_input_witness*witness_element`:`witness_element`] >> >> 1. subtype: `witness_element` >> >> 2. data: >> >> * [`u16`:`len`] >> >> * [`len*byte`:`witness`] >> >> >> >> ## General Notes >> >> - Validity of inputs/outputs is not checked until both peers have sent >> consecutive `tx_complete` messages. >> >> - Duplicate inputs or outputs is a protocol error. >> >> - Feerate is set by the initiator, or in the case of a closing >> transaction, negotiated before the transaction construction is initiated. >> >> - Every peer pays fees for the inputs + outputs they contribute, plus >> enough to cover the maximum estimate of their witnesses. Overpayment of >> fees is permissible. >> >> - Initiator is responsible for contributing the output/input in question, >> i.e. the >> >> funding output in the case of an opening, or the funding input in the >> case of a close. >> >> (This means that the opener will pay for the opening output). In the >> case of a splice, >> >> the initiator of the splice pays for the funding tx's inclusion as an >> input and the >> >> new 'funding tx' output. >> >> - Any contributor may signal that their input is RBF'able. The nSequence >> for this input should be set to 0xFEFF FFFF, 0xFFFFFFFF otherwise. >> >> - The initiating peer is understood to be paying the fee for the shared >> transaction fields (nVersion [4], segwit marker + flag [2], input + output >> counts [2-18], witness count [1-9], nLocktime [4]; total [13-40bytes]) >> >> - Inputs MUST be segwit compatible (PW* or P2SH-PW*) >> >> - All output scripts must be standard >> >> - nLocktime is always set to 0x00000000. >> >> - The `num_inputs` and `num_outputs` in `tx_complete` is a count of that >> peer’s final input and output contributions, net any removals. >> >> - Either peer may add or remove inputs and outputs until both peers have >> successfully >> >> exchanged a `tx_complete` message in succession. >> >> - Either peer may only add or remove their own input or output. >> >> - In the case that a `tx_complete` agreement cannot be reached, either >> peer may >> >> fail the channel or open protocol (whatever is reasonable for the >> particular case) >> >> - In the case of a splice, this would be a soft error (channel returns >> to normal operation until >> >> otherwise failed or closed.) >> >> - In the case of an open, this would be a failure to open the channel. >> >> - In the case of a close, a failed collaborative close would result in >> an error and a unilateral close. >> >> ### Considering the Simple Open case (2 parties) >> >> - Both peers signal `opt_dual_fund` >> >> - Opener initiates a channel open with `open_channel2` message, >> indicating the feerate for the opening transaction >> >> - Accepter signals acceptance of channel open as proposed, including >> proposed feerate, via `accept_channel2` >> >> - Opener sends `tx_add_output`, with the funding output for the sum of >> both peer’s funding_amount >> >> - Opener sends `tx_add_input` for each input the wish to add to the >> funding transaction >> >> - Opener sends `tx_add_output` for their change >> >> - Opener sends `tx_complete` >> >> - Accepter sends `tx_add_input` for each input they wish to add to the >> funding transaction >> >> - Accepter sends `tx_add_output` for their change. >> >> - Accepter sends `tx_complete` >> >> - Opener sends `tx_complete` >> >> - Opener and accepter exchange commitment signatures; etc. >> >> ### Considering the Splice case: >> >> - Both peers signal `opt_splice_ok` >> >> - One peer initiates a splice, also signaling the feerate for the >> transaction. Exact protocol unspecified herein. >> >> - Initiator sends `tx_add_input` with the original funding output >> >> - Initiator sends `tx_add_output` with the new, post-splice funding output >> >> - Initiator sends `tx_add_input/output` as needed to add all desired >> inputs + outputs >> >> - Initiator sends `tx_complete` >> >> - Peer sends `tx_add_input/output` as needed to add all desired inputs + >> outputs >> >> - Initiator sends `tx_complete` >> >> - Peer sends `tx_complete` >> >> - Initiator + peer exchange commitment signatures, etc. >> >> ### Considering the Close case: >> >> - Both peers signal `opt_collaborative_close` in their >> `node_announcement`. >> >> - A peer initiates a close sending a `shutdown`, as per usual. >> >> - A feerate is negotiated. Out of band for this particular portion of the >> protocol. >> >> -The closing initiator (peer which first sent `shutdown`), sends >> `tx_add_input` to spend the funding output and `tx_add_output` to add their >> output for the channel closure. >> >> - The peer responds with `tx_add_output`, adding their output to the >> close transaction. >> >> - If `option_upfront_shutdown_script` is flagged but no such output with >> a value at or within a reasonable feerate gap of the peer's funding output >> is present, then the peer must fail the channel. >> >> >> ## Updating a collaborative transaction with RBF: >> >> - If any input is flagged as RBF’able, then the transaction is considered >> eligible for RBF >> >> - RBF can be initiated by either party, and serves as an initiation for >> another round of transaction composition, as outlined above. >> >> - Note that this section has been cribbed and re-purposed from the >> original RBF proposal for splicing, see >> https://www.learnbitcoin.com/archive/lists/lightning-dev/t/2018/splicing-proposal-now-with-rbf#m-41bd6437 >> >> 1. type: 45 (`init_rbf`) (`option_collaborative_rbf`) >> >> 2. data: >> >> * [`32`:`channel_id`] >> >> * [`4`:`fee_step`] >> >> Each `fee_step` adds 1/4 (rounded down) to the initial >> >> transaction feerate. eg. if the initial feerate was 512 satoshis per >> kiloweight, `fee_step` 1 >> >> is 512 + 512 / 4 = 640, `fee_step` 2 is 640 + 640 / 4 = 800. >> >> The sender: >> >> - MUST set `fee_step` greater than zero and greater than any prior >> `fee_step`. >> >> The recipient: >> >> - if the new fee exceeds the sender's current balance minus reserve >> >> after it is applied to the splice transaction: >> >> - MUST error. >> >> >> >> NOTES: >> >> 1. 1/4 is a reasonable minimal RBF, but as each one requires more >> >> tracking by the recipient, serves to limit the number you can create. >> >> 2. Rule 4 of BIP125 requires a feerate increase to at least surpass the >> minimum transaction relay setting. Ratcheting by 25% should satisfy this >> requirement >> >> 3. An additional rule will be added to the checks of an RBF transaction >> that it must include at least one identical, replaceable input as the >> original transaction. >> >> _______________________________________________ >> Lightning-dev mailing list >> Lightning-dev at lists.linuxfoundation.org >> https://www.learnbitcoin.com/archive/lists/lightning-dev >> >
Sorry I wasn't clear enough in the \`(cdecker)\` paragraph.
The funding transaction sig would actually fail verification if tip differs between funder and fundee.
Darosior ( i'll stick with my pseudo, first names definitely don't have enough entropy :-) ) \-------- Original Message -------- On Jan 30, 2020, 19:09, Antoine Riard < antoine.riard at gmail.com> wrote:
Quoted text (503 lines)
> > > > Hey Darosior, > > > > You don't need a strict synchronization between both peers, > > > just let nLocktime picked up by initiator and announce it at > > > same time than feerate or at \`tx\_complete\`. Worst-case, > > > a slow-block-processing receiver may not be able to get > > > the transaction accepted by its local mempool, but IMO that's > fine if at least the initiator is able to do so. We are requiring peers > > > to be weakly in sync before operating channel anyway (\`funding\_locked\` > > > exchange). > > > > > > Funding\_tx can already be drop from mempool for others > > > reasons like mempool shrinks or expiry so broadcaster > > > should always be ready to re-send it or bump feerate. > > > > Or are you describing another issue ? > > > > > > Le jeu. 30 janv. 2020 à 04:06, darosior <[darosior at protonmail.com][darosior_protonmail.com]> a écrit : > > > > Hi Antoine and all, > > > > > > > > > > > > > > > > About nLockTime fun thing is Lisa, Cdecker and I had this conversation to integrate it to C-lightning just yesterday. > > > > > > > > > > > > > > > > Unfortunately you need to add a "My tip is xxxx" to the openchannel msg, otherwise if you set nLockTime to tip. (cdecker) > > > > > > > > > > > > > > > > Moreover in case of reorg the funding tx (now non-final) would be dropped from mempool ? But you could set nLockTime to, say, tip - 6. (niftynei) > > > > > > > > > > > > > > > > Antoine > > > > > > > > > > > > \-------- Original Message -------- > > On Jan 30, 2020, 01:21, Antoine Riard < [antoine.riard at gmail.com][antoine.riard_gmail.com]> wrote: > > > > > > > > > > > > > > Hey thanks for this proposal! > > > > > > > > > > > > 2 high-level questions: > > > > > > > > > > > > > > > > > > What about multi-party tx construction ? By multi-party, let's define > > > > > > Alice initiate a tx construction to Bob and then Bob announce a > > > > > > > > > construction to Caroll and "bridge" all inputs/outputs additions/substractions > > > > > > > > > in both directions. I think the current proposal hold, if you are a bit more > > > > > > > > > tolerant and bridge peer don't send a tx\_complete before receiving ones > > > > > > > > > from all its peers. > > > > > > > > > > > > > > > > > > What about transactions format ? I think we should coordinate with Coinjoin > > > > > > > > > people to converge to a common one to avoid leaking protocol usage when > > > we can hinder under Taproot. Like setting the nLocktime or sorting inputs > > > > > > > > > in some protocol-specific fashion. Ideally we should have a BIP for format > > > > > > > > > but every layer 2 protocols its own set of messages concerning the construction. > > > > > > > nLocktime is always set to 0x000000 > > > Maybe we can implement anti-fee sniping and mask among wallet core > > > txn set: [https://github.com/bitcoin/bitcoin/blob/aabec94541e23a67a9f30dc2c80dab3383a01737/src/wallet/wallet.cpp\#L2519][https_github.com_bitcoin_bitcoin_blob_aabec94541e23a67a9f30dc2c80dab3383a01737_src_wallet_wallet.cpp_L2519] ? > > > > > > > In the case of a close, a failed collaborative close would result in an error and a uninlateral close" > > > Or can we do first a mutual closing tx, hold tx broadcast for a bit if "opt\_dual\_fund" > > > is signaled to see if a tx\_construction + add\_funding\_input for the channel is received > > > soon ? At least that would be a dual opt-in to know than one party can submit a funding-outpoint > > > as part of a composed tx ? > > > > > > > > > > > > > > > Antoine > > > > > > > > > > > > > > > > > > Le lun. 27 janv. 2020 à 20:51, lisa neigut <[niftynei at gmail.com][niftynei_gmail.com]> a écrit : > > > > > > > > > > Some of the feedback I received from the check-in for the dual-funding proposal this past Monday was along the lines that we look at simplifying for breaking it into smaller, more manageable chunks. > > > > > > > > > > > > > > > > > > > > The biggest piece of the dual-funding protocol update is definitely the move from a single peer constructing a transaction to two participants. We're also going to likely want to reuse this portion of the protocol for batched closings and splicing. To that extent, it seemed useful to highlight it in a separate email. > > > > > > > > > > > > > > > > > > > > This is a change from the existing proposal in the dual-funding [PR \#524][PR _524] \-- it allows for the removal of inputs and outputs. > > > > > > > > > > > > > > > > > > > > The set of messages are as follows. > > > > > > > > > > > > > > > > > > > > Note that the 'initiation' of this protocol will be different depending on the case of the transaction (open, close or splice): > > > > > > > > > > > > > > > > > > > > 1. type: 440 \`tx\_add\_input\` > > > > > > > > 2. data: > > > > > > > > \* \[\`32\*byte\`:\`channel\_identifier\`\] > > > > > > > > \* \[\`u64\`:\`sats\`\] > > > > > > > > \* \[\`sha256\`:\`prevtx\_txid\`\] > > > > > > > > \* \[\`u32\`:\`prevtx\_vout\`\] > > > > > > > > \* \[\`u16\`:\`prevtx\_scriptpubkey\_len\`\] > > > > > > > > \* \[\`prevtx\_scriptpubkey\_len\*byte\`:\`prevtx\_scriptpubkey\`\] > > > > > > > > \* \[\`u16\`:\`max\_witness\_len\`\] > > > > > > > > \* \[\`u16\`:\`scriptlen\`\] > > > > > > > > \* \[\`scriptlen\*byte\`:\`script\`\] > > > > > > > > \* \[\`byte\`:\`signal\_rbf\`\] > > > > > > > > > > > > > > > > > > > > 1. type: 442 \`tx\_add\_output\` > > > > > > > > 2. data: > > > > > > > > \* \[\`32\*byte\`:\`channel\_identifier\`\] > > > > > > > > \* \[\`u64\`:\`sats\`\] > > > > > > > > \* \[\`u16\`:\`scriptlen\`\] > > > > > > > > \* \[\`scriptlen\*byte\`:\`script\`\] > > > > > > > > > > > > > > > > > > > > 1. type: 444 \`tx\_remove\_input\` > > > > > > > > 2. data: > > > > > > > > \* \[\`32\*byte\`:\`channel\_identifier\`\] > > > > > > > > \* \[\`sha256\`:\`prevtx\_txid\`\] > > > > > > > > \* \[\`u32\`:\`prevtx\_vout\`\] > > > > > > > > > > > > > > > > > > > > 1. type: 446 \`tx\_remove\_output\` > > > > > > > > 2. data: > > > > > > > > \* \[\`32\*byte\`:\`channel\_identifier\`\] > > > > > > > > \* \[\`u64\`:\`sats\`\] > > > > > > > > \* \[\`u16\`:\`scriptlen\`\] > > > > > > > > \* \[\`scriptlen\*byte\`:\`script\`\] > > > > > > > > > > > > > > > > > > > > 1. type: 448 \`tx\_complete\` > > > > > > > > 2. data: > > > > > > > > \* \[\`32\*byte\`:\`channel\_identifier\`\] > > > > > > > > \* \[\`u16\`:\`num\_inputs\`\] > > > > > > > > \* \[\`u16\`:\`num\_outputs\`\] > > > > > > > > > > > > > > > > > > > > 1. type: 448 \`tx\_sigs\` > > > > > > > > 2. data: > > > > > > > > \* \[\`channel\_id\`:\`channel\_identifier\`\] > > > > > > > > \* \[\`u16\`:\`num\_witnesses\`\] > > > > > > > > \* \[\`num\_witnesses\*witness\_stack\`:\`witness\_stack\`\] > > > > > > > > > > > > > > > > > > > > 1. subtype: \`witness\_stack\` > > > > > > > > 2. data: > > > > > > > > \* \[\`sha256\`:\`prevtx\_txid\`\] > > > > > > > > \* \[\`u32\`:\`prevtx\_vout\`\] > > > > > > > > \* \[\`u16\`:\`num\_input\_witness\`\] > > > > > > > > \* \[\`num\_input\_witness\*witness\_element\`:\`witness\_element\`\] > > > > > > > > > > > > > > > > > > > > 1. subtype: \`witness\_element\` > > > > > > > > 2. data: > > > > > > > > \* \[\`u16\`:\`len\`\] > > > > > > > > \* \[\`len\*byte\`:\`witness\`\] > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > \#\# General Notes > > > > > > > > \- Validity of inputs/outputs is not checked until both peers have sent consecutive \`tx\_complete\` messages. > > > > > > > > \- Duplicate inputs or outputs is a protocol error. > > > > > > > > \- Feerate is set by the initiator, or in the case of a closing transaction, negotiated before the transaction construction is initiated. > > > > > > > > \- Every peer pays fees for the inputs + outputs they contribute, plus enough to cover the maximum estimate of their witnesses. Overpayment of fees is permissible. > > > > > > > > \- Initiator is responsible for contributing the output/input in question, i.e. the > > > > > > > > funding output in the case of an opening, or the funding input in the case of a close. > > > > > > > > (This means that the opener will pay for the opening output). In the case of a splice, > > > > > > > > the initiator of the splice pays for the funding tx's inclusion as an input and the > > > > > > > > new 'funding tx' output. > > > > > > > > \- Any contributor may signal that their input is RBF'able. The nSequence for this input should be set to 0xFEFF FFFF, 0xFFFFFFFF otherwise. > > > > > > > > \- The initiating peer is understood to be paying the fee for the shared transaction fields (nVersion \[4\], segwit marker + flag \[2\], input + output counts \[2-18\], witness count \[1-9\], nLocktime \[4\]; total \[13-40bytes\]) > > > > > > > > \- Inputs MUST be segwit compatible (PW\* or P2SH-PW\*) > > > > > > > > \- All output scripts must be standard > > > > > > > > \- nLocktime is always set to 0x00000000. > > > > > > > > \- The \`num\_inputs\` and \`num\_outputs\` in \`tx\_complete\` is a count of that peer’s final input and output contributions, net any removals. > > > > > > > > > > > > > > > > > > > > \- Either peer may add or remove inputs and outputs until both peers have successfully > > > > > > > > exchanged a \`tx\_complete\` message in succession. > > > > > > > > \- Either peer may only add or remove their own input or output. > > > > > > > > \- In the case that a \`tx\_complete\` agreement cannot be reached, either peer may > > > > > > > > fail the channel or open protocol (whatever is reasonable for the particular case) > > > > > > > > - In the case of a splice, this would be a soft error (channel returns to normal operation until > > > > > > > > otherwise failed or closed.) > > > > > > > > - In the case of an open, this would be a failure to open the channel. > > > > > > > > - In the case of a close, a failed collaborative close would result in an error and a unilateral close. > > > > > > > > > > > > > > > > > > > > \#\#\# Considering the Simple Open case (2 parties) > > > > > > > > \- Both peers signal \`opt\_dual\_fund\` > > > > > > > > \- Opener initiates a channel open with \`open\_channel2\` message, indicating the feerate for the opening transaction > > > > > > > > \- Accepter signals acceptance of channel open as proposed, including proposed feerate, via \`accept\_channel2\` > > > > > > > > \- Opener sends \`tx\_add\_output\`, with the funding output for the sum of both peer’s funding\_amount > > > > > > > > \- Opener sends \`tx\_add\_input\` for each input the wish to add to the funding transaction > > > > > > > > \- Opener sends \`tx\_add\_output\` for their change > > > > > > > > \- Opener sends \`tx\_complete\` > > > > > > > > \- Accepter sends \`tx\_add\_input\` for each input they wish to add to the funding transaction > > > > > > > > \- Accepter sends \`tx\_add\_output\` for their change. > > > > > > > > \- Accepter sends \`tx\_complete\` > > > > > > > > \- Opener sends \`tx\_complete\` > > > > > > > > \- Opener and accepter exchange commitment signatures; etc. > > > > > > > > > > > > > > > > > > > > \#\#\# Considering the Splice case: > > > > > > > > \- Both peers signal \`opt\_splice\_ok\` > > > > > > > > \- One peer initiates a splice, also signaling the feerate for the transaction. Exact protocol unspecified herein. > > > > > > > > \- Initiator sends \`tx\_add\_input\` with the original funding output > > > > > > > > \- Initiator sends \`tx\_add\_output\` with the new, post-splice funding output > > > > > > > > \- Initiator sends \`tx\_add\_input/output\` as needed to add all desired inputs + outputs > > > > > > > > \- Initiator sends \`tx\_complete\` > > > > > > > > \- Peer sends \`tx\_add\_input/output\` as needed to add all desired inputs + outputs > > > > > > > > \- Initiator sends \`tx\_complete\` > > > > > > > > \- Peer sends \`tx\_complete\` > > > > > > > > \- Initiator + peer exchange commitment signatures, etc. > > > > > > > > > > > > > > > > > > > > \#\#\# Considering the Close case: > > > > > > > > \- Both peers signal \`opt\_collaborative\_close\` in their \`node\_announcement\`. > > > > > > > > \- A peer initiates a close sending a \`shutdown\`, as per usual. > > > > > > > > \- A feerate is negotiated. Out of band for this particular portion of the protocol. > > > > > > > > \-The closing initiator (peer which first sent \`shutdown\`), sends \`tx\_add\_input\` to spend the funding output and \`tx\_add\_output\` to add their output for the channel closure. > > > > > > > > \- The peer responds with \`tx\_add\_output\`, adding their output to the close transaction. > > > > > > > > \- If \`option\_upfront\_shutdown\_script\` is flagged but no such output with a value at or within a reasonable feerate gap of the peer's funding output is present, then the peer must fail the channel. > > > > > > > > > > > > > > > > > > > > > > > > \#\# Updating a collaborative transaction with RBF: > > > > > > > > \- If any input is flagged as RBF’able, then the transaction is considered eligible for RBF > > > > > > > > \- RBF can be initiated by either party, and serves as an initiation for another round of transaction composition, as outlined above. > > > > > > > > \- Note that this section has been cribbed and re-purposed from the original RBF proposal for splicing, see https://www.learnbitcoin.com/archive/lists/lightning-dev/t/2018/splicing-proposal-now-with-rbf#m-41bd6437 > > > > > > > > > > > > > > > > > > > > 1. type: 45 (\`init\_rbf\`) (\`option\_collaborative\_rbf\`) > > > > > > > > 2. data: > > > > > > > > \* \[\`32\`:\`channel\_id\`\] > > > > > > > > \* \[\`4\`:\`fee\_step\`\] > > > > > > > > > > > > > > > > > > > > Each \`fee\_step\` adds 1/4 (rounded down) to the initial > > > > > > > > transaction feerate. eg. if the initial feerate was 512 satoshis per kiloweight, \`fee\_step\` 1 > > > > > > > > is 512 + 512 / 4 = 640, \`fee\_step\` 2 is 640 + 640 / 4 = 800. > > > > > > > > > > > > > > > > > > > > The sender: > > > > > > > > - MUST set \`fee\_step\` greater than zero and greater than any prior \`fee\_step\`. > > > > > > > > > > > > > > > > > > > > The recipient: > > > > > > > > - if the new fee exceeds the sender's current balance minus reserve > > > > > > > > after it is applied to the splice transaction: > > > > > > > > - MUST error. > > > > > > > > > > > > > > > > NOTES: > > > > > > > > 1. 1/4 is a reasonable minimal RBF, but as each one requires more > > > > > > > > tracking by the recipient, serves to limit the number you can create. > > > > > > > > 2. Rule 4 of BIP125 requires a feerate increase to at least surpass the minimum transaction relay setting. Ratcheting by 25% should satisfy this requirement > > > > > > > > 3. An additional rule will be added to the checks of an RBF transaction that it must include at least one identical, replaceable input as the original transaction. > > > > > > > > > > > > > > > > > > > > \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_ > > > > Lightning-dev mailing list > > > > [Lightning-dev at lists.linuxfoundation.org][Lightning-dev_lists.linuxfoundation.org] > > > > https://www.learnbitcoin.com/archive/lists/lightning-dev > > > >
[darosior_protonmail.com]: mailto:darosior at protonmail.com [antoine.riard_gmail.com]: mailto:antoine.riard at gmail.com [https_github.com_bitcoin_bitcoin_blob_aabec94541e23a67a9f30dc2c80dab3383a01737_src_wallet_wallet.cpp_L2519]: https://github.com/bitcoin/bitcoin/blob/aabec94541e23a67a9f30dc2c80dab3383a01737/src/wallet/wallet.cpp#L2519 [niftynei_gmail.com]: mailto:niftynei at gmail.com [PR _524]: https://github.com/lightningnetwork/lightning-rfc/pull/524 [Lightning-dev_lists.linuxfoundation.org]: mailto:Lightning-dev at lists.linuxfoundation.org
Quoted text (2 lines)
> The funding transaction sig would actually fail verification if tip differs between funder and fundee
Yes that's the reason I wrote the initiator can just announce its own and receiver use it to sign the funding tx, even if receiver tip is backward. Funding tx won't propagate from receiver mempool but that's fine if it does from the initiator one.
Or are you talking about the commitment tx (different issue and there is broader privacy leaks there) ?
Quoted text (2 lines)
> Darosior ( i'll stick with my pseudo, first names definitely don't have enough entropy :-) )
Ahaha yeah this pseudo-random-name-generator is definitely not trustworthy :p
Le jeu. 30 janv. 2020 à 13:19, darosior <darosior at protonmail.com> a écrit :
Quoted text (424 lines)
> Sorry I wasn't clear enough in the `(cdecker)` paragraph. > > > The funding transaction sig would actually fail verification if tip > differs between funder and fundee. > > > Darosior ( i'll stick with my pseudo, first names definitely don't have > enough entropy :-) ) > -------- Original Message -------- > On Jan 30, 2020, 19:09, Antoine Riard < antoine.riard at gmail.com> wrote: > > > Hey Darosior, > > You don't need a strict synchronization between both peers, > just let nLocktime picked up by initiator and announce it at > same time than feerate or at `tx_complete`. Worst-case, > a slow-block-processing receiver may not be able to get > the transaction accepted by its local mempool, but IMO that's > fine if at least the initiator is able to do so. We are requiring peers > to be weakly in sync before operating channel anyway (`funding_locked` > exchange). > > Funding_tx can already be drop from mempool for others > reasons like mempool shrinks or expiry so broadcaster > should always be ready to re-send it or bump feerate. > > Or are you describing another issue ? > > Le jeu. 30 janv. 2020 à 04:06, darosior <darosior at protonmail.com> a > écrit : > >> Hi Antoine and all, >> >> >> About nLockTime fun thing is Lisa, Cdecker and I had this conversation to >> integrate it to C-lightning just yesterday. >> >> >> Unfortunately you need to add a "My tip is xxxx" to the openchannel msg, >> otherwise if you set nLockTime to tip. (cdecker) >> >> >> Moreover in case of reorg the funding tx (now non-final) would be dropped >> from mempool ? But you could set nLockTime to, say, tip - 6. (niftynei) >> >> >> Antoine >> >> >> -------- Original Message -------- >> On Jan 30, 2020, 01:21, Antoine Riard < antoine.riard at gmail.com> wrote: >> >> >> Hey thanks for this proposal! >> >> 2 high-level questions: >> >> What about multi-party tx construction ? By multi-party, let's define >> Alice initiate a tx construction to Bob and then Bob announce a >> construction to Caroll and "bridge" all inputs/outputs >> additions/substractions >> in both directions. I think the current proposal hold, if you are a bit >> more >> tolerant and bridge peer don't send a tx_complete before receiving ones >> from all its peers. >> >> What about transactions format ? I think we should coordinate with >> Coinjoin >> people to converge to a common one to avoid leaking protocol usage when >> we can hinder under Taproot. Like setting the nLocktime or sorting inputs >> in some protocol-specific fashion. Ideally we should have a BIP for format >> but every layer 2 protocols its own set of messages concerning the >> construction. >> >> > nLocktime is always set to 0x000000 >> Maybe we can implement anti-fee sniping and mask among wallet core >> txn set: >> https://github.com/bitcoin/bitcoin/blob/aabec94541e23a67a9f30dc2c80dab3383a01737/src/wallet/wallet.cpp#L2519 >> ? >> >> > In the case of a close, a failed collaborative close would result in an >> error and a uninlateral close" >> Or can we do first a mutual closing tx, hold tx broadcast for a bit if >> "opt_dual_fund" >> is signaled to see if a tx_construction + add_funding_input for the >> channel is received >> soon ? At least that would be a dual opt-in to know than one party can >> submit a funding-outpoint >> as part of a composed tx ? >> >> Antoine >> >> Le lun. 27 janv. 2020 à 20:51, lisa neigut <niftynei at gmail.com> a écrit : >> >>> Some of the feedback I received from the check-in for the dual-funding >>> proposal this past Monday was along the lines that we look at simplifying >>> for breaking it into smaller, more manageable chunks. >>> >>> The biggest piece of the dual-funding protocol update is definitely the >>> move from a single peer constructing a transaction to two participants. >>> We're also going to likely want to reuse this portion of the protocol >>> for batched closings and splicing. To that extent, it seemed useful to >>> highlight it in a separate email. >>> >>> This is a change from the existing proposal in the dual-funding PR #524 >>> <https://github.com/lightningnetwork/lightning-rfc/pull/524> -- it >>> allows for the removal of inputs and outputs. >>> >>> The set of messages are as follows. >>> >>> >>> Note that the 'initiation' of this protocol will be different depending >>> on the case of the transaction (open, close or splice): >>> >>> 1. type: 440 `tx_add_input` >>> >>> 2. data: >>> >>> * [`32*byte`:`channel_identifier`] >>> >>> * [`u64`:`sats`] >>> >>> * [`sha256`:`prevtx_txid`] >>> >>> * [`u32`:`prevtx_vout`] >>> >>> * [`u16`:`prevtx_scriptpubkey_len`] >>> >>> * [`prevtx_scriptpubkey_len*byte`:`prevtx_scriptpubkey`] >>> >>> * [`u16`:`max_witness_len`] >>> >>> * [`u16`:`scriptlen`] >>> >>> * [`scriptlen*byte`:`script`] >>> >>> * [`byte`:`signal_rbf`] >>> >>> 1. type: 442 `tx_add_output` >>> >>> 2. data: >>> >>> * [`32*byte`:`channel_identifier`] >>> >>> * [`u64`:`sats`] >>> >>> * [`u16`:`scriptlen`] >>> >>> * [`scriptlen*byte`:`script`] >>> >>> 1. type: 444 `tx_remove_input` >>> >>> 2. data: >>> >>> * [`32*byte`:`channel_identifier`] >>> >>> * [`sha256`:`prevtx_txid`] >>> >>> * [`u32`:`prevtx_vout`] >>> >>> 1. type: 446 `tx_remove_output` >>> >>> 2. data: >>> >>> * [`32*byte`:`channel_identifier`] >>> >>> * [`u64`:`sats`] >>> >>> * [`u16`:`scriptlen`] >>> >>> * [`scriptlen*byte`:`script`] >>> >>> 1. type: 448 `tx_complete` >>> >>> 2. data: >>> >>> * [`32*byte`:`channel_identifier`] >>> >>> * [`u16`:`num_inputs`] >>> >>> * [`u16`:`num_outputs`] >>> >>> 1. type: 448 `tx_sigs` >>> >>> 2. data: >>> >>> * [`channel_id`:`channel_identifier`] >>> >>> * [`u16`:`num_witnesses`] >>> >>> * [`num_witnesses*witness_stack`:`witness_stack`] >>> >>> 1. subtype: `witness_stack` >>> >>> 2. data: >>> >>> * [`sha256`:`prevtx_txid`] >>> >>> * [`u32`:`prevtx_vout`] >>> >>> * [`u16`:`num_input_witness`] >>> >>> * [`num_input_witness*witness_element`:`witness_element`] >>> >>> 1. subtype: `witness_element` >>> >>> 2. data: >>> >>> * [`u16`:`len`] >>> >>> * [`len*byte`:`witness`] >>> >>> >>> >>> ## General Notes >>> >>> - Validity of inputs/outputs is not checked until both peers have sent >>> consecutive `tx_complete` messages. >>> >>> - Duplicate inputs or outputs is a protocol error. >>> >>> - Feerate is set by the initiator, or in the case of a closing >>> transaction, negotiated before the transaction construction is initiated. >>> >>> - Every peer pays fees for the inputs + outputs they contribute, plus >>> enough to cover the maximum estimate of their witnesses. Overpayment of >>> fees is permissible. >>> >>> - Initiator is responsible for contributing the output/input in >>> question, i.e. the >>> >>> funding output in the case of an opening, or the funding input in the >>> case of a close. >>> >>> (This means that the opener will pay for the opening output). In the >>> case of a splice, >>> >>> the initiator of the splice pays for the funding tx's inclusion as an >>> input and the >>> >>> new 'funding tx' output. >>> >>> - Any contributor may signal that their input is RBF'able. The nSequence >>> for this input should be set to 0xFEFF FFFF, 0xFFFFFFFF otherwise. >>> >>> - The initiating peer is understood to be paying the fee for the shared >>> transaction fields (nVersion [4], segwit marker + flag [2], input + output >>> counts [2-18], witness count [1-9], nLocktime [4]; total [13-40bytes]) >>> >>> - Inputs MUST be segwit compatible (PW* or P2SH-PW*) >>> >>> - All output scripts must be standard >>> >>> - nLocktime is always set to 0x00000000. >>> >>> - The `num_inputs` and `num_outputs` in `tx_complete` is a count of that >>> peer’s final input and output contributions, net any removals. >>> >>> - Either peer may add or remove inputs and outputs until both peers have >>> successfully >>> >>> exchanged a `tx_complete` message in succession. >>> >>> - Either peer may only add or remove their own input or output. >>> >>> - In the case that a `tx_complete` agreement cannot be reached, either >>> peer may >>> >>> fail the channel or open protocol (whatever is reasonable for the >>> particular case) >>> >>> - In the case of a splice, this would be a soft error (channel returns >>> to normal operation until >>> >>> otherwise failed or closed.) >>> >>> - In the case of an open, this would be a failure to open the channel. >>> >>> - In the case of a close, a failed collaborative close would result in >>> an error and a unilateral close. >>> >>> ### Considering the Simple Open case (2 parties) >>> >>> - Both peers signal `opt_dual_fund` >>> >>> - Opener initiates a channel open with `open_channel2` message, >>> indicating the feerate for the opening transaction >>> >>> - Accepter signals acceptance of channel open as proposed, including >>> proposed feerate, via `accept_channel2` >>> >>> - Opener sends `tx_add_output`, with the funding output for the sum of >>> both peer’s funding_amount >>> >>> - Opener sends `tx_add_input` for each input the wish to add to the >>> funding transaction >>> >>> - Opener sends `tx_add_output` for their change >>> >>> - Opener sends `tx_complete` >>> >>> - Accepter sends `tx_add_input` for each input they wish to add to the >>> funding transaction >>> >>> - Accepter sends `tx_add_output` for their change. >>> >>> - Accepter sends `tx_complete` >>> >>> - Opener sends `tx_complete` >>> >>> - Opener and accepter exchange commitment signatures; etc. >>> >>> ### Considering the Splice case: >>> >>> - Both peers signal `opt_splice_ok` >>> >>> - One peer initiates a splice, also signaling the feerate for the >>> transaction. Exact protocol unspecified herein. >>> >>> - Initiator sends `tx_add_input` with the original funding output >>> >>> - Initiator sends `tx_add_output` with the new, post-splice funding >>> output >>> >>> - Initiator sends `tx_add_input/output` as needed to add all desired >>> inputs + outputs >>> >>> - Initiator sends `tx_complete` >>> >>> - Peer sends `tx_add_input/output` as needed to add all desired inputs + >>> outputs >>> >>> - Initiator sends `tx_complete` >>> >>> - Peer sends `tx_complete` >>> >>> - Initiator + peer exchange commitment signatures, etc. >>> >>> ### Considering the Close case: >>> >>> - Both peers signal `opt_collaborative_close` in their >>> `node_announcement`. >>> >>> - A peer initiates a close sending a `shutdown`, as per usual. >>> >>> - A feerate is negotiated. Out of band for this particular portion of >>> the protocol. >>> >>> -The closing initiator (peer which first sent `shutdown`), sends >>> `tx_add_input` to spend the funding output and `tx_add_output` to add their >>> output for the channel closure. >>> >>> - The peer responds with `tx_add_output`, adding their output to the >>> close transaction. >>> >>> - If `option_upfront_shutdown_script` is flagged but no such output with >>> a value at or within a reasonable feerate gap of the peer's funding output >>> is present, then the peer must fail the channel. >>> >>> >>> ## Updating a collaborative transaction with RBF: >>> >>> - If any input is flagged as RBF’able, then the transaction is >>> considered eligible for RBF >>> >>> - RBF can be initiated by either party, and serves as an initiation for >>> another round of transaction composition, as outlined above. >>> >>> - Note that this section has been cribbed and re-purposed from the >>> original RBF proposal for splicing, see >>> https://www.learnbitcoin.com/archive/lists/lightning-dev/t/2018/splicing-proposal-now-with-rbf#m-41bd6437 >>> >>> 1. type: 45 (`init_rbf`) (`option_collaborative_rbf`) >>> >>> 2. data: >>> >>> * [`32`:`channel_id`] >>> >>> * [`4`:`fee_step`] >>> >>> Each `fee_step` adds 1/4 (rounded down) to the initial >>> >>> transaction feerate. eg. if the initial feerate was 512 satoshis per >>> kiloweight, `fee_step` 1 >>> >>> is 512 + 512 / 4 = 640, `fee_step` 2 is 640 + 640 / 4 = 800. >>> >>> The sender: >>> >>> - MUST set `fee_step` greater than zero and greater than any prior >>> `fee_step`. >>> >>> The recipient: >>> >>> - if the new fee exceeds the sender's current balance minus reserve >>> >>> after it is applied to the splice transaction: >>> >>> - MUST error. >>> >>> >>> >>> NOTES: >>> >>> 1. 1/4 is a reasonable minimal RBF, but as each one requires more >>> >>> tracking by the recipient, serves to limit the number you can create. >>> >>> 2. Rule 4 of BIP125 requires a feerate increase to at least surpass the >>> minimum transaction relay setting. Ratcheting by 25% should satisfy this >>> requirement >>> >>> 3. An additional rule will be added to the checks of an RBF transaction >>> that it must include at least one identical, replaceable input as the >>> original transaction. >>> >>> _______________________________________________ >>> Lightning-dev mailing list >>> Lightning-dev at lists.linuxfoundation.org >>> https://www.learnbitcoin.com/archive/lists/lightning-dev >>> >>
Quoted text (1 line)
> Yes that's the reason I wrote the initiator can just announce its own and receiver use it to sign the funding tx, even if receiver tip is backward. Funding tx won't propagate from receiver mempool but that's fine if it does from the initiator one.
Ah, then we are back to my first response where niftynei proposed to accord on setting it to tip-6 so that reorg is not a problem (or if it is, there are bigger). \-------- Original Message -------- On Jan 30, 2020, 19:45, Antoine Riard < antoine.riard at gmail.com> wrote:
Quoted text (566 lines)
> > > > > The funding transaction sig would actually fail verification if tip differs between funder and fundee > > > > Yes that's the reason I wrote the initiator can just > > > announce its own and receiver use it to sign the funding tx, > > > even if receiver tip is backward. Funding tx won't propagate > > > from receiver mempool but that's fine if it does from the initiator > > one. > > > > Or are you talking about the commitment tx (different issue and there is > > > broader privacy leaks there) ? > > > Darosior ( i'll stick with my pseudo, first names definitely don't have enough entropy :-) ) > > > > Ahaha yeah this pseudo-random-name-generator is definitely not trustworthy :p > > > > > > > > > Le jeu. 30 janv. 2020 à 13:19, darosior <[darosior at protonmail.com][darosior_protonmail.com]> a écrit : > > > > Sorry I wasn't clear enough in the \`(cdecker)\` paragraph. > > > > > > > > > > > > > > > > The funding transaction sig would actually fail verification if tip differs between funder and fundee. > > > > > > > > > > > > > > > > Darosior ( i'll stick with my pseudo, first names definitely don't have enough entropy :-) ) > > \-------- Original Message -------- > > On Jan 30, 2020, 19:09, Antoine Riard < [antoine.riard at gmail.com][antoine.riard_gmail.com]> wrote: > > > > > > > > > > > > > > Hey Darosior, > > > > > > > > > > > > You don't need a strict synchronization between both peers, > > > > > > > > > just let nLocktime picked up by initiator and announce it at > > > > > > > > > same time than feerate or at \`tx\_complete\`. Worst-case, > > > > > > > > > a slow-block-processing receiver may not be able to get > > > > > > > > > the transaction accepted by its local mempool, but IMO that's > > > fine if at least the initiator is able to do so. We are requiring peers > > > > > > > > > to be weakly in sync before operating channel anyway (\`funding\_locked\` > > > > > > > > > exchange). > > > > > > > > > > > > > > > > > > Funding\_tx can already be drop from mempool for others > > > > > > > > > reasons like mempool shrinks or expiry so broadcaster > > > > > > > > > should always be ready to re-send it or bump feerate. > > > > > > > > > > > > Or are you describing another issue ? > > > > > > > > > > > > > > > > > > Le jeu. 30 janv. 2020 à 04:06, darosior <[darosior at protonmail.com][darosior_protonmail.com]> a écrit : > > > > > > > > > > Hi Antoine and all, > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > About nLockTime fun thing is Lisa, Cdecker and I had this conversation to integrate it to C-lightning just yesterday. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Unfortunately you need to add a "My tip is xxxx" to the openchannel msg, otherwise if you set nLockTime to tip. (cdecker) > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Moreover in case of reorg the funding tx (now non-final) would be dropped from mempool ? But you could set nLockTime to, say, tip - 6. (niftynei) > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Antoine > > > > > > > > > > > > > > > > > > > > > > > > \-------- Original Message -------- > > > > On Jan 30, 2020, 01:21, Antoine Riard < [antoine.riard at gmail.com][antoine.riard_gmail.com]> wrote: > > > > > > > > > > > > > > > > > > > > > > > > Hey thanks for this proposal! > > > > > > > > > > > > > > > > > > > > 2 high-level questions: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > What about multi-party tx construction ? By multi-party, let's define > > > > > > > > > > Alice initiate a tx construction to Bob and then Bob announce a > > > > > > > > > > > > > > > construction to Caroll and "bridge" all inputs/outputs additions/substractions > > > > > > > > > > > > > > > in both directions. I think the current proposal hold, if you are a bit more > > > > > > > > > > > > > > > tolerant and bridge peer don't send a tx\_complete before receiving ones > > > > > > > > > > > > > > > from all its peers. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > What about transactions format ? I think we should coordinate with Coinjoin > > > > > > > > > > > > > > > people to converge to a common one to avoid leaking protocol usage when > > > > > we can hinder under Taproot. Like setting the nLocktime or sorting inputs > > > > > > > > > > > > > > > in some protocol-specific fashion. Ideally we should have a BIP for format > > > > > > > > > > > > > > > but every layer 2 protocols its own set of messages concerning the construction. > > > > > > > > > > > nLocktime is always set to 0x000000 > > > > > Maybe we can implement anti-fee sniping and mask among wallet core > > > > > txn set: [https://github.com/bitcoin/bitcoin/blob/aabec94541e23a67a9f30dc2c80dab3383a01737/src/wallet/wallet.cpp\#L2519][https_github.com_bitcoin_bitcoin_blob_aabec94541e23a67a9f30dc2c80dab3383a01737_src_wallet_wallet.cpp_L2519] ? > > > > > > > > > > > In the case of a close, a failed collaborative close would result in an error and a uninlateral close" > > > > > Or can we do first a mutual closing tx, hold tx broadcast for a bit if "opt\_dual\_fund" > > > > > is signaled to see if a tx\_construction + add\_funding\_input for the channel is received > > > > > soon ? At least that would be a dual opt-in to know than one party can submit a funding-outpoint > > > > > as part of a composed tx ? > > > > > > > > > > > > > > > > > > > > > > > > > Antoine > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Le lun. 27 janv. 2020 à 20:51, lisa neigut <[niftynei at gmail.com][niftynei_gmail.com]> a écrit : > > > > > > > > > > > > > > > > Some of the feedback I received from the check-in for the dual-funding proposal this past Monday was along the lines that we look at simplifying for breaking it into smaller, more manageable chunks. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > The biggest piece of the dual-funding protocol update is definitely the move from a single peer constructing a transaction to two participants. We're also going to likely want to reuse this portion of the protocol for batched closings and splicing. To that extent, it seemed useful to highlight it in a separate email. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > This is a change from the existing proposal in the dual-funding [PR \#524][PR _524] \-- it allows for the removal of inputs and outputs. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > The set of messages are as follows. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Note that the 'initiation' of this protocol will be different depending on the case of the transaction (open, close or splice): > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > 1. type: 440 \`tx\_add\_input\` > > > > > > > > > > > > 2. data: > > > > > > > > > > > > \* \[\`32\*byte\`:\`channel\_identifier\`\] > > > > > > > > > > > > \* \[\`u64\`:\`sats\`\] > > > > > > > > > > > > \* \[\`sha256\`:\`prevtx\_txid\`\] > > > > > > > > > > > > \* \[\`u32\`:\`prevtx\_vout\`\] > > > > > > > > > > > > \* \[\`u16\`:\`prevtx\_scriptpubkey\_len\`\] > > > > > > > > > > > > \* \[\`prevtx\_scriptpubkey\_len\*byte\`:\`prevtx\_scriptpubkey\`\] > > > > > > > > > > > > \* \[\`u16\`:\`max\_witness\_len\`\] > > > > > > > > > > > > \* \[\`u16\`:\`scriptlen\`\] > > > > > > > > > > > > \* \[\`scriptlen\*byte\`:\`script\`\] > > > > > > > > > > > > \* \[\`byte\`:\`signal\_rbf\`\] > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > 1. type: 442 \`tx\_add\_output\` > > > > > > > > > > > > 2. data: > > > > > > > > > > > > \* \[\`32\*byte\`:\`channel\_identifier\`\] > > > > > > > > > > > > \* \[\`u64\`:\`sats\`\] > > > > > > > > > > > > \* \[\`u16\`:\`scriptlen\`\] > > > > > > > > > > > > \* \[\`scriptlen\*byte\`:\`script\`\] > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > 1. type: 444 \`tx\_remove\_input\` > > > > > > > > > > > > 2. data: > > > > > > > > > > > > \* \[\`32\*byte\`:\`channel\_identifier\`\] > > > > > > > > > > > > \* \[\`sha256\`:\`prevtx\_txid\`\] > > > > > > > > > > > > \* \[\`u32\`:\`prevtx\_vout\`\] > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > 1. type: 446 \`tx\_remove\_output\` > > > > > > > > > > > > 2. data: > > > > > > > > > > > > \* \[\`32\*byte\`:\`channel\_identifier\`\] > > > > > > > > > > > > \* \[\`u64\`:\`sats\`\] > > > > > > > > > > > > \* \[\`u16\`:\`scriptlen\`\] > > > > > > > > > > > > \* \[\`scriptlen\*byte\`:\`script\`\] > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > 1. type: 448 \`tx\_complete\` > > > > > > > > > > > > 2. data: > > > > > > > > > > > > \* \[\`32\*byte\`:\`channel\_identifier\`\] > > > > > > > > > > > > \* \[\`u16\`:\`num\_inputs\`\] > > > > > > > > > > > > \* \[\`u16\`:\`num\_outputs\`\] > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > 1. type: 448 \`tx\_sigs\` > > > > > > > > > > > > 2. data: > > > > > > > > > > > > \* \[\`channel\_id\`:\`channel\_identifier\`\] > > > > > > > > > > > > \* \[\`u16\`:\`num\_witnesses\`\] > > > > > > > > > > > > \* \[\`num\_witnesses\*witness\_stack\`:\`witness\_stack\`\] > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > 1. subtype: \`witness\_stack\` > > > > > > > > > > > > 2. data: > > > > > > > > > > > > \* \[\`sha256\`:\`prevtx\_txid\`\] > > > > > > > > > > > > \* \[\`u32\`:\`prevtx\_vout\`\] > > > > > > > > > > > > \* \[\`u16\`:\`num\_input\_witness\`\] > > > > > > > > > > > > \* \[\`num\_input\_witness\*witness\_element\`:\`witness\_element\`\] > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > 1. subtype: \`witness\_element\` > > > > > > > > > > > > 2. data: > > > > > > > > > > > > \* \[\`u16\`:\`len\`\] > > > > > > > > > > > > \* \[\`len\*byte\`:\`witness\`\] > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > \#\# General Notes > > > > > > > > > > > > \- Validity of inputs/outputs is not checked until both peers have sent consecutive \`tx\_complete\` messages. > > > > > > > > > > > > \- Duplicate inputs or outputs is a protocol error. > > > > > > > > > > > > \- Feerate is set by the initiator, or in the case of a closing transaction, negotiated before the transaction construction is initiated. > > > > > > > > > > > > \- Every peer pays fees for the inputs + outputs they contribute, plus enough to cover the maximum estimate of their witnesses. Overpayment of fees is permissible. > > > > > > > > > > > > \- Initiator is responsible for contributing the output/input in question, i.e. the > > > > > > > > > > > > funding output in the case of an opening, or the funding input in the case of a close. > > > > > > > > > > > > (This means that the opener will pay for the opening output). In the case of a splice, > > > > > > > > > > > > the initiator of the splice pays for the funding tx's inclusion as an input and the > > > > > > > > > > > > new 'funding tx' output. > > > > > > > > > > > > \- Any contributor may signal that their input is RBF'able. The nSequence for this input should be set to 0xFEFF FFFF, 0xFFFFFFFF otherwise. > > > > > > > > > > > > \- The initiating peer is understood to be paying the fee for the shared transaction fields (nVersion \[4\], segwit marker + flag \[2\], input + output counts \[2-18\], witness count \[1-9\], nLocktime \[4\]; total \[13-40bytes\]) > > > > > > > > > > > > \- Inputs MUST be segwit compatible (PW\* or P2SH-PW\*) > > > > > > > > > > > > \- All output scripts must be standard > > > > > > > > > > > > \- nLocktime is always set to 0x00000000. > > > > > > > > > > > > \- The \`num\_inputs\` and \`num\_outputs\` in \`tx\_complete\` is a count of that peer’s final input and output contributions, net any removals. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > \- Either peer may add or remove inputs and outputs until both peers have successfully > > > > > > > > > > > > exchanged a \`tx\_complete\` message in succession. > > > > > > > > > > > > \- Either peer may only add or remove their own input or output. > > > > > > > > > > > > \- In the case that a \`tx\_complete\` agreement cannot be reached, either peer may > > > > > > > > > > > > fail the channel or open protocol (whatever is reasonable for the particular case) > > > > > > > > > > > > - In the case of a splice, this would be a soft error (channel returns to normal operation until > > > > > > > > > > > > otherwise failed or closed.) > > > > > > > > > > > > - In the case of an open, this would be a failure to open the channel. > > > > > > > > > > > > - In the case of a close, a failed collaborative close would result in an error and a unilateral close. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > \#\#\# Considering the Simple Open case (2 parties) > > > > > > > > > > > > \- Both peers signal \`opt\_dual\_fund\` > > > > > > > > > > > > \- Opener initiates a channel open with \`open\_channel2\` message, indicating the feerate for the opening transaction > > > > > > > > > > > > \- Accepter signals acceptance of channel open as proposed, including proposed feerate, via \`accept\_channel2\` > > > > > > > > > > > > \- Opener sends \`tx\_add\_output\`, with the funding output for the sum of both peer’s funding\_amount > > > > > > > > > > > > \- Opener sends \`tx\_add\_input\` for each input the wish to add to the funding transaction > > > > > > > > > > > > \- Opener sends \`tx\_add\_output\` for their change > > > > > > > > > > > > \- Opener sends \`tx\_complete\` > > > > > > > > > > > > \- Accepter sends \`tx\_add\_input\` for each input they wish to add to the funding transaction > > > > > > > > > > > > \- Accepter sends \`tx\_add\_output\` for their change. > > > > > > > > > > > > \- Accepter sends \`tx\_complete\` > > > > > > > > > > > > \- Opener sends \`tx\_complete\` > > > > > > > > > > > > \- Opener and accepter exchange commitment signatures; etc. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > \#\#\# Considering the Splice case: > > > > > > > > > > > > \- Both peers signal \`opt\_splice\_ok\` > > > > > > > > > > > > \- One peer initiates a splice, also signaling the feerate for the transaction. Exact protocol unspecified herein. > > > > > > > > > > > > \- Initiator sends \`tx\_add\_input\` with the original funding output > > > > > > > > > > > > \- Initiator sends \`tx\_add\_output\` with the new, post-splice funding output > > > > > > > > > > > > \- Initiator sends \`tx\_add\_input/output\` as needed to add all desired inputs + outputs > > > > > > > > > > > > \- Initiator sends \`tx\_complete\` > > > > > > > > > > > > \- Peer sends \`tx\_add\_input/output\` as needed to add all desired inputs + outputs > > > > > > > > > > > > \- Initiator sends \`tx\_complete\` > > > > > > > > > > > > \- Peer sends \`tx\_complete\` > > > > > > > > > > > > \- Initiator + peer exchange commitment signatures, etc. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > \#\#\# Considering the Close case: > > > > > > > > > > > > \- Both peers signal \`opt\_collaborative\_close\` in their \`node\_announcement\`. > > > > > > > > > > > > \- A peer initiates a close sending a \`shutdown\`, as per usual. > > > > > > > > > > > > \- A feerate is negotiated. Out of band for this particular portion of the protocol. > > > > > > > > > > > > \-The closing initiator (peer which first sent \`shutdown\`), sends \`tx\_add\_input\` to spend the funding output and \`tx\_add\_output\` to add their output for the channel closure. > > > > > > > > > > > > \- The peer responds with \`tx\_add\_output\`, adding their output to the close transaction. > > > > > > > > > > > > \- If \`option\_upfront\_shutdown\_script\` is flagged but no such output with a value at or within a reasonable feerate gap of the peer's funding output is present, then the peer must fail the channel. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > \#\# Updating a collaborative transaction with RBF: > > > > > > > > > > > > \- If any input is flagged as RBF’able, then the transaction is considered eligible for RBF > > > > > > > > > > > > \- RBF can be initiated by either party, and serves as an initiation for another round of transaction composition, as outlined above. > > > > > > > > > > > > \- Note that this section has been cribbed and re-purposed from the original RBF proposal for splicing, see https://www.learnbitcoin.com/archive/lists/lightning-dev/t/2018/splicing-proposal-now-with-rbf#m-41bd6437 > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > 1. type: 45 (\`init\_rbf\`) (\`option\_collaborative\_rbf\`) > > > > > > > > > > > > 2. data: > > > > > > > > > > > > \* \[\`32\`:\`channel\_id\`\] > > > > > > > > > > > > \* \[\`4\`:\`fee\_step\`\] > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Each \`fee\_step\` adds 1/4 (rounded down) to the initial > > > > > > > > > > > > transaction feerate. eg. if the initial feerate was 512 satoshis per kiloweight, \`fee\_step\` 1 > > > > > > > > > > > > is 512 + 512 / 4 = 640, \`fee\_step\` 2 is 640 + 640 / 4 = 800. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > The sender: > > > > > > > > > > > > - MUST set \`fee\_step\` greater than zero and greater than any prior \`fee\_step\`. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > The recipient: > > > > > > > > > > > > - if the new fee exceeds the sender's current balance minus reserve > > > > > > > > > > > > after it is applied to the splice transaction: > > > > > > > > > > > > - MUST error. > > > > > > > > > > > > > > > > > > > > > > > > NOTES: > > > > > > > > > > > > 1. 1/4 is a reasonable minimal RBF, but as each one requires more > > > > > > > > > > > > tracking by the recipient, serves to limit the number you can create. > > > > > > > > > > > > 2. Rule 4 of BIP125 requires a feerate increase to at least surpass the minimum transaction relay setting. Ratcheting by 25% should satisfy this requirement > > > > > > > > > > > > 3. An additional rule will be added to the checks of an RBF transaction that it must include at least one identical, replaceable input as the original transaction. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_ > > > > > > Lightning-dev mailing list > > > > > > [Lightning-dev at lists.linuxfoundation.org][Lightning-dev_lists.linuxfoundation.org] > > > > > > https://www.learnbitcoin.com/archive/lists/lightning-dev > > > > > >
[darosior_protonmail.com]: mailto:darosior at protonmail.com [antoine.riard_gmail.com]: mailto:antoine.riard at gmail.com [https_github.com_bitcoin_bitcoin_blob_aabec94541e23a67a9f30dc2c80dab3383a01737_src_wallet_wallet.cpp_L2519]: https://github.com/bitcoin/bitcoin/blob/aabec94541e23a67a9f30dc2c80dab3383a01737/src/wallet/wallet.cpp#L2519 [niftynei_gmail.com]: mailto:niftynei at gmail.com [PR _524]: https://github.com/lightningnetwork/lightning-rfc/pull/524 [Lightning-dev_lists.linuxfoundation.org]: mailto:Lightning-dev at lists.linuxfoundation.org
Good morning darosior, ariard, niftynei, and list,
Quoted text (9 lines)
> We could also consider PoDLE as used in JoinMarket, which solves a similar problem. > https://gist.github.com/AdamISZ/9cbba5e9408d23813ca8#defence-2-committing-to-a-utxo-in-publicplaintext-at-the-start-of-the-handshake > Basically, a PoDLE commits to a UTXO, without being trivially grindable from the UTXO set and also including a proof that the creator of the PoDLE knows the secret key behind it. > It can later be opened to reveal which UTXO the opener allocated. > If the opener aborts (i.e. does not provide its signatures to the funding transaction) then the acceptor can gossip the UTXO and the revealed PoDLE as well to the rest of Lightning, so that the opener at least cannot reuse the same UTXO to probe other potential acceptors. > (though, my understanding, there is no clear way to determine when we can safely delete old PoDLEs: maybe each node can keep it around for a month, which might be good enough to limit the practical ability of a snoop to probe other nodes) > I believe JoinMarket also has solved the issue of allowing a UTXO to be used at most N times (for example due to "honest" failures, such as connectivity interruptions which might cause an abort of the protocol); I think it involves appending a single byte to something that is hashed, and ensuring its value is less than N, so that it can only be used from 0 to N - 1 (and thus allow a UTXO to be used at most N times). > > Getting into contact with waxwing / Adam Gibson for this might be useful to fill out how PoDLE works and so on; basically, I believe this issue is a practically solved problem already for JoinMarket, though waxwing may be able to provide a more nuanced opinion.
I communicated with waxwing, and he said:
* See also: https://joinmarket.me/blog/blog/poodle \[sic\]. * The counter I mentioned is implemented using the second generator point. * The PoDLE construction requires the standard base point `G`, and another generator point `J`. * To create the generator point `J`, JoinMarket appends the counter byte (the one used to limit N number of uses of the same UTXO) to `G`, hashes it, then uses a coerce-to-point. * PoDLE is sometimes called DLEQ elsewhere. * There is no concrete answer on "when to delete old PoDLE"; JoinMarket never deletes (though they might if throughput increases). * Watermarks like `nLockTime`, `nSequence`, `nVersion` are currently fixed values; JoinMarket sees no reason to change this since equal-valued CoinJoins are otherwise obvious to chain analysis anyway. * But note: JoinMarket implements PayJoin, which is not otherwise obvious onchain, and does indeed do anti-fee-sniping emulation for PayJoin. * JoinMarket also strives to make similar feerates across users.
In any case, for myself, my thoughts are:
* I observe that our use-case is quite similar to a PayJoin: * The opener proposes to make a payment (to a channel between the opener and the acceptor, rather than outright giving control to the acceptor as in PayJoin). * The acceptor adds some UTXOs which will contribute to the payment output (i.e. the channel). * This probably does mean we want to later consider `nLockTime` anti-fee-sniping as well in multi-funded channel opens. * Speaking of multi-funded channel opens, it seems to me this interactive tx construction mechanism as well can be later used for channel factories. * Similarly, PoDLE techniques would be useful as well to multi-funded channel factories. * It would probably be a good idea to share PoDLE format with JoinMarket so we can share PoDLE with them (there could be bridges that share PoDLE between a JoinMarket maker and a Lightning node, and each network already has its own gossip protocols, so LN just needs a gossip protocol for sharing PoDLEs as well). * Probably we can mandate in some BOLT spec to retain PoDLE for at least a year or a month or two weeks or so, which should be enough to slow down probe attempts.
Regards, ZmnSCPxj
Hi ZmnSCPxj,
Using joinmarket's PoDLEs is a great idea, and it seems preferable to using a transaction chain with a distinguishable SIGHASH.
Just a naive question, what is described in https://gist.github.com/AdamISZ/9cbba5e9408d23813ca8#defence-2-committing-to-a-utxo-in-publicplaintext-at-the-start-of-the-handshake and https://joinmarket.me/blog/blog/poodle/ uses Schnorr signature. Can we use this protocol with ECDSA ?
I'm now thinking about how this could be integrated into niftynei's work on the dual-funded channel proposal. The PoDLE broadcast protocol seems to be the bigger part.
*Imagining the size of the monster PR if PoDLEs ever get integrated* Regards, Darosior
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐ Le vendredi, janvier 31, 2020 12:31 AM, ZmnSCPxj <ZmnSCPxj at protonmail.com> a écrit :
Quoted text (37 lines)
> Good morning darosior, ariard, niftynei, and list, > > > We could also consider PoDLE as used in JoinMarket, which solves a similar problem. > > https://gist.github.com/AdamISZ/9cbba5e9408d23813ca8#defence-2-committing-to-a-utxo-in-publicplaintext-at-the-start-of-the-handshake > > Basically, a PoDLE commits to a UTXO, without being trivially grindable from the UTXO set and also including a proof that the creator of the PoDLE knows the secret key behind it. > > It can later be opened to reveal which UTXO the opener allocated. > > If the opener aborts (i.e. does not provide its signatures to the funding transaction) then the acceptor can gossip the UTXO and the revealed PoDLE as well to the rest of Lightning, so that the opener at least cannot reuse the same UTXO to probe other potential acceptors. > > (though, my understanding, there is no clear way to determine when we can safely delete old PoDLEs: maybe each node can keep it around for a month, which might be good enough to limit the practical ability of a snoop to probe other nodes) > > I believe JoinMarket also has solved the issue of allowing a UTXO to be used at most N times (for example due to "honest" failures, such as connectivity interruptions which might cause an abort of the protocol); I think it involves appending a single byte to something that is hashed, and ensuring its value is less than N, so that it can only be used from 0 to N - 1 (and thus allow a UTXO to be used at most N times). > > Getting into contact with waxwing / Adam Gibson for this might be useful to fill out how PoDLE works and so on; basically, I believe this issue is a practically solved problem already for JoinMarket, though waxwing may be able to provide a more nuanced opinion. > > I communicated with waxwing, and he said: > > - See also: https://joinmarket.me/blog/blog/poodle \[sic\]. > - The counter I mentioned is implemented using the second generator point. > - The PoDLE construction requires the standard base point `G`, and another generator point `J`. > - To create the generator point `J`, JoinMarket appends the counter byte (the one used to limit N number of uses of the same UTXO) to `G`, hashes it, then uses a coerce-to-point. > - PoDLE is sometimes called DLEQ elsewhere. > - There is no concrete answer on "when to delete old PoDLE"; JoinMarket never deletes (though they might if throughput increases). > - Watermarks like `nLockTime`, `nSequence`, `nVersion` are currently fixed values; JoinMarket sees no reason to change this since equal-valued CoinJoins are otherwise obvious to chain analysis anyway. > - But note: JoinMarket implements PayJoin, which is not otherwise obvious onchain, and does indeed do anti-fee-sniping emulation for PayJoin. > - JoinMarket also strives to make similar feerates across users. > > In any case, for myself, my thoughts are: > > - I observe that our use-case is quite similar to a PayJoin: > - The opener proposes to make a payment (to a channel between the opener and the acceptor, rather than outright giving control to the acceptor as in PayJoin). > - The acceptor adds some UTXOs which will contribute to the payment output (i.e. the channel). > - This probably does mean we want to later consider `nLockTime` anti-fee-sniping as well in multi-funded channel opens. > - Speaking of multi-funded channel opens, it seems to me this interactive tx construction mechanism as well can be later used for channel factories. > - Similarly, PoDLE techniques would be useful as well to multi-funded channel factories. > - It would probably be a good idea to share PoDLE format with JoinMarket so we can share PoDLE with them (there could be bridges that share PoDLE between a JoinMarket maker and a Lightning node, and each network already has its own gossip protocols, so LN just needs a gossip protocol for sharing PoDLEs as well). > - Probably we can mandate in some BOLT spec to retain PoDLE for at least a year or a month or two weeks or so, which should be enough to slow down probe attempts. > > Regards, > ZmnSCPxj >
Good morning darosior,
Quoted text (5 lines)
> Hi ZmnSCPxj, > > Using joinmarket's PoDLEs is a great idea, and it seems preferable to using a transaction chain with a distinguishable SIGHASH. > > Just a naive question, what is described in https://gist.github.com/AdamISZ/9cbba5e9408d23813ca8#defence-2-committing-to-a-utxo-in-publicplaintext-at-the-start-of-the-handshake and https://joinmarket.me/blog/blog/poodle/ uses Schnorr signature. Can we use this protocol with ECDSA ?
I cannot really grok the exact mathematics of ECDSA, and the signing scheme for PoDLE is not *exactly* Schnorr but certainly uses the same schema.
It looks to me that the DLEQ proof is based on Fiat-Shamir (as Schnorr signing is), though you might do better from an answer from an actual cryptographer.
In any case it is not used onchain anyway, and it is not going to be exactly the same as normal ECDSA signing so code reuse is still unlikely.
Quoted text (3 lines)
> I'm now thinking about how this could be integrated into niftynei's work on the dual-funded channel proposal. The PoDLE broadcast protocol seems to be the bigger part. > > Imagining the size of the monster PR if PoDLEs ever get integrated
Another wrinkle is that, PoDLE needs to be exchanged if the acceptor wants to add its own funds. If the opener offers to open a channel but the acceptor is not interested in revealing its own funds, then the opener need not reveal PoDLE of its UTXOs.
It seems to me that individual PoDLEs are small enough (32 bytes, `h(P2)` is all you need for the commitment, the signature-like thing is part of the opening, if my understanding is correct) that a simple gossip protocol might work.
Regards, ZmnSCPxj
Rusty had some suggestions about how to improve the protocol messages for this, namely adding a serial_id to the inputs and outputs, which can then be reused for deletions.
The serial id can then also be used as the ordering heuristic for transaction inputs during construction (replacing current usage of BIP69). Inputs can be shared amongst peers by flipping the bottom bit of the serial_id before relaying them to another peer (as your own).
See below for details.
1. type: 440 `tx_add_input`
Quoted text (5 lines)
> > 2. data: > > * [`32*byte`:`channel_identifier`] >
* [`32*byte`:``serial_id`]
Add a serial id.
Each input addition must have a unique serial id.
No addition may have a repeated id number.
The initiator's serial id's must be odd. The non-initiator's serial id's must be even. Serial ids are used as sorting heuristic for input ordering in final transaction, replaces BIP69
* [`u64`:`sats`]
Quoted text (16 lines)
> > * [`sha256`:`prevtx_txid`] > > * [`u32`:`prevtx_vout`] > > * [`u16`:`prevtx_scriptpubkey_len`] > > * [`prevtx_scriptpubkey_len*byte`:`prevtx_scriptpubkey`] > > * [`u16`:`max_witness_len`] > > * [`u16`:`scriptlen`] > > * [`scriptlen*byte`:`script`] > > Removes the signal_rbf; everything will be flagged as RBF eligible. (This
makes verifying RBF eligibility during a RBF round simpler.)
Quoted text (6 lines)
> 1. type: 442 `tx_add_output` > > 2. data: > > * [`32*byte`:`channel_identifier`] >
* [`16*byte`:`serial_id`]
Add a serial id. Same rules as for inputs, but a distinct counter set is used. Used for ordering the transactions’ outputs, replacing BIP69
Quoted text (12 lines)
> * [`u64`:`sats`] > > * [`u16`:`scriptlen`] > > * [`scriptlen*byte`:`script`] > > 1. type: 444 `tx_remove_input` > > 2. data: > > * [`32*byte`:`channel_identifier`] >
* [`16*byte`:`serial_id`]
Input to remove identified by the serial id, not txid and index.
Quoted text (7 lines)
> > 1. type: 446 `tx_remove_output` > > 2. data: > > * [`32*byte`:`channel_identifier`] >
* [`16*byte`:`serial_id]
Output to remove identified by the serial id, not output script and amount.
Quoted text (6 lines)
> 1. type: 448 `tx_complete` > > 2. data: > > * [`32*byte`:`channel_identifier`] >
Total counts removed from tx_complete. The txid exchanged in the `tx_sigs` will serves as a checksum for the transaction.
Quoted text (14 lines)
> 1. type: 448 `tx_sigs` > > 2. data: > > * [`channel_id`:`channel_identifier`] > > * [`u16`:`num_witnesses`] > > * [`num_witnesses*witness_stack`:`witness_stack`] > > 1. subtype: `witness_stack` > > 2. data: >
* [`u16`:`num_input_witness`]
Quoted text (3 lines)
> > * [`num_input_witness*witness_element`:`witness_element`] >
prev_out and prev_txid are removed; witnesses ordered implicitly by serial_id.
Quoted text (16 lines)
> 1. subtype: `witness_element` > > 2. data: > > * [`u16`:`len`] > > * [`len*byte`:`witness`] > > > > ## General Notes > > - All output scripts must be standard > > - nLocktime is always set to 0x00000000 >
- If a blockheight to be used as nLocktime is communicated in the initiation step, is set to blockheight-6; otherwise set to zero- - Serial ids should be chosen at random - For multiparty constructions, the initiator MUST flip the bottom bit of any received inputs before relaying them to a peer. - Collisions of serial ids between peers is a protocol error
Good morning niftynei,
Quoted text (3 lines)
> Rusty had some suggestions about how to improve the protocol messages for this, namely adding a serial_id to the inputs and outputs, which can then be reused for deletions. > > The serial id can then also be used as the ordering heuristic for transaction inputs during construction (replacing current usage of BIP69). Inputs can be shared amongst peers by flipping the bottom bit of the serial_id before relaying them to another peer (as your own).
What happens if the initiator deliberately provides serial IDs 0x1, 0x3, .... while the acceptor naively provides serial IDs from `/dev/urandom`?
Then the balance of probability is that the initiator inputs and outputs are sorted before the acceptor. Now, this is probably not an issue, since the initiator and acceptor both know which inputs and outputs are theirs and not theirs, so they could just reveal this information to anyone, so an actor providing such lousy serial IDs is just hurting its own privacy relative to blockchain analysts, so probably will not happen in practice.
My initial reaction was to propose adding a secret-sharing round where the resulting key is XORed to each serial ID before sorting by the XORed serial ID, but this might be too overweight, and again the initiator is only hurting its own privacy, and the two participants already know whose money is whose anyway....
Quoted text (39 lines)
> > See below for details. > > > 1. type: 440 `tx_add_input` > > > > 2. data: > > > > * [`32*byte`:`channel_identifier`] > > * [`32*byte`:``serial_id`] > > Add a serial id. > > Each input addition must have a unique serial id. > > No addition may have a repeated id number. > > The initiator's serial id's must be odd. The non-initiator's serial id's must be even. > > Serial ids are used as sorting heuristic for input ordering in final transaction, replaces BIP69 > > > > * [`u64`:`sats`] > > > > * [`sha256`:`prevtx_txid`] > > > > * [`u32`:`prevtx_vout`] > > > > * [`u16`:`prevtx_scriptpubkey_len`] > > > > * [`prevtx_scriptpubkey_len*byte`:`prevtx_scriptpubkey`] > > > > * [`u16`:`max_witness_len`] > > > > * [`u16`:`scriptlen`] > > > > * [`scriptlen*byte`:`script`] > > Removes the signal_rbf; everything will be flagged as RBF eligible. (This makes verifying RBF eligibility during a RBF round simpler.)
Yes. Ish. RBF and privacy do not work well together unfortunately. This is still initiator-pays, right?
Quoted text (15 lines)
> > 1. subtype: `witness_element` > > > > 2. data: > > > > * [`u16`:`len`] > > > > * [`len*byte`:`witness`] > > > > ## General Notes > > > > - All output scripts must be standard > > > > - nLocktime is always set to 0x00000000 > > - If a blockheight to be used as nLocktime is communicated in the initiation step, is set to blockheight-6; otherwise set to zero-
I am unsure what is the purpose of this minus 6.
If you fear blockheight disagreements, this is probably a good time to introduce block headers. So for example if the acceptor thinks the initiator blockheight is too high, it could challenge the initiator to give block headers from its known blockheight to the initiator blockheight. If the acceptor thinks the initiator blockheight is too low, it could provide block headers itself as proof. This could be limited so that gross differences in blockheight are outright rejected by the acceptor (it could `error` the temporary channel ID rather than accept it).
This is SPV, but neither side is actually making or accepting a payment *yet*, just synchronizing clocks, so maybe not as bad as normal SPV.
Massive chain reorgs cannot reduce blockheight, only increase it (else the reorg attempt fails in the first place) so there must still exist at least one chain(split) with the highest known blockheight already given a proof-of-header-chain, and all you really need is some mining activity on top of *one* split that confirms your funding transaction.
If it is not because of blockheight disagreements or massive chain reorgs, what is the purpose of `blockheight - 6`?
Quoted text (4 lines)
> - Serial ids should be chosen at random > - For multiparty constructions, the initiator MUST flip the bottom bit of any received inputs before relaying them to a peer. > > - Collisions of serial ids between peers is a protocol error
I suppose we should define collision to mean "equal in all bits except the lowest bit".
Regards, ZmnSCPxj
Quoted text (1 line)
> I am unsure what is the purpose of this minus 6.
The original motivation was to keep the funding transaction from being rejected from the mempool in the case of a re-org, but as you pointed out, the 'next block' is always at -par or ahead of the current chain tip, so I'm not sure this accomplishes this goal. I'm not sure how bitcoind handles the mempool in the case of the 'best block' moving to another tip, the goal of setting it to -6 is to avoid the funding transaction being evicted.
In practice, setting the locktime back a few blocks makes the funding transaction eligible for inclusion in any of the previous six blocks, so in case of a reorg there's a higher probability it will have been included in the reorganization. In other words, it enables fee-sniping for up to 6 blocks in the hopes that any 'eligible' re-org includes the funding transaction (the short channel id will change, but otherwise the channel open will be the same).
On second thought, this doesn't seem like something that we should include at the protocol level; if a peer wanted to 'allow fee-sniping for up to X blocks', then they'd simply relay the "blocktip" that they're using for the nLocktime to be at the depth they'd desire. Though it might be worth imposing a limit as to how far back in the past a peer can allow fee-sniping for... no more than 6 blocks from our current tip seems reasonable. (This would then limit the 'acceptable range' for an offset of an initiator to 5, as your peer may be off from your tip by one.)
On that note, I believe bitcoind fuzzes the nLocktime value to obfuscate exactly what blockheight the outgoing transaction was composed / broadcast at, which is probably something we should encourage in lightning implementations as well.
On Wed, Feb 5, 2020 at 8:25 PM ZmnSCPxj <ZmnSCPxj at protonmail.com> wrote:
Quoted text (134 lines)
> Good morning niftynei, > > > > Rusty had some suggestions about how to improve the protocol messages > for this, namely adding a serial_id to the inputs and outputs, which can > then be reused for deletions. > > > > The serial id can then also be used as the ordering heuristic for > transaction inputs during construction (replacing current usage of BIP69). > Inputs can be shared amongst peers by flipping the bottom bit of the > serial_id before relaying them to another peer (as your own). > > What happens if the initiator deliberately provides serial IDs 0x1, 0x3, > .... while the acceptor naively provides serial IDs from `/dev/urandom`? > > Then the balance of probability is that the initiator inputs and outputs > are sorted before the acceptor. > Now, this is probably not an issue, since the initiator and acceptor both > know which inputs and outputs are theirs and not theirs, so they could just > reveal this information to anyone, so an actor providing such lousy serial > IDs is just hurting its own privacy relative to blockchain analysts, so > probably will not happen in practice. > > My initial reaction was to propose adding a secret-sharing round where the > resulting key is XORed to each serial ID before sorting by the XORed serial > ID, but this might be too overweight, and again the initiator is only > hurting its own privacy, and the two participants already know whose money > is whose anyway.... > > > > > See below for details. > > > > > 1. type: 440 `tx_add_input` > > > > > > 2. data: > > > > > > * [`32*byte`:`channel_identifier`] > > > > * [`32*byte`:``serial_id`] > > > > Add a serial id. > > > > Each input addition must have a unique serial id. > > > > No addition may have a repeated id number. > > > > The initiator's serial id's must be odd. The non-initiator's serial id's > must be even. > > > > Serial ids are used as sorting heuristic for input ordering in final > transaction, replaces BIP69 > > > > > > > * [`u64`:`sats`] > > > > > > * [`sha256`:`prevtx_txid`] > > > > > > * [`u32`:`prevtx_vout`] > > > > > > * [`u16`:`prevtx_scriptpubkey_len`] > > > > > > * [`prevtx_scriptpubkey_len*byte`:`prevtx_scriptpubkey`] > > > > > > * [`u16`:`max_witness_len`] > > > > > > * [`u16`:`scriptlen`] > > > > > > * [`scriptlen*byte`:`script`] > > > > Removes the signal_rbf; everything will be flagged as RBF eligible. > (This makes verifying RBF eligibility during a RBF round simpler.) > > Yes. Ish. > RBF and privacy do not work well together unfortunately. > This is still initiator-pays, right? > > > > > 1. subtype: `witness_element` > > > > > > 2. data: > > > > > > * [`u16`:`len`] > > > > > > * [`len*byte`:`witness`] > > > > > > ## General Notes > > > > > > - All output scripts must be standard > > > > > > - nLocktime is always set to 0x00000000 > > > > - If a blockheight to be used as nLocktime is communicated in the > initiation step, is set to blockheight-6; otherwise set to zero- > > I am unsure what is the purpose of this minus 6. > > If you fear blockheight disagreements, this is probably a good time to > introduce block headers. > So for example if the acceptor thinks the initiator blockheight is too > high, it could challenge the initiator to give block headers from its known > blockheight to the initiator blockheight. > If the acceptor thinks the initiator blockheight is too low, it could > provide block headers itself as proof. > This could be limited so that gross differences in blockheight are > outright rejected by the acceptor (it could `error` the temporary channel > ID rather than accept it). > > This is SPV, but neither side is actually making or accepting a payment > *yet*, just synchronizing clocks, so maybe not as bad as normal SPV. > > Massive chain reorgs cannot reduce blockheight, only increase it (else the > reorg attempt fails in the first place) so there must still exist at least > one chain(split) with the highest known blockheight already given a > proof-of-header-chain, and all you really need is some mining activity on > top of *one* split that confirms your funding transaction. > > If it is not because of blockheight disagreements or massive chain reorgs, > what is the purpose of `blockheight - 6`? > > > > > - Serial ids should be chosen at random > > - For multiparty constructions, the initiator MUST flip the bottom bit > of any received inputs before relaying them to a peer. > > > > - Collisions of serial ids between peers is a protocol error > > I suppose we should define collision to mean "equal in all bits except the > lowest bit". > > Regards, > ZmnSCPxj > >
Good morning lisa,
Quoted text (3 lines)
> > I am unsure what is the purpose of this minus 6. > > The original motivation was to keep the funding transaction from being rejected from the mempool in the case of a re-org, but as you pointed out, the 'next block' is always at -par or ahead of the current chain tip, so I'm not sure this accomplishes this goal. I'm not sure how bitcoind handles the mempool in the case of the 'best block' moving to another tip, the goal of setting it to -6 is to avoid the funding transaction being evicted.
My understanding is that it rewinds the abandoned tip, putting the transactions in those blocks back into its local mempool (which may lead to evictions if the mempool gets full), all the way to the branch-off point, then it re-adds blocks back to the new tip (which can lead to removals from the mempool, if transactions in the block spend the same UTXOs (or *are* the same transactions) as transactions in the mempool). The main effect is that there could be suddenly higher fee pressure for the transactions in the reorged-away blocks (because of possible mempool congestion if the longer chainsplit has fewer transactions per block), but that is why the dual-funding protocol has RBF built-in right?
Setting blockheight - 6 also increases the incentive of potential deliberate reorgers to actually perform a reorg attack, because the transaction you just added is valid for earlier blocks that the reorger wants to rewrite. This is a bad thing, because you want your funding txout to be confirmed, not have parts of global hashpower contemplating reorgs and delaying your confirmations even more.
Quoted text (6 lines)
> > In practice, setting the locktime back a few blocks makes the funding transaction eligible for inclusion in any of the previous six blocks, so in case of a reorg there's a higher probability it will have been included in the reorganization. In other words, it enables fee-sniping for up to 6 blocks in the hopes that any 'eligible' re-org includes the funding transaction (the short channel id will change, but otherwise the channel open will be the same). > > On second thought, this doesn't seem like something that we should include at the protocol level; if a peer wanted to 'allow fee-sniping for up to X blocks', then they'd simply relay the "blocktip" that they're using for the nLocktime to be at the depth they'd desire. Though it might be worth imposing a limit as to how far back in the past a peer can allow fee-sniping for... no more than 6 blocks from our current tip seems reasonable. (This would then limit the 'acceptable range' for an offset of an initiator to 5, as your peer may be off from your tip by one.) > > On that note, I believe bitcoind fuzzes the nLocktime value to obfuscate exactly what blockheight the outgoing transaction was composed / broadcast at, which is probably something we should encourage in lightning implementations as well.
But if you impose the blockheight - 6 in the Lightning protocol level, and Lightning succeeds (meaning a substantial fraction of blockchain transactions are Lightning opens) --- then transactions with `nLockTime` equal to the block they are included in minus 5 will be more common than others, and would be a reliable indicator that the transaction is a Lightning channel funding attempt. The fuzzing may not be big enough to cover that, as there is a 10% chance to fuzz and about 1% subsequent chance (total 0.1% chance) that Bitcoin ore will put a transaction at blockheight - 6 (as opposed to the 99 other possibilities: blockheight - 0 to blockheight - 99 inclusive). So once more than 0.1% of onchain transactions are Lightning dual-fundings, an analyst has > 50% chance of correctly betting that a blockheight - 5 transaction (yes, - 5, because a transaction can typically be added only on the next block) is a Lightning funding.
You are better off with blockheight, possibly with SPV-header-chain-proofs if one side or the other thinks the blockheight has changed since one side or the other proposed it.
Regards, ZmnSCPxj
Quoted text (98 lines)
> > On Wed, Feb 5, 2020 at 8:25 PM ZmnSCPxj <ZmnSCPxj at protonmail.com> wrote: > > > Good morning niftynei, > > > > > Rusty had some suggestions about how to improve the protocol messages for this, namely adding a serial_id to the inputs and outputs, which can then be reused for deletions. > > > > > > The serial id can then also be used as the ordering heuristic for transaction inputs during construction (replacing current usage of BIP69). Inputs can be shared amongst peers by flipping the bottom bit of the serial_id before relaying them to another peer (as your own). > > > > What happens if the initiator deliberately provides serial IDs 0x1, 0x3, .... while the acceptor naively provides serial IDs from `/dev/urandom`? > > > > Then the balance of probability is that the initiator inputs and outputs are sorted before the acceptor. > > Now, this is probably not an issue, since the initiator and acceptor both know which inputs and outputs are theirs and not theirs, so they could just reveal this information to anyone, so an actor providing such lousy serial IDs is just hurting its own privacy relative to blockchain analysts, so probably will not happen in practice. > > > > My initial reaction was to propose adding a secret-sharing round where the resulting key is XORed to each serial ID before sorting by the XORed serial ID, but this might be too overweight, and again the initiator is only hurting its own privacy, and the two participants already know whose money is whose anyway.... > > > > > > > > See below for details. > > > > > > > 1. type: 440 `tx_add_input` > > > > > > > > 2. data: > > > > > > > > * [`32*byte`:`channel_identifier`] > > > > > > * [`32*byte`:``serial_id`] > > > > > > Add a serial id. > > > > > > Each input addition must have a unique serial id. > > > > > > No addition may have a repeated id number. > > > > > > The initiator's serial id's must be odd. The non-initiator's serial id's must be even. > > > > > > Serial ids are used as sorting heuristic for input ordering in final transaction, replaces BIP69 > > > > > > > > > > * [`u64`:`sats`] > > > > > > > > * [`sha256`:`prevtx_txid`] > > > > > > > > * [`u32`:`prevtx_vout`] > > > > > > > > * [`u16`:`prevtx_scriptpubkey_len`] > > > > > > > > * [`prevtx_scriptpubkey_len*byte`:`prevtx_scriptpubkey`] > > > > > > > > * [`u16`:`max_witness_len`] > > > > > > > > * [`u16`:`scriptlen`] > > > > > > > > * [`scriptlen*byte`:`script`] > > > > > > Removes the signal_rbf; everything will be flagged as RBF eligible. (This makes verifying RBF eligibility during a RBF round simpler.) > > > > Yes. Ish. > > RBF and privacy do not work well together unfortunately. > > This is still initiator-pays, right? > > > > > > 1. subtype: `witness_element` > > > > > > > > 2. data: > > > > > > > > * [`u16`:`len`] > > > > > > > > * [`len*byte`:`witness`] > > > > > > > > ## General Notes > > > > > > > > - All output scripts must be standard > > > > > > > > - nLocktime is always set to 0x00000000 > > > > > > - If a blockheight to be used as nLocktime is communicated in the initiation step, is set to blockheight-6; otherwise set to zero- > > > > I am unsure what is the purpose of this minus 6. > > > > If you fear blockheight disagreements, this is probably a good time to introduce block headers. > > So for example if the acceptor thinks the initiator blockheight is too high, it could challenge the initiator to give block headers from its known blockheight to the initiator blockheight. > > If the acceptor thinks the initiator blockheight is too low, it could provide block headers itself as proof. > > This could be limited so that gross differences in blockheight are outright rejected by the acceptor (it could `error` the temporary channel ID rather than accept it). > > > > This is SPV, but neither side is actually making or accepting a payment *yet*, just synchronizing clocks, so maybe not as bad as normal SPV. > > > > Massive chain reorgs cannot reduce blockheight, only increase it (else the reorg attempt fails in the first place) so there must still exist at least one chain(split) with the highest known blockheight already given a proof-of-header-chain, and all you really need is some mining activity on top of *one* split that confirms your funding transaction. > > > > If it is not because of blockheight disagreements or massive chain reorgs, what is the purpose of `blockheight - 6`? > > > > > - Serial ids should be chosen at random > > > - For multiparty constructions, the initiator MUST flip the bottom bit of any received inputs before relaying them to a peer. > > > > > > - Collisions of serial ids between peers is a protocol error > > > > I suppose we should define collision to mean "equal in all bits except the lowest bit". > > > > Regards, > > ZmnSCPxj
Quoted text (7 lines)
> But if you impose the blockheight - 6 in the Lightning protocol level, and Lightning succeeds (meaning a substantial fraction of blockchain transactions are Lightning opens)... > --- then transactions with `nLockTime` equal to the block they are included in minus 5 will be more common than others, and would be a reliable indicator that the transaction is a Lightning channel funding attempt.
Ah good point. This can be mitigated by setting the acceptable range up to 100 then, matching the behavior of bitcoind. <https://github.com/bitcoin/bitcoin/blob/master/src/wallet/wallet.cpp#L2507-L2544>
On Thu, Feb 6, 2020 at 6:23 PM ZmnSCPxj <ZmnSCPxj at protonmail.com> wrote:
Quoted text (214 lines)
> Good morning lisa, > > > > I am unsure what is the purpose of this minus 6. > > > > The original motivation was to keep the funding transaction from being > rejected from the mempool in the case of a re-org, but as you pointed out, > the 'next block' is always at -par or ahead of the current chain tip, so > I'm not sure this accomplishes this goal. I'm not sure how bitcoind > handles the mempool in the case of the 'best block' moving to another tip, > the goal of setting it to -6 is to avoid the funding transaction being > evicted. > > My understanding is that it rewinds the abandoned tip, putting the > transactions in those blocks back into its local mempool (which may lead to > evictions if the mempool gets full), all the way to the branch-off point, > then it re-adds blocks back to the new tip (which can lead to removals from > the mempool, if transactions in the block spend the same UTXOs (or *are* > the same transactions) as transactions in the mempool). > The main effect is that there could be suddenly higher fee pressure for > the transactions in the reorged-away blocks (because of possible mempool > congestion if the longer chainsplit has fewer transactions per block), but > that is why the dual-funding protocol has RBF built-in right? > > Setting blockheight - 6 also increases the incentive of potential > deliberate reorgers to actually perform a reorg attack, because the > transaction you just added is valid for earlier blocks that the reorger > wants to rewrite. > This is a bad thing, because you want your funding txout to be confirmed, > not have parts of global hashpower contemplating reorgs and delaying your > confirmations even more. > > > > > > In practice, setting the locktime back a few blocks makes the funding > transaction eligible for inclusion in any of the previous six blocks, so in > case of a reorg there's a higher probability it will have been included in > the reorganization. In other words, it enables fee-sniping for up to 6 > blocks in the hopes that any 'eligible' re-org includes the funding > transaction (the short channel id will change, but otherwise the channel > open will be the same). > > > > On second thought, this doesn't seem like something that we should > include at the protocol level; if a peer wanted to 'allow fee-sniping for > up to X blocks', then they'd simply relay the "blocktip" that they're using > for the nLocktime to be at the depth they'd desire. Though it might be > worth imposing a limit as to how far back in the past a peer can allow > fee-sniping for... no more than 6 blocks from our current tip seems > reasonable. (This would then limit the 'acceptable range' for an offset of > an initiator to 5, as your peer may be off from your tip by one.) > > > > On that note, I believe bitcoind fuzzes the nLocktime value to obfuscate > exactly what blockheight the outgoing transaction was composed / broadcast > at, which is probably something we should encourage in lightning > implementations as well. > > But if you impose the blockheight - 6 in the Lightning protocol level, and > Lightning succeeds (meaning a substantial fraction of blockchain > transactions are Lightning opens) --- then transactions with `nLockTime` > equal to the block they are included in minus 5 will be more common than > others, and would be a reliable indicator that the transaction is a > Lightning channel funding attempt. > The fuzzing may not be big enough to cover that, as there is a 10% chance > to fuzz and about 1% subsequent chance (total 0.1% chance) that Bitcoin ore > will put a transaction at blockheight - 6 (as opposed to the 99 other > possibilities: blockheight - 0 to blockheight - 99 inclusive). > So once more than 0.1% of onchain transactions are Lightning > dual-fundings, an analyst has > 50% chance of correctly betting that a > blockheight - 5 transaction (yes, - 5, because a transaction can typically > be added only on the next block) is a Lightning funding. > > > You are better off with blockheight, possibly with SPV-header-chain-proofs > if one side or the other thinks the blockheight has changed since one side > or the other proposed it. > > > Regards, > ZmnSCPxj > > > > > On Wed, Feb 5, 2020 at 8:25 PM ZmnSCPxj <ZmnSCPxj at protonmail.com> wrote: > > > > > Good morning niftynei, > > > > > > > Rusty had some suggestions about how to improve the protocol > messages for this, namely adding a serial_id to the inputs and outputs, > which can then be reused for deletions. > > > > > > > > The serial id can then also be used as the ordering heuristic for > transaction inputs during construction (replacing current usage of BIP69). > Inputs can be shared amongst peers by flipping the bottom bit of the > serial_id before relaying them to another peer (as your own). > > > > > > What happens if the initiator deliberately provides serial IDs 0x1, > 0x3, .... while the acceptor naively provides serial IDs from > `/dev/urandom`? > > > > > > Then the balance of probability is that the initiator inputs and > outputs are sorted before the acceptor. > > > Now, this is probably not an issue, since the initiator and acceptor > both know which inputs and outputs are theirs and not theirs, so they could > just reveal this information to anyone, so an actor providing such lousy > serial IDs is just hurting its own privacy relative to blockchain analysts, > so probably will not happen in practice. > > > > > > My initial reaction was to propose adding a secret-sharing round where > the resulting key is XORed to each serial ID before sorting by the XORed > serial ID, but this might be too overweight, and again the initiator is > only hurting its own privacy, and the two participants already know whose > money is whose anyway.... > > > > > > > > > > > See below for details. > > > > > > > > > 1. type: 440 `tx_add_input` > > > > > > > > > > 2. data: > > > > > > > > > > * [`32*byte`:`channel_identifier`] > > > > > > > > * [`32*byte`:``serial_id`] > > > > > > > > Add a serial id. > > > > > > > > Each input addition must have a unique serial id. > > > > > > > > No addition may have a repeated id number. > > > > > > > > The initiator's serial id's must be odd. The non-initiator's serial > id's must be even. > > > > > > > > Serial ids are used as sorting heuristic for input ordering in final > transaction, replaces BIP69 > > > > > > > > > > > > > * [`u64`:`sats`] > > > > > > > > > > * [`sha256`:`prevtx_txid`] > > > > > > > > > > * [`u32`:`prevtx_vout`] > > > > > > > > > > * [`u16`:`prevtx_scriptpubkey_len`] > > > > > > > > > > * [`prevtx_scriptpubkey_len*byte`:`prevtx_scriptpubkey`] > > > > > > > > > > * [`u16`:`max_witness_len`] > > > > > > > > > > * [`u16`:`scriptlen`] > > > > > > > > > > * [`scriptlen*byte`:`script`] > > > > > > > > Removes the signal_rbf; everything will be flagged as RBF eligible. > (This makes verifying RBF eligibility during a RBF round simpler.) > > > > > > Yes. Ish. > > > RBF and privacy do not work well together unfortunately. > > > This is still initiator-pays, right? > > > > > > > > 1. subtype: `witness_element` > > > > > > > > > > 2. data: > > > > > > > > > > * [`u16`:`len`] > > > > > > > > > > * [`len*byte`:`witness`] > > > > > > > > > > ## General Notes > > > > > > > > > > - All output scripts must be standard > > > > > > > > > > - nLocktime is always set to 0x00000000 > > > > > > > > - If a blockheight to be used as nLocktime is communicated in the > initiation step, is set to blockheight-6; otherwise set to zero- > > > > > > I am unsure what is the purpose of this minus 6. > > > > > > If you fear blockheight disagreements, this is probably a good time to > introduce block headers. > > > So for example if the acceptor thinks the initiator blockheight is too > high, it could challenge the initiator to give block headers from its known > blockheight to the initiator blockheight. > > > If the acceptor thinks the initiator blockheight is too low, it could > provide block headers itself as proof. > > > This could be limited so that gross differences in blockheight are > outright rejected by the acceptor (it could `error` the temporary channel > ID rather than accept it). > > > > > > This is SPV, but neither side is actually making or accepting a > payment *yet*, just synchronizing clocks, so maybe not as bad as normal SPV. > > > > > > Massive chain reorgs cannot reduce blockheight, only increase it (else > the reorg attempt fails in the first place) so there must still exist at > least one chain(split) with the highest known blockheight already given a > proof-of-header-chain, and all you really need is some mining activity on > top of *one* split that confirms your funding transaction. > > > > > > If it is not because of blockheight disagreements or massive chain > reorgs, what is the purpose of `blockheight - 6`? > > > > > > > - Serial ids should be chosen at random > > > > - For multiparty constructions, the initiator MUST flip the bottom > bit of any received inputs before relaying them to a peer. > > > > > > > > - Collisions of serial ids between peers is a protocol error > > > > > > I suppose we should define collision to mean "equal in all bits except > the lowest bit". > > > > > > Regards, > > > ZmnSCPxj > > >
Here's some thoughts I had on PoDLE's and lightning. An enormous tip-of-the-hat is due to ZmnSCPxj for surfacing the work that JoinMarket has done here already.
- The initiating message (in the case of open channel, this would be `open_channel2`) is extended to include an 'H2' field in its TLV, a 32-byte hash commitment to the P2 key. - Only one H2 commitment is required. - The `tx_add_input` message, as specified previously, is extended to an include a TLV type. This must be present on the input addition that corresponds with the UTXO used for the originally transmitted commitment - The non-initiator SHOULD wait to send any `tx_add_input` messages of their own until after receiving a `tx_add_input` message with a valid PoDLE TLV extension.
1. tlvs: `add_input_tlvs`
2. types:
1. type: 1 (`proof_of_dle`)
2. data:
*[`64*byte`:`s||e`]
*[`33*byte`:pubkey`]
*[`33*byte`:pubkey2`]
- If the proof is incorrect, the non-initiator MAY fail the transaction collaboration or respond with `tx_complete`. There is no need for them to publish the PoDLE. - If the proof is correct, the non-initiator verifies that the commitment (hash of pubkey2) has not been communicated to them via gossip. - If the proof is not in their gossip store, the transaction collaboration continues. It is considered 'safe' for the non-initiator to send `tx_add_input` to their peer. - If the proof IS in their gossip store, the transaction collaboration SHOULD reply with `tx_complete`. It is considered 'unsafe' for the non-initiator to send `tx_add_input`. (This allows errored/erroring initiators to use blacklisted utxos, however it prevents them from privy to any other nodes' UTXO set.) - The initiator MUST NOT remove the committed to UTXO from the collaboration set.
- If the transaction collaboration fails/is errored by the initiator,
- the non-initiator SHOULD broadcast the original PoDLE commitment to
the gossip network.
- the non-initiator MAY delay broadcast to allow the initiating node to
re-attempt the open.
The gossip message for a PoDLE blacklist entry is as follows:
1. type: 259 (`podle_blacklist`)
2. data:
*[`signature`:`signature`]
*[`32*byte`:`H2`]
*[`point`:`node_id`]
*[`u32`:`timestamp`]
Note that the `node_id` is the id of the node that signs (and broadcasts) the blacklisted PoDLE. h/t to ZmnSCPxj for the gossip construction. The timestamp is added as a convenience for peers to trim/discard blacklist participants as they wish depending on time/staleness.
## Some Notes: - The JoinMarket protocol allows nodes to use any of a range of secondary points for J. Since the lightning version of this allows blacklisted UTXOs to still open channels, albeit without participation from the peer, it seems unnecessary to allow for more than one valid J point. I'd propose fixing the J the same zero-index point used by JoinMarket. This reduces the number of valid H2's that are available for any given utxo set, while also keeping blacklisted H2's compatible with the blacklist set generated by JoinMarket implementations. - The blacklist originates from the 'non-initiating' peer, and does not reveal the offending node's id. - Assuming that every node honestly participates in the blacklist, only verified H2's will be submitted to the blacklist - A malicious non-initiator can only prevent an honest initiator from using the committed UTXO for collaborative transactions; they won't prevent them from successfully initiating a one-sided transaction with honest peers. - Only nodes that have at least one public channel will be able to contribute to the public PoDLE blacklist. This means it's possible for a malicious initiator to grief non-public nodes without much consequence, however this requires the ability to send inbound messages to private nodes, i.e. more likely for a close or splice interaction. - As ZmnSCPxj has pointed out elsewhere, a malicious peer could broadcast junk H2's; it is acceptable to rate-limit the number of PoDLE blacklists generated by a peer.peer - It is possible for a malicious peer to fail to relay their `H2` entries in the blacklisted gossip set. - Duplicate H2 gossip should replace older timestamped versions. - Elsewhere we've had a discussion/concern over floods of PoDLE blacklist messages. It's possible for gossip message floods to originate from a malicious peer; they also might signal an ongoing probe attempt. Given a timestamp and a rough measure of the number of utxos' currently outstanding in the mempool, however, it should be possible to distinguish the two.
## Open Questions: - Should PoDLE be required for every collaborative transaction (opens, splices + closes), or only for opens? It seems reasonable to limit them just to opens, as for all others you'll already have a shared UTXO with the peer. - Is fixing the generator point too restrictive? JoinMarket allows for a range of acceptable NUMS (J) points (up to 256). The smaller the pool of eligible J's, the smaller the pool of potential blacklisted PoDLE's (up to no. NUMs * current utxo count). One upside to allowing a larger pool of J's means that the same UTXO can be retried on failure. One downside to allowing a pool of J's means that a single UTXO can be validly retried in a probe attack against a variety of peers.
On Thu, Jan 30, 2020 at 5:32 PM ZmnSCPxj <ZmnSCPxj at protonmail.com> wrote:
Quoted text (75 lines)
> Good morning darosior, ariard, niftynei, and list, > > > We could also consider PoDLE as used in JoinMarket, which solves a > similar problem. > > > https://gist.github.com/AdamISZ/9cbba5e9408d23813ca8#defence-2-committing-to-a-utxo-in-publicplaintext-at-the-start-of-the-handshake > > Basically, a PoDLE commits to a UTXO, without being trivially grindable > from the UTXO set and also including a proof that the creator of the PoDLE > knows the secret key behind it. > > It can later be opened to reveal which UTXO the opener allocated. > > If the opener aborts (i.e. does not provide its signatures to the > funding transaction) then the acceptor can gossip the UTXO and the revealed > PoDLE as well to the rest of Lightning, so that the opener at least cannot > reuse the same UTXO to probe other potential acceptors. > > (though, my understanding, there is no clear way to determine when we > can safely delete old PoDLEs: maybe each node can keep it around for a > month, which might be good enough to limit the practical ability of a snoop > to probe other nodes) > > I believe JoinMarket also has solved the issue of allowing a UTXO to be > used at most N times (for example due to "honest" failures, such as > connectivity interruptions which might cause an abort of the protocol); I > think it involves appending a single byte to something that is hashed, and > ensuring its value is less than N, so that it can only be used from 0 to N > - 1 (and thus allow a UTXO to be used at most N times). > > > > Getting into contact with waxwing / Adam Gibson for this might be useful > to fill out how PoDLE works and so on; basically, I believe this issue is a > practically solved problem already for JoinMarket, though waxwing may be > able to provide a more nuanced opinion. > > I communicated with waxwing, and he said: > > * See also: https://joinmarket.me/blog/blog/poodle \[sic\]. > * The counter I mentioned is implemented using the second generator point. > * The PoDLE construction requires the standard base point `G`, and > another generator point `J`. > * To create the generator point `J`, JoinMarket appends the counter byte > (the one used to limit N number of uses of the same UTXO) to `G`, hashes > it, then uses a coerce-to-point. > * PoDLE is sometimes called DLEQ elsewhere. > * There is no concrete answer on "when to delete old PoDLE"; JoinMarket > never deletes (though they might if throughput increases). > * Watermarks like `nLockTime`, `nSequence`, `nVersion` are currently fixed > values; JoinMarket sees no reason to change this since equal-valued > CoinJoins are otherwise obvious to chain analysis anyway. > * But note: JoinMarket implements PayJoin, which is not otherwise > obvious onchain, and does indeed do anti-fee-sniping emulation for PayJoin. > * JoinMarket also strives to make similar feerates across users. > > In any case, for myself, my thoughts are: > > * I observe that our use-case is quite similar to a PayJoin: > * The opener proposes to make a payment (to a channel between the opener > and the acceptor, rather than outright giving control to the acceptor as in > PayJoin). > * The acceptor adds some UTXOs which will contribute to the payment > output (i.e. the channel). > * This probably does mean we want to later consider `nLockTime` > anti-fee-sniping as well in multi-funded channel opens. > * Speaking of multi-funded channel opens, it seems to me this interactive > tx construction mechanism as well can be later used for channel factories. > * Similarly, PoDLE techniques would be useful as well to multi-funded > channel factories. > * It would probably be a good idea to share PoDLE format with JoinMarket > so we can share PoDLE with them (there could be bridges that share PoDLE > between a JoinMarket maker and a Lightning node, and each network already > has its own gossip protocols, so LN just needs a gossip protocol for > sharing PoDLEs as well). > * Probably we can mandate in some BOLT spec to retain PoDLE for at least a > year or a month or two weeks or so, which should be enough to slow down > probe attempts. > > Regards, > ZmnSCPxj >
I'd like to propose that we add a second commitment requirement to the PoDLE that JoinMarket uses, to limit the use of a commitment's validity to be only between an initiator and a single peer. Otherwise you can enable something I'll call the "pouncing venus-flytrap attack"[1]. Venus-flytrap because they sit in wait for victims; pouncing because the venus-flytrap then attacks other nodes using the provided fly/utxo bait.
## The Attack A malicious node sits and waits until another, honest, node initiates an open with them. They wait until the honest initiator has sent them the commitment and utxo proof. They then use the provided, non-blacklisted utxo and commitment proof to attempt to open a channel with as many other nodes as possible, simultaneously. They may either fail to respond or not fail the original channel open. They fail every other open attempt, simultaneously. Each of the nodes they've griefed will blacklist the provided UTXO; the honest initiator has now had their utxo blacklisted.
## Mitigation Have each initiator provide two commitments: one to the shared/global J point and one to a point that is found from the hash of the non-initiating node's node_id.[2]
The global-point commitment is the one that is blacklisted; the node_id's commitment prevents the other party from being able to re-use a commitment in another channel, as they'll be unable to produce a valid commitment to the point derived from the node_id of their victim (so the victim will know the commitment has been re-used).
This has implications for 'multi-channel opens', in that any node initiating an open MUST provide at least one utxo of their own. This seems like an acceptable limitation, imo.
The protocol adjustments required for this are :
- Add a second commitment to the TLV of `open_channel2`; two H2's, one for the 'global J' and one for the 'nodes J', with the global point commitment always appearing first. - The TLV type for the `tx_add_input` for the 'committed utxo' will now include an array of two `proof of dle's`, in commitment hash order.
1. tlvs: `add_input_tlvs`
2. types:
1. type: 1 (`proof_of_dle_array`)
2. data:
*[`2*proof_of_dle`]
1. subtype (`proof_of_dle`)
*[`64*byte`:`s||e`]
*[`33*byte`:pubkey`]
*[`33*byte`:pubkey2`]
A node that provides a valid global point but an invalid 'local point' commitment should be immediately errored on and potentially blacklisted. A failure of this type should *not* result in a blacklist of the global commitment.
[1] There's probably a better analogy here, but it's escaping me at the moment. [2] We reuse JoinMarket's NUMs point generation idea of appending a counter to a hash until a valid positive-public key point is found, but without the index.
On Mon, Feb 10, 2020 at 5:11 PM lisa neigut <niftynei at gmail.com> wrote:
Quoted text (183 lines)
> Here's some thoughts I had on PoDLE's and lightning. An enormous > tip-of-the-hat is due to ZmnSCPxj for surfacing the work that JoinMarket > has done here already. > > - The initiating message (in the case of open channel, this would be > `open_channel2`) is extended to include an 'H2' field in its TLV, a 32-byte > hash commitment to the P2 key. > - Only one H2 commitment is required. > - The `tx_add_input` message, as specified previously, is extended to an > include a TLV type. This must be present on the input addition that > corresponds with the UTXO used for the originally transmitted commitment > - The non-initiator SHOULD wait to send any `tx_add_input` messages of > their own until after receiving a `tx_add_input` message with a valid PoDLE > TLV extension. > > 1. tlvs: `add_input_tlvs` > 2. types: > 1. type: 1 (`proof_of_dle`) > 2. data: > *[`64*byte`:`s||e`] > *[`33*byte`:pubkey`] > *[`33*byte`:pubkey2`] > > - If the proof is incorrect, the non-initiator MAY fail the transaction > collaboration or respond with `tx_complete`. There is no need for them to > publish the PoDLE. > - If the proof is correct, the non-initiator verifies that the commitment > (hash of pubkey2) has not been communicated to them via gossip. > - If the proof is not in their gossip store, the transaction collaboration > continues. It is considered 'safe' for the non-initiator to send > `tx_add_input` to their peer. > - If the proof IS in their gossip store, the transaction collaboration > SHOULD reply with `tx_complete`. It is considered 'unsafe' for the > non-initiator to send `tx_add_input`. (This allows errored/erroring > initiators to use blacklisted utxos, however it prevents them from privy to > any other nodes' UTXO set.) > - The initiator MUST NOT remove the committed to UTXO from the > collaboration set. > > - If the transaction collaboration fails/is errored by the initiator, > - the non-initiator SHOULD broadcast the original PoDLE commitment to > the gossip network. > - the non-initiator MAY delay broadcast to allow the initiating node > to re-attempt the open. > > The gossip message for a PoDLE blacklist entry is as follows: > > 1. type: 259 (`podle_blacklist`) > 2. data: > *[`signature`:`signature`] > *[`32*byte`:`H2`] > *[`point`:`node_id`] > *[`u32`:`timestamp`] > > Note that the `node_id` is the id of the node that signs (and broadcasts) > the blacklisted PoDLE. h/t to ZmnSCPxj for the gossip construction. > The timestamp is added as a convenience for peers to trim/discard > blacklist participants as they wish depending on time/staleness. > > ## Some Notes: > - The JoinMarket protocol allows nodes to use any of a range of secondary > points for J. Since the lightning version of this allows blacklisted UTXOs > to still open channels, albeit without participation from the peer, it > seems unnecessary to allow for more than one valid J point. I'd propose > fixing the J the same zero-index point used by JoinMarket. This reduces the > number of valid H2's that are available for any given utxo set, while also > keeping blacklisted H2's compatible with the blacklist set generated by > JoinMarket implementations. > - The blacklist originates from the 'non-initiating' peer, and does not > reveal the offending node's id. > - Assuming that every node honestly participates in the blacklist, only > verified H2's will be submitted to the blacklist > - A malicious non-initiator can only prevent an honest initiator from > using the committed UTXO for collaborative transactions; they won't prevent > them from successfully initiating a one-sided transaction with honest peers. > - Only nodes that have at least one public channel will be able to > contribute to the public PoDLE blacklist. This means it's possible for a > malicious initiator to grief non-public nodes without much consequence, > however this requires the ability to send inbound messages to private > nodes, i.e. more likely for a close or splice interaction. > - As ZmnSCPxj has pointed out elsewhere, a malicious peer could broadcast > junk H2's; it is acceptable to rate-limit the number of PoDLE blacklists > generated by a peer.peer > - It is possible for a malicious peer to fail to relay their `H2` entries > in the blacklisted gossip set. > - Duplicate H2 gossip should replace older timestamped versions. > - Elsewhere we've had a discussion/concern over floods of PoDLE blacklist > messages. It's possible for gossip message floods to originate from a > malicious peer; they also might signal an ongoing probe attempt. Given a > timestamp and a rough measure of the number of utxos' currently outstanding > in the mempool, however, it should be possible to distinguish the two. > > ## Open Questions: > - Should PoDLE be required for every collaborative transaction (opens, > splices + closes), or only for opens? It seems reasonable to limit them > just to opens, as for all others you'll already have a shared UTXO with the > peer. > - Is fixing the generator point too restrictive? JoinMarket allows for a > range of acceptable NUMS (J) points (up to 256). The smaller the pool of > eligible J's, the smaller the pool of potential blacklisted PoDLE's (up to > no. NUMs * current utxo count). One upside to allowing a larger pool of J's > means that the same UTXO can be retried on failure. One downside to > allowing a pool of J's means that a single UTXO can be validly retried in a > probe attack against a variety of peers. > > On Thu, Jan 30, 2020 at 5:32 PM ZmnSCPxj <ZmnSCPxj at protonmail.com> wrote: > >> Good morning darosior, ariard, niftynei, and list, >> >> > We could also consider PoDLE as used in JoinMarket, which solves a >> similar problem. >> > >> https://gist.github.com/AdamISZ/9cbba5e9408d23813ca8#defence-2-committing-to-a-utxo-in-publicplaintext-at-the-start-of-the-handshake >> > Basically, a PoDLE commits to a UTXO, without being trivially grindable >> from the UTXO set and also including a proof that the creator of the PoDLE >> knows the secret key behind it. >> > It can later be opened to reveal which UTXO the opener allocated. >> > If the opener aborts (i.e. does not provide its signatures to the >> funding transaction) then the acceptor can gossip the UTXO and the revealed >> PoDLE as well to the rest of Lightning, so that the opener at least cannot >> reuse the same UTXO to probe other potential acceptors. >> > (though, my understanding, there is no clear way to determine when we >> can safely delete old PoDLEs: maybe each node can keep it around for a >> month, which might be good enough to limit the practical ability of a snoop >> to probe other nodes) >> > I believe JoinMarket also has solved the issue of allowing a UTXO to be >> used at most N times (for example due to "honest" failures, such as >> connectivity interruptions which might cause an abort of the protocol); I >> think it involves appending a single byte to something that is hashed, and >> ensuring its value is less than N, so that it can only be used from 0 to N >> - 1 (and thus allow a UTXO to be used at most N times). >> > >> > Getting into contact with waxwing / Adam Gibson for this might be >> useful to fill out how PoDLE works and so on; basically, I believe this >> issue is a practically solved problem already for JoinMarket, though >> waxwing may be able to provide a more nuanced opinion. >> >> I communicated with waxwing, and he said: >> >> * See also: https://joinmarket.me/blog/blog/poodle \[sic\]. >> * The counter I mentioned is implemented using the second generator point. >> * The PoDLE construction requires the standard base point `G`, and >> another generator point `J`. >> * To create the generator point `J`, JoinMarket appends the counter >> byte (the one used to limit N number of uses of the same UTXO) to `G`, >> hashes it, then uses a coerce-to-point. >> * PoDLE is sometimes called DLEQ elsewhere. >> * There is no concrete answer on "when to delete old PoDLE"; JoinMarket >> never deletes (though they might if throughput increases). >> * Watermarks like `nLockTime`, `nSequence`, `nVersion` are currently >> fixed values; JoinMarket sees no reason to change this since equal-valued >> CoinJoins are otherwise obvious to chain analysis anyway. >> * But note: JoinMarket implements PayJoin, which is not otherwise >> obvious onchain, and does indeed do anti-fee-sniping emulation for PayJoin. >> * JoinMarket also strives to make similar feerates across users. >> >> In any case, for myself, my thoughts are: >> >> * I observe that our use-case is quite similar to a PayJoin: >> * The opener proposes to make a payment (to a channel between the >> opener and the acceptor, rather than outright giving control to the >> acceptor as in PayJoin). >> * The acceptor adds some UTXOs which will contribute to the payment >> output (i.e. the channel). >> * This probably does mean we want to later consider `nLockTime` >> anti-fee-sniping as well in multi-funded channel opens. >> * Speaking of multi-funded channel opens, it seems to me this interactive >> tx construction mechanism as well can be later used for channel factories. >> * Similarly, PoDLE techniques would be useful as well to multi-funded >> channel factories. >> * It would probably be a good idea to share PoDLE format with JoinMarket >> so we can share PoDLE with them (there could be bridges that share PoDLE >> between a JoinMarket maker and a Lightning node, and each network already >> has its own gossip protocols, so LN just needs a gossip protocol for >> sharing PoDLEs as well). >> * Probably we can mandate in some BOLT spec to retain PoDLE for at least >> a year or a month or two weeks or so, which should be enough to slow down >> probe attempts. >> >> Regards, >> ZmnSCPxj >> >
Hi niftynei and list,
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐ Le mardi, février 11, 2020 12:11 AM, lisa neigut <niftynei at gmail.com> a écrit :
Quoted text (19 lines)
> Here's some thoughts I had on PoDLE's and lightning. An enormous tip-of-the-hat is due to ZmnSCPxj for surfacing the work that JoinMarket has done here already. > > - The initiating message (in the case of open channel, this would be `open_channel2`) is extended to include an 'H2' field in its TLV, a 32-byte hash commitment to the P2 key. > - Only one H2 commitment is required. > - The `tx_add_input` message, as specified previously, is extended to an include a TLV type. This must be present on the input addition that corresponds with the UTXO used for the originally transmitted commitment > - The non-initiator SHOULD wait to send any `tx_add_input` messages of their own until after receiving a `tx_add_input` message with a valid PoDLE TLV extension. > > 1. tlvs: `add_input_tlvs` > 2. types: > 1. type: 1 (`proof_of_dle`) > 2. data: > *[`64*byte`:`s||e`] > *[`33*byte`:pubkey`] > *[`33*byte`:pubkey2`] > > - If the proof is incorrect, the non-initiator MAY fail the transaction collaboration or respond with `tx_complete`. There is no need for them to publish the PoDLE. > - If the proof is correct, the non-initiator verifies that the commitment (hash of pubkey2) has not been communicated to them via gossip. > - If the proof is not in their gossip store, the transaction collaboration continues. It is considered 'safe' for the non-initiator to send `tx_add_input` to their peer. > - If the proof IS in their gossip store, the transaction collaboration SHOULD reply with `tx_complete`. It is considered 'unsafe' for the non-initiator to send `tx_add_input`. (This allows errored/erroring initiators to use blacklisted utxos, however it prevents them from privy to any other nodes' UTXO set.)
We could agree on an acceptable number of reuse in case on a non-malicious failure from the initiator after a valid PoDLE exchange ? (credits ZmnSCPxj)
Quoted text (28 lines)
> - The initiator MUST NOT remove the committed to UTXO from the collaboration set. > > - If the transaction collaboration fails/is errored by the initiator, > - the non-initiator SHOULD broadcast the original PoDLE commitment to the gossip network. > - the non-initiator MAY delay broadcast to allow the initiating node to re-attempt the open. > > The gossip message for a PoDLE blacklist entry is as follows: > > 1. type: 259 (`podle_blacklist`) > 2. data: > *[`signature`:`signature`] > *[`32*byte`:`H2`] > *[`point`:`node_id`] > *[`u32`:`timestamp`] > > Note that the `node_id` is the id of the node that signs (and broadcasts) the blacklisted PoDLE. h/t to ZmnSCPxj for the gossip construction. > The timestamp is added as a convenience for peers to trim/discard blacklist participants as they wish depending on time/staleness. > > ## Some Notes: > - The JoinMarket protocol allows nodes to use any of a range of secondary points for J. Since the lightning version of this allows blacklisted UTXOs to still open channels, albeit without participation from the peer, it seems unnecessary to allow for more than one valid J point. I'd propose fixing the J the same zero-index point used by JoinMarket. This reduces the number of valid H2's that are available for any given utxo set, while also keeping blacklisted H2's compatible with the blacklist set generated by JoinMarket implementations. > - The blacklist originates from the 'non-initiating' peer, and does not reveal the offending node's id. > - Assuming that every node honestly participates in the blacklist, only verified H2's will be submitted to the blacklist > - A malicious non-initiator can only prevent an honest initiator from using the committed UTXO for collaborative transactions; they won't prevent them from successfully initiating a one-sided transaction with honest peers. > - Only nodes that have at least one public channel will be able to contribute to the public PoDLE blacklist. This means it's possible for a malicious initiator to grief non-public nodes without much consequence, however this requires the ability to send inbound messages to private nodes, i.e. more likely for a close or splice interaction. > - As ZmnSCPxj has pointed out elsewhere, a malicious peer could broadcast junk H2's; it is acceptable to rate-limit the number of PoDLE blacklists generated by a peer.peer > - It is possible for a malicious peer to fail to relay their `H2` entries in the blacklisted gossip set. > - Duplicate H2 gossip should replace older timestamped versions. > - Elsewhere we've had a discussion/concern over floods of PoDLE blacklist messages. It's possible for gossip message floods to originate from a malicious peer; they also might signal an ongoing probe attempt. Given a timestamp and a rough measure of the number of utxos' currently outstanding in the mempool, however, it should be possible to distinguish the two.
Ok, so knowing where PoDLE originate from mitigates the flood we talked about with ZmnSCPxj. However I don't see how the number of utxos in the mempool is useful here, as you cannot distinguish which PoDLE is the real one out of the load you are receiving in case of a flood ?
Quoted text (43 lines)
> ## Open Questions: > - Should PoDLE be required for every collaborative transaction (opens, splices + closes), or only for opens? It seems reasonable to limit them just to opens, as for all others you'll already have a shared UTXO with the peer. > - Is fixing the generator point too restrictive? JoinMarket allows for a range of acceptable NUMS (J) points (up to 256). The smaller the pool of eligible J's, the smaller the pool of potential blacklisted PoDLE's (up to no. NUMs * current utxo count). One upside to allowing a larger pool of J's means that the same UTXO can be retried on failure. One downside to allowing a pool of J's means that a single UTXO can be validly retried in a probe attack against a variety of peers. > > On Thu, Jan 30, 2020 at 5:32 PM ZmnSCPxj <ZmnSCPxj at protonmail.com> wrote: > > > Good morning darosior, ariard, niftynei, and list, > > > > > We could also consider PoDLE as used in JoinMarket, which solves a similar problem. > > > https://gist.github.com/AdamISZ/9cbba5e9408d23813ca8#defence-2-committing-to-a-utxo-in-publicplaintext-at-the-start-of-the-handshake > > > Basically, a PoDLE commits to a UTXO, without being trivially grindable from the UTXO set and also including a proof that the creator of the PoDLE knows the secret key behind it. > > > It can later be opened to reveal which UTXO the opener allocated. > > > If the opener aborts (i.e. does not provide its signatures to the funding transaction) then the acceptor can gossip the UTXO and the revealed PoDLE as well to the rest of Lightning, so that the opener at least cannot reuse the same UTXO to probe other potential acceptors. > > > (though, my understanding, there is no clear way to determine when we can safely delete old PoDLEs: maybe each node can keep it around for a month, which might be good enough to limit the practical ability of a snoop to probe other nodes) > > > I believe JoinMarket also has solved the issue of allowing a UTXO to be used at most N times (for example due to "honest" failures, such as connectivity interruptions which might cause an abort of the protocol); I think it involves appending a single byte to something that is hashed, and ensuring its value is less than N, so that it can only be used from 0 to N - 1 (and thus allow a UTXO to be used at most N times). > > > > > > Getting into contact with waxwing / Adam Gibson for this might be useful to fill out how PoDLE works and so on; basically, I believe this issue is a practically solved problem already for JoinMarket, though waxwing may be able to provide a more nuanced opinion. > > > > I communicated with waxwing, and he said: > > > > * See also: https://joinmarket.me/blog/blog/poodle \[sic\]. > > * The counter I mentioned is implemented using the second generator point. > > * The PoDLE construction requires the standard base point `G`, and another generator point `J`. > > * To create the generator point `J`, JoinMarket appends the counter byte (the one used to limit N number of uses of the same UTXO) to `G`, hashes it, then uses a coerce-to-point. > > * PoDLE is sometimes called DLEQ elsewhere. > > * There is no concrete answer on "when to delete old PoDLE"; JoinMarket never deletes (though they might if throughput increases). > > * Watermarks like `nLockTime`, `nSequence`, `nVersion` are currently fixed values; JoinMarket sees no reason to change this since equal-valued CoinJoins are otherwise obvious to chain analysis anyway. > > * But note: JoinMarket implements PayJoin, which is not otherwise obvious onchain, and does indeed do anti-fee-sniping emulation for PayJoin. > > * JoinMarket also strives to make similar feerates across users. > > > > In any case, for myself, my thoughts are: > > > > * I observe that our use-case is quite similar to a PayJoin: > > * The opener proposes to make a payment (to a channel between the opener and the acceptor, rather than outright giving control to the acceptor as in PayJoin). > > * The acceptor adds some UTXOs which will contribute to the payment output (i.e. the channel). > > * This probably does mean we want to later consider `nLockTime` anti-fee-sniping as well in multi-funded channel opens. > > * Speaking of multi-funded channel opens, it seems to me this interactive tx construction mechanism as well can be later used for channel factories. > > * Similarly, PoDLE techniques would be useful as well to multi-funded channel factories. > > * It would probably be a good idea to share PoDLE format with JoinMarket so we can share PoDLE with them (there could be bridges that share PoDLE between a JoinMarket maker and a Lightning node, and each network already has its own gossip protocols, so LN just needs a gossip protocol for sharing PoDLEs as well). > > * Probably we can mandate in some BOLT spec to retain PoDLE for at least a year or a month or two weeks or so, which should be enough to slow down probe attempts. > > > > Regards, > > ZmnSCPxj
Good morning darosior, niftynei, and list,
Quoted text (2 lines)
> > We could agree on an acceptable number of reuse in case on a non-malicious failure from the initiator after a valid PoDLE exchange ? (credits ZmnSCPxj)
The default of 3 for JoinMarket seems reasonable.
Quoted text (3 lines)
> > Ok, so knowing where PoDLE originate from mitigates the flood we talked about with ZmnSCPxj. > However I don't see how the number of utxos in the mempool is useful here, as you cannot distinguish which PoDLE is the real one out of the load you are receiving in case of a flood ?
No idea either, but if we limit accepted `node_id`s to those that we have seen in a `node_announcement` before, then we ride on the fact that `node_announcement` is costly in the sense that somebody has to allocate at least some small amount of funds to a channel that is visible onchain, because `node_announcement` requires a `channel_announcement` with an anchored channel.
Then if nodes on the network can just send PoDLE gossip that they did not sign themselves, but are signed by *some* node that was `node_announcement`ed before, we can identify those nodes that are spamming a lot of their own signed PoDLE gossip, and rate-limit those.
It is likely that announced nodes are the ones who will have such attack attempts performed on them, so they are in the best position to inform others of such attempts and are the most likely to have such data.
At some point we probably also need to have set reconciliation for these as well.
Regards, ZmnSCPxj
Hi darosior, niftynei, and list,
waxwing replied the below text, and asked to propagate as well to lightning-dev. He has just recently re-subscribed to lightning-dev, but may be waiting for the necessary subscription notices or whatnot.
Regards, ZmnSCPxj
-----------
Re: Venus Flytrap attack and JoinMarket
This issue didn't crop up in our use case because takers always send out to 5-12 (typically) makers at once, and the HP2 only needs to get broadcast by one to stop any reuse. But whichever way you look at it, it's a very good point! And in LN case, seems like a very substantial attack (at least from what little I've read so far).
In case a brief summary of JM mechanism is helpful, here's the taker-maker conversation:
!fill amount, oid, commitment (HP2) -- this is where a taker sends to each maker an hp2 value. This is the step intended to enforce scarcity, and the assumption in JM was always that this would basically inevitably get shared. Because there are typically 5-12 makers involved, this seemed a reasonably safe assumption. If the commitment value is already used and thus not valid, it gets broadcast immediately. If it's not, it only gets shared as part of the !ioauth step below.
!pubkey key
-- this is just the maker giving an ephemeral key for the encryption
!auth (s, e, u, P, P2) -- (encrypted) this is the taker opening the above commitment. It's rather weird at first sight, because he is opening immediately after committing, with apparently no step inbetween; but in fact the implicit intermediate step is the broadcast (exactly what is being questioned with 'venus flytrap').
!ioauth maker-utxo-data -- notice the maker is only sending this utxo data (encrypted of course) after proof of ownership of the utxo above. It's only at this step that the hp2 commitment value is (a) added to the maker's local "used up" list, and (b)privmsged to 1 randomly chosen other bots in the trading pit, who then pubmsgs it to everyone (and that happens multiple times because multiple makers in tx), and they in turn record it as "used".
The mechanism is both not very strong - we use 3 allowed attempts per utxo - and imperfect in its "justice"; such commitments can be "used up" by failures of one's counterparties. But it does serve to stop trivial global snooping, and doesn't cost anything in terms of identity or locked funds, so it has served a purpose (we did actually see such attacks before it, and not after it).
I'd also note that in terms of the venus flytrap attack mentioned, there could be a small time window between one maker receiving !auth and at least one other honest maker getting to broadcast step at !ioauth; while I don't think that's very practical in our use case, it is for sure a theoretical concern and removing it could be either slightly, or extremely, important in another use case.
I'll have a look at this new idea related to node-id and get back to you on that. Thanks for this analysis and investigation, it's a very interesting area.
ZmnSCPxj via Lightning-dev <lightning-dev at lists.linuxfoundation.org> writes:
Quoted text (8 lines)
> Good morning niftynei, > > >> Rusty had some suggestions about how to improve the protocol messages for this, namely adding a serial_id to the inputs and outputs, which can then be reused for deletions. >> >> The serial id can then also be used as the ordering heuristic for transaction inputs during construction (replacing current usage of BIP69). Inputs can be shared amongst peers by flipping the bottom bit of the serial_id before relaying them to another peer (as your own). > > What happens if the initiator deliberately provides serial IDs 0x1, 0x3, .... while the acceptor naively provides serial IDs from `/dev/urandom`?
This is a feature, and one you might need to use if you have some SIGHASH_SINGLE or other weirdness for one input.
Quoted text (14 lines)
> Then the balance of probability is that the initiator inputs and outputs are sorted before the acceptor. > Now, this is probably not an issue, since the initiator and acceptor both know which inputs and outputs are theirs and not theirs, so they could just reveal this information to anyone, so an actor providing such lousy serial IDs is just hurting its own privacy relative to blockchain analysts, so probably will not happen in practice. > > My initial reaction was to propose adding a secret-sharing round where the resulting key is XORed to each serial ID before sorting by the XORed serial ID, but this might be too overweight, and again the initiator is only hurting its own privacy, and the two participants already know whose money is whose anyway.... >> > - nLocktime is always set to 0x00000000 >> >> - If a blockheight to be used as nLocktime is communicated in the initiation step, is set to blockheight-6; otherwise set to zero- > > I am unsure what is the purpose of this minus 6. > > If you fear blockheight disagreements, this is probably a good time to introduce block headers. > So for example if the acceptor thinks the initiator blockheight is too high, it could challenge the initiator to give block headers from its known blockheight to the initiator blockheight. > If the acceptor thinks the initiator blockheight is too low, it could provide block headers itself as proof. > This could be limited so that gross differences in blockheight are outright rejected by the acceptor (it could `error` the temporary channel ID rather than accept it).
Yes, I would just have the initiator specify nLocktime directly, just like feerate. If you don't like it, don't contribute to the tx construction.
Quoted text (4 lines)
> This is SPV, but neither side is actually making or accepting a payment *yet*, just synchronizing clocks, so maybe not as bad as normal SPV. > > Massive chain reorgs cannot reduce blockheight, only increase it (else > the reorg attempt fails in the first place)
This is not quite true, due to difficulty adjustments. It's true in practice, however, and not relevant since you'd just have to wait one more block.
Quoted text (6 lines)
>> - Serial ids should be chosen at random >> - For multiparty constructions, the initiator MUST flip the bottom bit of any received inputs before relaying them to a peer. >> >> - Collisions of serial ids between peers is a protocol error > > I suppose we should define collision to mean "equal in all bits except the lowest bit".
No, literally equal. i.e. you can only make this error by clashing with yourself.
Cheers, Rusty.
Good morning Rusty, niftynei, and list,
Quoted text (11 lines)
> > > - Serial ids should be chosen at random > > > > > > - For multiparty constructions, the initiator MUST flip the bottom bit of any received inputs before relaying them to a peer. > > > > > > - Collisions of serial ids between peers is a protocol error > > > > > > > I suppose we should define collision to mean "equal in all bits except the lowest bit". > > No, literally equal. i.e. you can only make this error by clashing with > yourself.
hmm, I thought the entire point of having the low bit was that you could multifund in such a way that the initiator creates multiple channels simultaneously with multiple nodes? So you would have to take the UTXOs of one peer and give it to the other peer claiming it as your own. Or something.
With PoDLE this would not be possible I think, as you would not be able to open the PoDLE commitment with the other node as the target (if we go with the modified PoDLE which also commits to which node an opening is for, to prevent the pouncing venus flytrap attack).
Regards, ZmnSCPxj
Quoted text (4 lines)
> With PoDLE this would not be possible I think, as you would not be able to open the PoDLE commitment with the other node as the target (if we go with the modified PoDLE which also commits to which node an opening is for, to prevent the pouncing venus flytrap attack).
Good question. It should be possible to do multi-channel open even with the PoDLE signature committing to a node_id.
- An initiator can use the same utxo (h2) as their proof for multiple peers; the signatures passed to each peer will have to commit to that specific peer's node_id, however. - The revised PoDLE signature commitment requires every initiator to include at least one of their own inputs in the tx. Attempting to initiate an additional open etc using someone else's utxo's won't work (this is the pouncing venus flytrap attack which we're preventing). The initiator including at least one input is expected behavior, at least in the open case, since the opener has to cover the fees for the funding output. - Ideally, a node would remove the PoDLE TLV data from any 'forwarded' `tx_add_inputs` that isn't the input they're proving for, to prevent leaking information about which inputs belong to other parties. I say ideally here because even if you fail to do this, the peer can iterate through all the provided commitment proofs until one of them matches/verifies with the upfront provided PoDLE.
On Thu, Feb 13, 2020 at 12:18 AM ZmnSCPxj <ZmnSCPxj at protonmail.com> wrote:
Quoted text (32 lines)
> Good morning Rusty, niftynei, and list, > > > > > - Serial ids should be chosen at random > > > > > > > > - For multiparty constructions, the initiator MUST flip the bottom > bit of any received inputs before relaying them to a peer. > > > > > > > > - Collisions of serial ids between peers is a protocol error > > > > > > > > > > I suppose we should define collision to mean "equal in all bits except > the lowest bit". > > > > No, literally equal. i.e. you can only make this error by clashing with > > yourself. > > hmm, I thought the entire point of having the low bit was that you could > multifund in such a way that the initiator creates multiple channels > simultaneously with multiple nodes? > So you would have to take the UTXOs of one peer and give it to the other > peer claiming it as your own. > Or something. > > With PoDLE this would not be possible I think, as you would not be able to > open the PoDLE commitment with the other node as the target (if we go with > the modified PoDLE which also commits to which node an opening is for, to > prevent the pouncing venus flytrap attack). > > Regards, > ZmnSCPxj > >
lisa neigut <niftynei at gmail.com> writes:
Quoted text (23 lines)
>> With PoDLE this would not be possible I think, as you would not be able > to open the PoDLE commitment with the other node as the target (if we go > with the modified PoDLE which also commits to which node an opening is for, > to prevent the pouncing venus flytrap attack). > > Good question. It should be possible to do multi-channel open even with the > PoDLE signature committing to a node_id. > > - An initiator can use the same utxo (h2) as their proof for multiple > peers; the signatures passed to each peer will have to commit to that > specific peer's node_id, however. > - The revised PoDLE signature commitment requires every initiator to > include at least one of their own inputs in the tx. Attempting to initiate > an additional open etc using someone else's utxo's won't work (this is the > pouncing venus flytrap attack which we're preventing). The initiator > including at least one input is expected behavior, at least in the open > case, since the opener has to cover the fees for the funding output. > - Ideally, a node would remove the PoDLE TLV data from any 'forwarded' > `tx_add_inputs` that isn't the input they're proving for, to prevent > leaking information about which inputs belong to other parties. I say > ideally here because even if you fail to do this, the peer can iterate > through all the provided commitment proofs until one of them > matches/verifies with the upfront provided PoDLE.
Yes, you need to PoDLE your own contribution I think, which means you need one UTXO per contributor in the N-way-open who you want to contribute a UTXO.
Consider Alice trying to create a single-tx to open a channel with both Bob and Carol, and wants *both* of them to also contribute.
Alice sends her own UTXO1 with proof to Bob, he shares his UTXO back. Alice sends her own UTXO2 with proof to Carol, she shares a UTXO back. Alice sets the lower bit on the serial_id from Bob and sends to Carol, and sets the lower on the serial_id from Carol and sends to Bob. She similarly reflects everything from Carol to Bob and vice-versa, and sends both of them the two "channel opening" outputs.
Now all parties have the same tx; unless Bob and Carol chose the same serial_ids (spec says random, but Bob and Carol don't get along). But this is trivially identifiable, and you give up on mutual opening.
Cheers, Rusty.