Last active
May 19, 2020 04:13
-
-
Save murchandamus/b521d2122befb8f9363874d13d1f41fe to your computer and use it in GitHub Desktop.
Short overview of the costs of 2-of-3 taproot inputs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Everything below is best effort. Corrections welcome! –Murch | |
==== Key path spending costs ==== | |
* outpoint (txid:vout): 32+4vB | |
* scriptSig size: 1vB | |
* nSequence: 4vB | |
* num witness items: 1WU | |
* witness item size: 1WU | |
* signature: 64WU | |
32+4+1+4+(1+1+64)/4 = 57.5vB | |
==== Control Blocks ==== | |
* Depth 0 control block: | |
* Length of control block: 1WU | |
* Header byte (script version, sign of output key): 1WU | |
* Inner key of root key: 32WU | |
= 34WU | |
* Depth 1 control block: | |
* CB size: 1WU | |
* Header byte: 1WU | |
* Inner key of root key: 32WU | |
* Hashing partner in tree: 32WU | |
= 66WU | |
==== Script path spending cost added to key path spending cost ==== | |
Script path spend assuming 2-of-2 MuSig leaf: | |
* script size: 1WU | |
* script "<pk> OP_CHECKSIG": 33+1WU | |
* Depth 1 Control block: 66WU | |
57.5+(1+34+66)/4 = 82.75vB | |
Leafs cannot do MuSig, construction with 2-of-2 OP_CHECKSIG: | |
* +2nd sig: 1+64WU | |
* script size: 1WU | |
* Script "<pk1> OP_CHECKSIGVERIFY <pk2> OP_CHECKSIG": 33+1+33+1=68WU | |
* Depth 1 Control block: 66WU | |
57.5+(1+64+1+68+1+1+32+32)/4 = 107.5vB | |
==== Discarded other options ==== | |
First less inefficient construction for 2-of-2 OP_CHECKSIG: | |
~Improved in second iteration below!~ | |
* +2nd sig: 1+64WU | |
* Length of script: 1WU | |
* Script "<pk1> OP_CHECKSIGVERIFY <pk2> OP_CHECKSIG 2 OP_EQUAL": 33+1+33+1+1+1=70WU | |
* Depth 1 Control block: 66WU | |
57.5+(1+64+1+70+66)/4 = 108vB | |
Less private, more costly variant with a single 2-of-3 leaf in lieu of two 2-of-2 leaves: | |
* +2nd sig: 1+64WU | |
* +1 empty witness item: 2WU | |
* Length of script: 1WU | |
* Script "<pk1> OP_CHECKSIG <pk2> OP_CHECKSIGADD <pk3> OP_CHECKSIGADD 2 OP_EQUAL": 33+1+33+1+33+1+2=104WU | |
* Depth 0 Control block: | |
57.5+(1+64+2+1+104+1+1+32)/4 = 109vB |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment