Skip to content

Commit 6a91484

Browse files
committed
Fix update script &, footnotes
1 parent a23b3a8 commit 6a91484

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

bip-0442.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ OP_EQUALVERIFY #
6363

6464
### Use in Lightning Symmetry
6565

66-
Lightning Symmetry contracts require data availability for contested closes. By forcing parties to include settlement transaction hashes in the witness, later updates can reconstruct scripts using only the latest state.
66+
Lightning Symmetry contracts require data availability for contested closes. [^3] By forcing parties to include settlement transaction hashes in the witness, later updates can reconstruct scripts using only the latest state.
6767
[^3]: The required data is a full CTV hash of the settlement transaction when there are open HTLCs, or merely the difference in balance between the channel partners in other cases. Whether the latter optimization would be used is an implementation detail not further discussed here.
6868

6969
```shell
@@ -73,7 +73,7 @@ Lightning Symmetry contracts require data availability for contested closes. By
7373
# settlement-n-hash: { nSequence(2w), out(A, amount(A)), out(B, amount(B)) }
7474
# state-n-recovery-data: { settlement-n-hash or state-n-balance }
7575
```
76-
#### Example channel script (pseudo-code):
76+
#### Example channel script (pseudo-code)
7777

7878
```shell
7979
# Witness: <sig> <state-n-recovery-data> <state-n-hash>
@@ -86,9 +86,7 @@ OP_CHECKLOCKTIMEVERIFY # <1>, <S+1>
8686
OP_DROP # <1>
8787
```
8888

89-
*Note: `state-n-hash` commits to a specific `nLockTime` value for the transaction through `OP_CHECKTEMPLATEVERIFY`; `OP_CHECKLOCKTIMEVERIFY` ensures that the state progression can only go forward (the transaction needs to have greater `nLockTime` value than the intermediate state being spent).*
90-
91-
#### Channel update script (pseudo-code):
89+
#### Channel update script (pseudo-code) for m > n
9290

9391
```shell
9492
OP_IF
@@ -97,43 +95,45 @@ OP_IF
9795
OP_PAIRCOMMIT # <sig>, PC(state-m-recovery-data, state-m-hash)
9896
OP_INTERNALKEY # <sig>, PC(state-m-recovery-data, state-m-hash), <internal-key>
9997
OP_CHECKSIGFROMSTACK # <1>
100-
OP_PUSHDATA (S+1) # <1>, <S+1>
101-
OP_CHECKLOCKTIMEVERIFY # <1>, <S+1>
98+
OP_PUSHDATA (S+n+1) # <1>, <S+n+1>
99+
OP_CHECKLOCKTIMEVERIFY # <1>, <S+n+1>
102100
OP_DROP # <1>
103101
OP_ELSE
104-
# Witness: <settlement-n-hash>
102+
# Empty witness stack
103+
OP_PUSHDATA (settlement-n-hash) # <settlement-n-hash>
105104
OP_CHECKTEMPLATEVERIFY # <settlement-n-hash>
106105
OP_0NOTEQUAL # <1>
107106
OP_ENDIF
108107
```
109108

110-
*Note: `OP_0NOTEQUAL` can be omitted (any non-zero value left on the stack would be accepted by the script interpreter).*
109+
These constructions ensure both parties sign the same pair hash, requiring inclusion of both update and settlement hashes in the witness. [^4] [^5]
111110

112-
These constructions ensure both parties sign the same pair hash, requiring inclusion of both update and settlement hashes in the witness.
111+
[^4]: `state-n-hash` commits to a specific `nLockTime` value for the transaction through `OP_CHECKTEMPLATEVERIFY`; `OP_CHECKLOCKTIMEVERIFY` ensures that the state progression can only go forward (the transaction needs to have greater `nLockTime` value than the intermediate state
112+
[^5]: `OP_0NOTEQUAL` can be omitted (any non-zero value left on the stack would be accepted by the script interpreter).
113113

114114
### In MATT
115115

116-
The Merklize All The Things ([MATT]) framework uses `OP_CAT` to combine items for commitments. `OP_PAIRCOMMIT` provides a more ergonomic and secure alternative[^4].
116+
The Merklize All The Things ([MATT]) framework uses `OP_CAT` to combine items for commitments. `OP_PAIRCOMMIT` provides a more ergonomic and secure alternative[^6].
117117

118-
[^4]: Naive use of `OP_CAT` is vulnerable to byte shifting attacks. E.g. `0x0102 || 0x03` equals `0x01 || 0x0203`. Mitigation requires length checking or hashing.
118+
[^6]: Naive use of `OP_CAT` is vulnerable to byte shifting attacks. E.g. `0x0102 || 0x03` equals `0x01 || 0x0203`. Mitigation requires length checking or hashing.
119119

120120
## Alternative approaches
121121

122122
Alternative approaches considered and rejected:
123123

124-
- `OP_CAT`[^4][^7]
125-
- SHA256 streaming opcodes[^7]
124+
- `OP_CAT`[^6][^9]
125+
- SHA256 streaming opcodes[^9]
126126
- Merkle operation opcodes
127127
- 'Kitty' CAT: `OP_CAT` with size limits
128-
- `OP_CHECKTEMPLATEVERIFY` committing to the taproot annex[^5]
128+
- `OP_CHECKTEMPLATEVERIFY` committing to the taproot annex[^7]
129129
- `OP_CHECKSIGFROMSTACK` on n elements
130130
- `OP_VECTORCOMMIT`: generalized for n > 2 elements
131131
- ReKey/Laddering[^2]
132-
- `OP_RETURN`[^6]
132+
- `OP_RETURN`[^8]
133133

134-
[^5]: Committing to the taproot annex allows one additional item, but it is not accessible to script.
135-
[^6]: `OP_RETURN` can commit to additional data, but is costly and not accessible to script.
136-
[^7]: `OP_PAIRCOMMIT` enables useful scripts without the risks of `OP_CAT` (see [CAT-tricks-I], [CAT-tricks-II]).
134+
[^7]: Committing to the taproot annex allows one additional item, but it is not accessible to script.
135+
[^8]: `OP_RETURN` can commit to additional data, but is costly and not accessible to script.
136+
[^9]: `OP_PAIRCOMMIT` enables useful scripts without the risks of `OP_CAT` (see [CAT-tricks-I], [CAT-tricks-II]).
137137

138138
## Reference Implementation
139139

0 commit comments

Comments
 (0)