@@ -17,24 +17,21 @@ provides limited vector commitment functionality in tapscript.
17
17
18
18
When evaluated, the ` OP_PAIRCOMMIT ` instruction:
19
19
* Pops the top two values off the stack,
20
- * takes the "PairCommit" tagged SHA256 hash of the stack elements,
21
- * pushes the resulting commitment on the top of the stack.
20
+ * takes the "PairCommit" tagged SHA256 hash of the stack elements with size
21
+ commitments,
22
+ * pushes the resulting 32-byte hash to the top of stack.
22
23
23
24
## Motivation
24
25
25
- To do [ LN-Symmetry] contracts that don't require the nodes to keep old states,
26
- we need to solve the data availability problem presented by unilateral closes.
27
- Channel peers must be able to reconstruct the script that spends an
28
- intermediate state.
26
+ Currently, bitcoin lacks a way to hash multiple stack elements together. Which
27
+ means building Merkle trees or verifying inclusion in a tree is not supported.
29
28
30
- Using in sequence ` OP_CHECKTEMPLATEVERIFY ` , ` OP_PAIRCOMMIT ` , ` OP_INTERNALKEY `
31
- and ` OP_CHECKSIGFROMSTACK ` we can construct a [ rebindable channel] that is also
32
- [ optimal] .
29
+ ` OP_PAIRCOMMIT ` is a simple and efficient tool to commit to two stack elements,
30
+ in a way that makes length redistribution attacks infeasible.
33
31
34
- The number of SHA256 iterations is minimized in the primary use case we
35
- can optimize for, which is LN-Symmetry. Since the Tag can be pre-computed as
36
- mid-state, it would only take 1 or 2 hash cycles in validation for the
37
- unilateral close scenario.
32
+ The number of SHA256 iterations is minimized in the typical use cases we can
33
+ optimize for. Since the Tag can be pre-computed as mid-state, it would only
34
+ take 1 or 2 hash cycles in validation for the unilateral close scenario.
38
35
39
36
## Specification
40
37
@@ -95,6 +92,15 @@ highly optimized for just 2 stack elements.
95
92
96
93
### Use in LN-Symmetry
97
94
95
+ To do LN-Symmetry contracts that don't require the nodes to keep old states,
96
+ we need to solve the data availability problem presented by unilateral closes.
97
+ Channel peers must be able to reconstruct the script that spends an
98
+ intermediate state.
99
+
100
+ Using in sequence ` OP_CHECKTEMPLATEVERIFY ` , ` OP_PAIRCOMMIT ` , ` OP_INTERNALKEY `
101
+ and ` OP_CHECKSIGFROMSTACK ` we can construct a rebindable channel that is also
102
+ [ optimal] .
103
+
98
104
The following assembly-like pseudo-code shows a possible LN-Symmetry channel
99
105
construction that provides data availability to spend to the latest state from
100
106
an earlier state pushed on-chain with a forced close by channel partner.
@@ -137,8 +143,13 @@ https://github.com/lnhance/bitcoin/pull/6/files
137
143
If ` OP_CAT ` was available, it could be used to combine multiple stack elements
138
144
that get verified with ` OP_CHECKSIGFROMSTACK ` as a valid state update.
139
145
146
+ Using ` OP_CAT ` for this purpose requires additional opcodes to prevent witness
147
+ malleability (e.g. ` 0x0102 0x03 OP_CAT ` is identical to ` 0x01 0x0203 OP_CAT ` ).
148
+
140
149
` OP_PAIRCOMMIT ` solves this specific problem without introducing a wide range
141
- of potentially controversial new behaviors, such as novel 2-way peg mechanisms.
150
+ of potentially controversial new behaviors like fully detailed introspection,
151
+ which includes the ability to inspect parent transactions and novel 2-way peg
152
+ mechanisms. ([ CAT-tricks-I] and [ CAT-tricks-II] by Andrew Poelstra)
142
153
143
154
Alternatively ` OP_RETURN ` could be used to ensure the availability of the state
144
155
recovery data, as ` OP_CHECKTEMPLATEVERIFY ` naturally commits to all outputs.
@@ -172,6 +183,7 @@ various reasons, either for expanding the scope or for unnecessary complexity:
172
183
* OP_CHECKTEMPLATEVERIFY committing to the taproot annex in tapscript
173
184
* OP_CHECKSIGFROMSTACK on n elements as message
174
185
* OP_VECTORCOMMIT: generalized form for n > 2 elements
186
+ * ReKey: key delegation and multiple use of OP_CHECKSIGFROMSTACK
175
187
176
188
### Cost comparison of LN-Symmetry constructions
177
189
@@ -191,24 +203,24 @@ same size for both Force Close and Contest in LN-Symmetry, ForceC: total cost of
191
203
Merkle trees can be used to prove computation where the root of the tree
192
204
represents the * function* and the leaves represent the * inputs* and * output* .
193
205
There are practical limits to the entropy space for the * inputs* as they need
194
- to be iterated over and hashed into a merkle root.
206
+ to be iterated over and hashed into a Merkle root.
195
207
196
- MAST trees can currently cover 128 bits of entropy space, which is well over
197
- the practical limits to iterate over and merklize. Therefore, we assume this
208
+ Taproot MAST trees can currently cover 128 bits of entropy space, which is over
209
+ the practical limits to iterate over and merklize. Therefore, we conclude this
198
210
capability does not materially extend what computations are possible to prove
199
211
in bitcoin script. While ` OP_PAIRCOMMIT ` is not limited to a height of 128,
200
212
that should not be practically feasible to utilize.
201
213
202
214
There is a way to reduce the size of the witness for proving computation,
203
- by eliminating the merkle path inclusion proofs, using ` OP_CHECKSIGFROMSTACK `
215
+ by eliminating the Merkle path inclusion proofs, using ` OP_CHECKSIGFROMSTACK `
204
216
together with ` OP_PAIRCOMMIT ` . This method involves deleted key assumptions,
205
217
most likely using MPC to create an enormous amount of signatures for the stack
206
218
elements representing the * inputs* and the * output* of the * function* .
207
219
208
220
## Backward Compatibility
209
221
210
222
By constraining the behavior of OP_SUCCESS opcodes, deployment of the BIP
211
- can be done in a backwards compatible, soft-fork manner. If anyone were to
223
+ can be done in a backwards- compatible, soft-fork manner. If anyone were to
212
224
rely on the OP_SUCCESS behavior of ` OP_SUCCESS205 ` , ` OP_PAIRCOMMIT ` would
213
225
invalidate their spend.
214
226
@@ -236,6 +248,8 @@ This document is licensed under the 3-clause BSD license.
236
248
237
249
[ lnhance ] : https://github.com/lnhance/bitcoin
238
250
[ eltoo ] : https://github.com/instagibbs/bolts/blob/eltoo_draft/XX-eltoo-transactions.md
251
+ [ CAT-tricks-I ] : https://medium.com/blockstream/cat-and-schnorr-tricks-i-faf1b59bd298
252
+ [ CAT-tricks-II ] : https://medium.com/blockstream/cat-and-schnorr-tricks-ii-2f6ede3d7bb5
239
253
240
254
[ // ] : # ( BIPs referenced )
241
255
[ BIP-119 ] : https://github.com/bitcoin/bips/tree/master/bip-0119.mediawiki
@@ -248,6 +262,4 @@ This document is licensed under the 3-clause BSD license.
248
262
[ BIN-2024-0004 ] : https://github.com/bitcoin-inquisition/binana/blob/master/2024/BIN-2024-0004.md
249
263
250
264
[ // ] : # ( Internal links )
251
- [ LN-Symmetry ] : #use-in-ln-symmetry
252
- [ rebindable channel ] : #use-in-ln-symmetry
253
265
[ optimal ] : #cost-comparison-of-ln-symmetry-constructions
0 commit comments