@@ -54,16 +54,16 @@ Created: 2022-04-20
5454- [ Test Vectors] ( #test-vectors )
5555- [ Acknowledgements] ( #acknowledgements )
5656
57- # Introduction
57+ # Introduction
5858
59- ## Abstract
59+ ## Abstract
6060
6161
6262The activation of the Taproot soft-fork suite enables a number of updates to
6363the Lightning Network, allowing developers to improve the privacy, security,
64- and flexibility of the system. This document specifies extensions to BOLTs 2,
64+ and flexibility of the system. This document specifies extensions to BOLTs 2,
65653, and 5 which describe a new Taproot based channels to update to the Lightning
66- Network to take advantage of _ some_ of these new capabilities. Namely, we
66+ Network to take advantage of _ some_ of these new capabilities. Namely, we
6767mechanically translate the current funding and commitment design to utilize
6868` musig2 ` and the new tapscript tree capabilities.
6969
@@ -150,7 +150,7 @@ A `tap_branch` can commit to either a `tap_leaf` or `tap_branch`. Before
150150hashing, a ` tap_branch ` sorts the two ` tap_node ` arguments based on
151151lexicographical ordering:
152152```
153- tagged_hash("TapBranch, sort(node_1, node_2)
153+ tagged_hash("TapBranch" , sort(node_1, node_2) )
154154```
155155
156156A tapscript tree is constructed by hashing each pair of leaves into a
@@ -171,7 +171,7 @@ script path.
171171[ BIP 86] ( https://github.com/bitcoin/bips/blob/master/bip-0086.mediawiki ) defines a taproot output key derivation scheme that wherein only the internal
172172key is committed to without a script root:
173173```
174- taproot_output_key = taproot_internal_key + tagged_hash("TapTweak", taproot_internal_key)*G
174+ taproot_output_key = taproot_internal_key + tagged_hash("TapTweak", taproot_internal_key)*G
175175```
176176
177177We use BIP 86 whenever we want to ensure that a script path spend isn't
@@ -219,7 +219,7 @@ will be absent.
219219
220220The final witness to spend a script path output is:
221221```
222- control_block || leaf_script || witness
222+ <witness1> ... <witnessN> < leaf_script> <control_block>
223223```
224224
225225### MuSig2
@@ -396,7 +396,7 @@ The sending node:
396396The sending node SHOULD:
397397
398398 - use the ` NonceGen ` algorithm defined in ` bip-musig2 ` to generate
399- ` lcaol_musig2_pubnonce ` and ` remote_musig2_pubnonce ` to ensure it
399+ ` locall_musig2_pubnonce ` and ` remote_musig2_pubnonce ` to ensure it
400400 generates nonces in a safe manner.
401401
402402The receiving node MUST fail the channel if:
@@ -416,7 +416,7 @@ step.
416416
417417The ` remote_musig2_pubnonce ` will be used to sign the _ remote_ party's
418418commitment transaction, while the ` local_musig2_pubnonce ` will be used to sign
419- the local party's commitment transaction.
419+ the local party's commitment transaction.
420420
421421We require two nonces, as there're actually two messages being signed: the
422422local commitment and the remote commitment. If only one nonce was used, when a
@@ -454,7 +454,7 @@ The receiver:
454454
455455The sender:
456456
457- - MUST derive the aggregated ` musig2 ` public key using the exchanged ` funding_pubkey ` s
457+ - MUST derive the aggregated ` musig2 ` public key using the exchanged ` funding_pubkey ` s
458458 - Before aggregating the two funding public keys, the keys MUST be sorted
459459 using the ` KeySort ` routine of ` bip-musig2 ` .
460460
@@ -610,7 +610,7 @@ The receiver MUST:
610610 - Fail the channel if the received schnorr partial signature failed to verify
611611 using the ` PartialSigVerify ` paramterized with the local combined nonce
612612 (` local_musig2_pubnonce ` of the verifying party, and the
613- ` remote_musig2_pubnonce ` of the sending party) algorithm of ` musig2 ` .
613+ ` remote_musig2_pubnonce ` of the sending party) algorithm of ` musig2 ` .
614614
615615 - Fail the channel is _ any_ of the received HTLC signatures does not validate
616616 according to the message extensions and sighash algorithm described in BIP
@@ -713,15 +713,14 @@ The new output has the following form:
713713
714714 * ` OP_1 to_local_output_key `
715715 * where:
716- * ` to_local_output_key = < revocationpubkey> + tagged_hash("TapTweak", < revocationpubkey> || to_delay_script_root `
716+ * ` to_local_output_key = revocationpubkey + tagged_hash("TapTweak", revocationpubkey || to_delay_script_root) `
717717 * ` to_delay_script_root = tapscript_root([to_delay_script]) `
718718 * ` to_delay_script ` is the delay script:
719719 ```
720- to_self_delay
721- OP_CHECKSEQUENCEVERIFY
722- OP_DROP
723720 <local_delayedpubkey>
724721 OP_CHECKSIGVERIFY
722+ to_self_delay
723+ OP_CHECKSEQUENCEVERIFY
725724 ```
726725
727726The parity (even or odd) of the y-coordinate of the derived
@@ -731,7 +730,7 @@ The `tapscript_root` routine constructs a valid taproot commitment according to
731730BIP 341+342. Namely, a leaf version of `0xc0` MUST be used. As there's only a
732731single script, one can derive the tapscript root as:
733732```
734- tapscript_root = tagged_hash("TapLeaf, 0xc0 || compact_size_of(to_delay_script) || to_delay_script)
733+ tapscript_root = tagged_hash("TapLeaf" , 0xc0 || compact_size_of(to_delay_script) || to_delay_script)
735734```
736735
737736In the case of a commitment breach, the `to_delay_script_root` can be used
@@ -742,23 +741,23 @@ top-level key spend path. A valid witness is then just:
742741```
743742
744743In the case of a routine force close, the script path must be revealed so the
745- broadcaster can sweep their funds after a delay. The control block to spend is
744+ broadcaster can sweep their funds after a delay. The control block to spend is
746745only `33` bytes, as it just includes the internal key (along with the y-parity
747746bit and leaf version):
748747```
749- delay_control_block = (parity_of_y | 0x0c ) || < revocationpubkey >
748+ delay_control_block = (output_key_y_parity | 0xc0 ) || revocationpubkey
750749```
751750
752751A valid witness is then:
753752```
754- <delay_control_block > <to_delay_script> <local_delayedsig >
753+ <local_delayedsig > <to_delay_script> <delay_control_block >
755754```
756755
757- A with base channels, the `nSequence` field must be set to `to_self_delay`.
756+ As with base channels, the `nSequence` field must be set to `to_self_delay`.
758757
759758#### To Remote Outputs
760759
761- As we inheirit the anchor output semmeantics we want to ensure that the remote
760+ As we inherit the anchor output semantics we want to ensure that the remote
762761party can unilaterally sweep their funds after the 1 block CSV delay. In order
763762to achieve this property, we'll utilize a NUMs point (`simple_taproot_nums`) By
764763using this point as the internal key, we ensure that the remote party isn't
@@ -769,21 +768,21 @@ The to remote output has the following form:
769768 * `OP_1 to_remote_output_key`
770769 * where:
771770 * `taproot_nums_point = 0245b18183a06ee58228f07d9716f0f121cd194e4d924b037522503a7160432f15`
772- * `to_remote_output_key = taproot_nums_point + tagged_hash("TapTweak", taproot_nums_point|| to_remote_script_root`
771+ * `to_remote_output_key = taproot_nums_point + tagged_hash("TapTweak", taproot_nums_point || to_remote_script_root) `
773772 * `to_remote_script_root = tapscript_root([to_remote_script])`
774773 * `to_remote_script` is the remote script:
775774 ```
776- <remotepubkey> OP_CHECKSIGVERIFY 1 OP_CHECKSEQUENCEVERIFY
775+ <remotepubkey> OP_CHECKSIG OP_CHECKSEQUENCEVERIFY
777776 ```
778777
779778This output can be swept by the remote party with the following witness:
780779```
781- <to_remote_control_block > <to_remote_script> <remote_sig >
780+ <remote_sig > <to_remote_script> <to_remote_control_block >
782781```
783782
784783where `to_remote_control_block` is:
785784```
786- (parity_of_y(remotepubkey) | 0x0c ) || < remotepubkey >
785+ (output_key_y_parity | 0xc0 ) || taproot_nums_point
787786```
788787
789788#### Anchor Outputs
@@ -798,13 +797,25 @@ An anchor output has the following form:
798797 * `OP_1 anchor_output_key`
799798 * where:
800799 * `anchor_internal_key = remotepubkey/local_delayedpubkey`
801- * `anchor_output_key= anchor_internal_key + tagged_hash("TapTweak", anchor_internal_key || anchor_script_root)`
802- * `anchor_script = tapscript_root([anchor_script])`
800+ * `anchor_output_key = anchor_internal_key + tagged_hash("TapTweak", anchor_internal_key || anchor_script_root)`
801+ * `anchor_script_root = tapscript_root([anchor_script])`
803802 * `anchor_script`:
804803 ```
805804 OP_16 OP_CHECKSEQUENCEVERIFY
806805 ```
807806
807+ This output can be swept by anyone after 16 blocks with the following witness:
808+ ```
809+ <anchor_script> <anchor_control_block>
810+ ```
811+
812+ where `anchor_control_block` is:
813+ ```
814+ (output_key_y_parity | 0xc0) || anchor_internal_key
815+ ```
816+
817+ `nSequence` needs to be set to 16.
818+
808819### HTLC Scripts & Transactions
809820
810821#### Offered HTLCs
@@ -821,15 +832,14 @@ An offered HTLC has the following form:
821832 * `htlc_script_root = tapscript_root([htlc_timeout, htlc_success])`
822833 * `htlc_timeout`:
823834 ```
824- <local_htlcpubkey> OP_CHECKSIGADD <remote_htlcpubkey> OP_CHECKSIGADD 2 OP_EQUALVERIFY
825- 1 OP_CHECKSEQUENCEVERIFY
835+ <local_htlcpubkey> OP_CHECKSIGVERIFY <remote_htlcpubkey> OP_CHECKSIG
826836 ```
827837 * `htlc_success`:
828838 ```
829839 OP_SIZE 32 OP_EQUALVERIFY OP_HASH160 <RIPEMD160(payment_hash)> OP_EQUALVERIFY
830840 <remote_htlcpubkey>
831- OP_CHECKSIGVERIFY
832- 1 OP_CHECKSEQUENCEVERIFY
841+ OP_CHECKSIG
842+ OP_CHECKSEQUENCEVERIFY
833843 ```
834844
835845In order to spend a offered HTLC, via either script path, an `inclusion_proof`
@@ -847,18 +857,21 @@ Accepted HTLCs inherit a similar format:
847857 * `htlc_timeout`:
848858 ```
849859 <remote_htlcpubkey>
850- OP_CHECKSIGVERIFY
851- 1 OP_CHECKSEQUENCEVERIFY OP_DROP
860+ OP_CHECKSIG
861+ OP_CHECKSEQUENCEVERIFY
852862 <cltv_expiry>
853- OP_CHECKLOCKTIMEVERIFY
863+ OP_CHECKLOCKTIMEVERIFY OP_DROP
854864 ```
855865 * `htlc_success`:
856866 ```
857867 OP_SIZE 32 OP_EQUALVERIFY OP_HASH160 <RIPEMD160(payment_hash)> OP_EQUALVERIFY
858- <local_htlcpubkey> OP_CHECKSIGADD <remote_htlcpubkey> OP_CHECKSIGADD 2 OP_EQUALVERIFY
859- 1 OP_CHECKSEQUENCEVERIFY
868+ <local_htlcpubkey> OP_CHECKSIGVERIFY <remote_htlcpubkey> OP_CHECKSIG
860869 ```
861870
871+ Note that there is no `OP_CHECKSEQUENCEVERIFY` in the offered HTLC's timeout path
872+ and in the accepted HTLC's success path. This is not needed here as these paths
873+ require a remote signature that commits to the sequence, which needs to be set at 1.
874+
862875In order to spend an accepted HTLC, via either script path, an
863876`inclusion_proof` must be specified along with the control block. This
864877`inclusion_proof` is simply the `tap_leaf` hash of the path _not_ taken.
@@ -886,7 +899,8 @@ A HTLC-Success transaction has the following structure:
886899 * input:
887900 * txid: commitment_tx
888901 * vout: htlc_index
889- * witness: `control_block || htlc_success_script || <localsig> <remotesig> <preimage>`
902+ * sequence: 1
903+ * witness: `<remotehtlcsig> <localhtlcsig> <preimage> <htlc_success_script> <control_block>`
890904 * output:
891905 * value: htlc_value
892906 * script:
@@ -911,7 +925,8 @@ A HTLC-Timeout transaction has the following structure:
911925 * input:
912926 * txid: commitment_tx
913927 * vout: htlc_index
914- * witness: `control_block || htlc_timeout_script || <localsig> <remotesig>`
928+ * sequence: 1
929+ * witness: `<remotehtlcsig> <localhtlcsig> <htlc_timeout_script> <control_block>`
915930 * output:
916931 * value: htlc_value
917932 * script:
0 commit comments