Skip to content

Commit 69d8d97

Browse files
committed
Update Motivation section, further carifications
1 parent 9d86add commit 69d8d97

File tree

1 file changed

+33
-21
lines changed

1 file changed

+33
-21
lines changed

bip-0442.md

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,21 @@ provides limited vector commitment functionality in tapscript.
1717

1818
When evaluated, the `OP_PAIRCOMMIT` instruction:
1919
* 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.
2223

2324
## Motivation
2425

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.
2928

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.
3331

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.
3835

3936
## Specification
4037

@@ -95,6 +92,15 @@ highly optimized for just 2 stack elements.
9592

9693
### Use in LN-Symmetry
9794

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+
98104
The following assembly-like pseudo-code shows a possible LN-Symmetry channel
99105
construction that provides data availability to spend to the latest state from
100106
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
137143
If `OP_CAT` was available, it could be used to combine multiple stack elements
138144
that get verified with `OP_CHECKSIGFROMSTACK` as a valid state update.
139145

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+
140149
`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)
142153

143154
Alternatively `OP_RETURN` could be used to ensure the availability of the state
144155
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:
172183
* OP_CHECKTEMPLATEVERIFY committing to the taproot annex in tapscript
173184
* OP_CHECKSIGFROMSTACK on n elements as message
174185
* OP_VECTORCOMMIT: generalized form for n > 2 elements
186+
* ReKey: key delegation and multiple use of OP_CHECKSIGFROMSTACK
175187

176188
### Cost comparison of LN-Symmetry constructions
177189

@@ -191,24 +203,24 @@ same size for both Force Close and Contest in LN-Symmetry, ForceC: total cost of
191203
Merkle trees can be used to prove computation where the root of the tree
192204
represents the *function* and the leaves represent the *inputs* and *output*.
193205
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.
195207

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
198210
capability does not materially extend what computations are possible to prove
199211
in bitcoin script. While `OP_PAIRCOMMIT` is not limited to a height of 128,
200212
that should not be practically feasible to utilize.
201213

202214
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`
204216
together with `OP_PAIRCOMMIT`. This method involves deleted key assumptions,
205217
most likely using MPC to create an enormous amount of signatures for the stack
206218
elements representing the *inputs* and the *output* of the *function*.
207219

208220
## Backward Compatibility
209221

210222
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
212224
rely on the OP_SUCCESS behavior of `OP_SUCCESS205`, `OP_PAIRCOMMIT` would
213225
invalidate their spend.
214226

@@ -236,6 +248,8 @@ This document is licensed under the 3-clause BSD license.
236248

237249
[lnhance]: https://github.com/lnhance/bitcoin
238250
[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
239253

240254
[//]: # (BIPs referenced)
241255
[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.
248262
[BIN-2024-0004]: https://github.com/bitcoin-inquisition/binana/blob/master/2024/BIN-2024-0004.md
249263

250264
[//]: # (Internal links)
251-
[LN-Symmetry]: #use-in-ln-symmetry
252-
[rebindable channel]: #use-in-ln-symmetry
253265
[optimal]: #cost-comparison-of-ln-symmetry-constructions

0 commit comments

Comments
 (0)