@@ -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,15 @@ 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
720+ <local_delayedpubkey>
721+ OP_CHECKSIG
722+ <to_self_delay>
721723 OP_CHECKSEQUENCEVERIFY
722724 OP_DROP
723- <local_delayedpubkey>
724- OP_CHECKSIGVERIFY
725725 ```
726726
727727The parity (even or odd) of the y-coordinate of the derived
@@ -731,7 +731,7 @@ The `tapscript_root` routine constructs a valid taproot commitment according to
731731BIP 341+342. Namely, a leaf version of `0xc0` MUST be used. As there's only a
732732single script, one can derive the tapscript root as:
733733```
734- tapscript_root = tagged_hash("TapLeaf, 0xc0 || compact_size_of(to_delay_script) || to_delay_script)
734+ tapscript_root = tagged_hash("TapLeaf" , 0xc0 || compact_size_of(to_delay_script) || to_delay_script)
735735```
736736
737737In the case of a commitment breach, the `to_delay_script_root` can be used
@@ -742,23 +742,23 @@ top-level key spend path. A valid witness is then just:
742742```
743743
744744In 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
745+ broadcaster can sweep their funds after a delay. The control block to spend is
746746only `33` bytes, as it just includes the internal key (along with the y-parity
747747bit and leaf version):
748748```
749- delay_control_block = (parity_of_y | 0x0c ) || < revocationpubkey >
749+ delay_control_block = (output_key_y_parity | 0xc0 ) || revocationpubkey
750750```
751751
752752A valid witness is then:
753753```
754- <delay_control_block > <to_delay_script> <local_delayedsig >
754+ <local_delayedsig > <to_delay_script> <delay_control_block >
755755```
756756
757- A with base channels, the `nSequence` field must be set to `to_self_delay`.
757+ As with base channels, the `nSequence` field must be set to `to_self_delay`.
758758
759759#### To Remote Outputs
760760
761- As we inheirit the anchor output semmeantics we want to ensure that the remote
761+ As we inherit the anchor output semantics we want to ensure that the remote
762762party can unilaterally sweep their funds after the 1 block CSV delay. In order
763763to achieve this property, we'll utilize a NUMs point (`simple_taproot_nums`) By
764764using this point as the internal key, we ensure that the remote party isn't
@@ -769,21 +769,21 @@ The to remote output has the following form:
769769 * `OP_1 to_remote_output_key`
770770 * where:
771771 * `taproot_nums_point = 0245b18183a06ee58228f07d9716f0f121cd194e4d924b037522503a7160432f15`
772- * `to_remote_output_key = taproot_nums_point + tagged_hash("TapTweak", taproot_nums_point|| to_remote_script_root`
772+ * `to_remote_output_key = taproot_nums_point + tagged_hash("TapTweak", taproot_nums_point || to_remote_script_root) `
773773 * `to_remote_script_root = tapscript_root([to_remote_script])`
774774 * `to_remote_script` is the remote script:
775775 ```
776- <remotepubkey> OP_CHECKSIGVERIFY 1 OP_CHECKSEQUENCEVERIFY
776+ <remotepubkey> OP_CHECKSIG OP_CHECKSEQUENCEVERIFY
777777 ```
778778
779779This output can be swept by the remote party with the following witness:
780780```
781- <to_remote_control_block > <to_remote_script> <remote_sig >
781+ <remote_sig > <to_remote_script> <to_remote_control_block >
782782```
783783
784784where `to_remote_control_block` is:
785785```
786- (parity_of_y(remotepubkey) | 0x0c ) || < remotepubkey >
786+ (output_key_y_parity | 0xc0 ) || taproot_nums_point
787787```
788788
789789#### Anchor Outputs
@@ -798,13 +798,25 @@ An anchor output has the following form:
798798 * `OP_1 anchor_output_key`
799799 * where:
800800 * `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])`
801+ * `anchor_output_key = anchor_internal_key + tagged_hash("TapTweak", anchor_internal_key || anchor_script_root)`
802+ * `anchor_script_root = tapscript_root([anchor_script])`
803803 * `anchor_script`:
804804 ```
805805 OP_16 OP_CHECKSEQUENCEVERIFY
806806 ```
807807
808+ This output can be swept by anyone after 16 blocks with the following witness:
809+ ```
810+ <anchor_script> <anchor_control_block>
811+ ```
812+
813+ where `anchor_control_block` is:
814+ ```
815+ (output_key_y_parity | 0xc0) || anchor_internal_key
816+ ```
817+
818+ `nSequence` needs to be set to 16.
819+
808820### HTLC Scripts & Transactions
809821
810822#### Offered HTLCs
@@ -821,15 +833,14 @@ An offered HTLC has the following form:
821833 * `htlc_script_root = tapscript_root([htlc_timeout, htlc_success])`
822834 * `htlc_timeout`:
823835 ```
824- <local_htlcpubkey> OP_CHECKSIGADD <remote_htlcpubkey> OP_CHECKSIGADD 2 OP_EQUALVERIFY
825- 1 OP_CHECKSEQUENCEVERIFY
836+ <local_htlcpubkey> OP_CHECKSIGVERIFY <remote_htlcpubkey> OP_CHECKSIG
826837 ```
827838 * `htlc_success`:
828839 ```
829840 OP_SIZE 32 OP_EQUALVERIFY OP_HASH160 <RIPEMD160(payment_hash)> OP_EQUALVERIFY
830841 <remote_htlcpubkey>
831- OP_CHECKSIGVERIFY
832- 1 OP_CHECKSEQUENCEVERIFY
842+ OP_CHECKSIG
843+ OP_CHECKSEQUENCEVERIFY
833844 ```
834845
835846In order to spend a offered HTLC, via either script path, an `inclusion_proof`
@@ -847,18 +858,21 @@ Accepted HTLCs inherit a similar format:
847858 * `htlc_timeout`:
848859 ```
849860 <remote_htlcpubkey>
850- OP_CHECKSIGVERIFY
851- 1 OP_CHECKSEQUENCEVERIFY OP_DROP
861+ OP_CHECKSIG
862+ OP_CHECKSEQUENCEVERIFY
852863 <cltv_expiry>
853- OP_CHECKLOCKTIMEVERIFY
864+ OP_CHECKLOCKTIMEVERIFY OP_DROP
854865 ```
855866 * `htlc_success`:
856867 ```
857868 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
869+ <local_htlcpubkey> OP_CHECKSIGVERIFY <remote_htlcpubkey> OP_CHECKSIG
860870 ```
861871
872+ Note that there is no `OP_CHECKSEQUENCEVERIFY` in the offered HTLC's timeout path
873+ and in the accepted HTLC's success path. This is not needed here as these paths
874+ require a remote signature that commits to the sequence, which needs to be set at 1.
875+
862876In order to spend an accepted HTLC, via either script path, an
863877`inclusion_proof` must be specified along with the control block. This
864878`inclusion_proof` is simply the `tap_leaf` hash of the path _not_ taken.
@@ -886,7 +900,8 @@ A HTLC-Success transaction has the following structure:
886900 * input:
887901 * txid: commitment_tx
888902 * vout: htlc_index
889- * witness: `control_block || htlc_success_script || <localsig> <remotesig> <preimage>`
903+ * sequence: 1
904+ * witness: `<remotehtlcsig> <localhtlcsig> <preimage> <htlc_success_script> <control_block>`
890905 * output:
891906 * value: htlc_value
892907 * script:
@@ -897,9 +912,10 @@ A HTLC-Success transaction has the following structure:
897912 * `htlc_success`:
898913 ```
899914 <local_delayedpubkey>
900- OP_CHECKSIGVERIFY
915+ OP_CHECKSIG
901916 <to_self_delay>
902917 OP_CHECKSEQUENCEVERIFY
918+ OP_DROP
903919 ```
904920
905921##### HTLC-Timeout Transactions
@@ -911,7 +927,8 @@ A HTLC-Timeout transaction has the following structure:
911927 * input:
912928 * txid: commitment_tx
913929 * vout: htlc_index
914- * witness: `control_block || htlc_timeout_script || <localsig> <remotesig>`
930+ * sequence: 1
931+ * witness: `<remotehtlcsig> <localhtlcsig> <htlc_timeout_script> <control_block>`
915932 * output:
916933 * value: htlc_value
917934 * script:
@@ -922,9 +939,10 @@ A HTLC-Timeout transaction has the following structure:
922939 * `htlc_timeout`:
923940 ```
924941 <local_delayedpubkey>
925- OP_CHECKSIGVERIFY
942+ OP_CHECKSIG
926943 <to_self_delay>
927944 OP_CHECKSEQUENCEVERIFY
945+ OP_DROP
928946 ```
929947
930948# Appendix
0 commit comments