I asked a few questions within this one. They are all related to the leaf version, so I didn't find it necessary to split them into multiple separate questions as they can all be answered in 1/2 a sentence (at least I assume).
Thanks to all in advance.
- What is leaf version?
- In BIP341 they say that leaf represents a logical AND between the first byte of the control block and
0xfe
.- I quote: "Let v = c[0] & 0xfe and call it the leaf version"
- Pieter Wuille said in his answer that only the top 7 bits of the first byte of the control block (
11111110
) represent leaf version while the first (bottom) bit (00000001
) of the same byte is a sign.- I quote: "Its first byte stores the leaf version (#3) (top 7 bits) and the sign bit (#6) (bottom bit)."
- In some answers/articles I also read that the leaf version represents entire first byte of the control block.
- In BIP341 they say that leaf represents a logical AND between the first byte of the control block and
- What is the purpose of leaf version?
- As I understand it, it is a way to indicate which type of script is used, i.e. that some special opcodes can be found within that script or that the existing ones have a different meaning, or that the content of that script has some totally new special meaning. Therefore, each leaf (script), has its version that defines the way in which we observe its content (something similar to the witness version in segWit). So, when we use a script from MAST, we must also specify its version in order to know how its content is treated (but also to correctly calculate the complete tree). Am I right?
- What is the leaf version value for using the normal (standard) Bitcoin scripts if its even possible to use them inside taproot? (with normal script I mean on scripts used in non-segwit outputs or in P2SH etc.)
- What are the all possible values for the leaf version?
- BIP341[7] and Pieter Wuille gave some answers, but I still do not understand. I understand why it cannot be 0x50 (so as not to be confused with the annex) and why it can be only even value (because logical AND is done with 11111110), but it is not clear to me why there must be only those values listed there in the BIP341[7]/Pieter Wuille's answer.