Skip to content

Commit 43f45e8

Browse files
committed
fix and make scripts smaller
1 parent ec8c7b4 commit 43f45e8

File tree

1 file changed

+22
-23
lines changed

1 file changed

+22
-23
lines changed

bolt-simple-taproot.md

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ A `tap_branch` can commit to either a `tap_leaf` or `tap_branch`. Before
150150
hashing, a `tap_branch` sorts the two `tap_node` arguments based on
151151
lexicographical ordering:
152152
```
153-
tagged_hash("TapBranch, sort(node_1, node_2)
153+
tagged_hash("TapBranch", sort(node_1, node_2))
154154
```
155155

156156
A tapscript tree is constructed by hashing each pair of leaves into a
@@ -219,7 +219,7 @@ will be absent.
219219

220220
The 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
@@ -717,11 +717,10 @@ The new output has the following form:
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
727726
The 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
731730
BIP 341+342. Namely, a leaf version of `0xc0` MUST be used. As there's only a
732731
single 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
737736
In the case of a commitment breach, the `to_delay_script_root` can be used
@@ -746,12 +745,12 @@ broadcaster can sweep their funds after a delay. The control block to spend is
746745
only `33` bytes, as it just includes the internal key (along with the y-parity
747746
bit and leaf version):
748747
```
749-
delay_control_block = (parity_of_y | 0x0c) || <revocationpubkey>
748+
delay_control_block = (parity_of_y | 0xc0) || <revocationpubkey>
750749
```
751750
752751
A 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
757756
A with base channels, the `nSequence` field must be set to `to_self_delay`.
@@ -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
779778
This 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
784783
where `to_remote_control_block` is:
785784
```
786-
(parity_of_y(remotepubkey) | 0x0c) || <remotepubkey>
785+
(parity_of_y(remotepubkey) | 0xc0) || <remotepubkey>
787786
```
788787
789788
#### Anchor Outputs
@@ -821,15 +820,15 @@ An offered HTLC has the following form:
821820
* `htlc_script_root = tapscript_root([htlc_timeout, htlc_success])`
822821
* `htlc_timeout`:
823822
```
824-
<local_htlcpubkey> OP_CHECKSIGADD <remote_htlcpubkey> OP_CHECKSIGADD 2 OP_EQUALVERIFY
825-
1 OP_CHECKSEQUENCEVERIFY
823+
<local_htlcpubkey> OP_CHECKSIGVERIFY <remote_htlcpubkey> OP_CHECKSIG
824+
OP_CHECKSEQUENCEVERIFY
826825
```
827826
* `htlc_success`:
828827
```
829828
OP_SIZE 32 OP_EQUALVERIFY OP_HASH160 <RIPEMD160(payment_hash)> OP_EQUALVERIFY
830829
<remote_htlcpubkey>
831-
OP_CHECKSIGVERIFY
832-
1 OP_CHECKSEQUENCEVERIFY
830+
OP_CHECKSIG
831+
OP_CHECKSEQUENCEVERIFY
833832
```
834833
835834
In order to spend a offered HTLC, via either script path, an `inclusion_proof`
@@ -847,16 +846,16 @@ Accepted HTLCs inherit a similar format:
847846
* `htlc_timeout`:
848847
```
849848
<remote_htlcpubkey>
850-
OP_CHECKSIGVERIFY
851-
1 OP_CHECKSEQUENCEVERIFY OP_DROP
849+
OP_CHECKSIG
850+
OP_CHECKSEQUENCEVERIFY
852851
<cltv_expiry>
853-
OP_CHECKLOCKTIMEVERIFY
852+
OP_CHECKLOCKTIMEVERIFY OP_DROP
854853
```
855854
* `htlc_success`:
856855
```
857856
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
857+
<local_htlcpubkey> OP_CHECKSIGVERIFY <remote_htlcpubkey> OP_CHECKSIG
858+
OP_CHECKSEQUENCEVERIFY
860859
```
861860
862861
In order to spend an accepted HTLC, via either script path, an
@@ -886,7 +885,7 @@ A HTLC-Success transaction has the following structure:
886885
* input:
887886
* txid: commitment_tx
888887
* vout: htlc_index
889-
* witness: `control_block || htlc_success_script || <localsig> <remotesig> <preimage>`
888+
* witness: `<remotehtlcsig> <localhtlcsig> <preimage> <htlc_success_script> <control_block>`
890889
* output:
891890
* value: htlc_value
892891
* script:
@@ -911,7 +910,7 @@ A HTLC-Timeout transaction has the following structure:
911910
* input:
912911
* txid: commitment_tx
913912
* vout: htlc_index
914-
* witness: `control_block || htlc_timeout_script || <localsig> <remotesig>`
913+
* witness: `<remotehtlcsig> <localhtlcsig> <htlc_timeout_script> <control_block>`
915914
* output:
916915
* value: htlc_value
917916
* script:

0 commit comments

Comments
 (0)