WITHDRAWN
- Let t = hashTapTweak(p || km).
You can’t back-calculate the internal key from the SPK and the script tree - would make taproot all in secure if that worked.
Original post
I blame Lisa.
I’m writing my deck for BTC++ and I think that there’s an alternate design for Lightning Symmetry channel scripts when specifically designed for use with LNHANCE instead of APO.
Basic background reading is Greg’s thread.
Scripts
For LNHANCE-Symmetry, we have the following script structures:
Channel outpoint
LNHANCE: tr(musig2(a, b), CTV INTERNALKEY CSFS)
APO: tr(musig(a, b), 1 CHECKSIG)
Update (tapleaves)
LNHANCE: tr(settlement-hash, {<n+1> CLTV DROP CTV musig2(a, b) CSFS, INTERNALKEY CTV})
APO: tr(musig(a, b), {<n+1> CLTV DROP 1 CHECKSIG, <settlement-sig> <G> CHECKSIG})
Update (OP_IF)
LNHANCE: tr(settlement-hash, DEPTH NOTIF INTERNALKEY CTV ELSE <n+1> CLTV DROP CTV musig2(a, b) CSFS ENDIF)
APO: tr(musig(a, b), DEPTH NOTIF <settlement-sig> <G> CHECKSIG ELSE <n+1> CLTV DROP 1 CHECKSIG ENDIF)
Discussion
In Greg’s APO-Symmetry design, the taproot annex is used to store the hash of the settlement transaction which was used to generate the settlement sig for the settlement transaction corresponding to the update transaction being signed. This ensures that if Alice publishes an update and Bob has a later update, he can recover the taproot sibling hash needed to spend Alice’s update.
In LNHANCE-Symmetry, the settlement transaction’s CTV hash can be ground to a valid X on the curve and then used as the internal key for the taproot output. This makes the tapscripts identical from update to update ensuring that either party can store O(1) data and be able to spend any prior update.
Witness sizes
Summary
Variant | Initial update | Subsequent update | Settlement |
---|---|---|---|
APO-Symmetry (tapleaves) | 137WU | 176WU | 168WU |
APO-Symmetry (OP_IF) | 137WU | 249WU | 149WU |
LNHANCE-Symmetry (tapleaves) | 136WU | 207WU | 69WU |
LNHANCE-Symmetry (OP_IF) | 136WU | 149WU | 83WU |
weight calculations
APO-Symmetry:
Initial update
- 33-byte annex
- 33-byte control block
- 2-byte script
- 65-byte signature
- Total: 4+33+33+2+65=137WU
Subsequent update (tapleaves)
- 33-byte annex
- 65-byte control block
- 9-byte script
- 65-byte signature
- Total: 4+33+65+9+65=176WU
Settlement (tapleaves)
- 65-byte control block
- 66+33+1-byte script
- Total: 2+65+(65+1+33+1+1)=168WU
Subsequent update (OP_IF)
- 33-byte annex
- 33-byte control block
- 114-byte script
- 65-byte signature
- Total: 4+33+33+114+65=249WU
Settlement (OP_IF)
- 65-byte control block
- 114-byte script
- Total: 2+33+114=149WU
LNHANCE-Symmetry
Initial update
- 33-byte control block
- 3-byte script
- 32-byte hash
- 64-byte signature
- Total: 4+33+3+64+32=136WU
Subsequent update (tapleaves)
- 65-byte control block
- 42-byte script
- 32-byte hash
- 64-byte signature
- Total: 4+65+42+64=207WU
Settlement (tapleaves)
- 65-byte control block
- 2-byte script
- Total: 2+65+2=69WU
Subsequent update (OP_IF)
- 33-byte control block
- 48-byte script
- 32-byte hash
- 64-byte signature
- Total: 4+33+48+64=149WU
Settlement (OP_IF)
- 33-byte control block
- 48-byte script
- Total: 2+33+48=83WU
Conclusion?
Where a 32-byte hash can be used for settlement, there is a significant weight saving for Lightning Symmetry channels from overloading the taproot internal key with the settlement hash.
Edit: Added OP_IF variants
The APO-Symmetry OP_IF variant favors force closes that are not challenged significantly. It moderately reduces overall weight when a close is not challenged and significantly increases overall weight when it is challenged.
LNHANCE-Symmetry already favors non-challenged closes significantly, and the OP_IF variant reduces that. It slightly increases overall weight when a close is not challenged, and significantly reduces overall weight when it is challenged.
Which of these variants might be preferred when building production Lightning Symmetry depends on the relative importance they give to unchallenged force close weight vs. the cost of challenge when necessary.
Edit: not as great a savings when i properly include the ctv hash in the update witness stack. Sigh. OP_TEMPLATEHASH (or TXHASH) in tapscript only would improve the gains.