Questions about the MAST tree from the book “Mastering Bitcoin”
It seems to me that the text should read “We can have 4”. conditions “For the same cost.”
MAST is a binary tree. This means that the number of possible scripts (conditions) increases exponentially with the size of the inclusion proof, or, equivalently, the size of the inclusion proof increases logarithmically with the number of possible scripts. For example, in a balanced tree:
- 1 commit (Merkle root) gives 1 possible script.
- Two promises (a Merkle root and a branch step) give us two possible scripts.
- Provides 4 possible scripts with 3 promises (Merkle root and 2 branch steps)
- Provides 8 possible scripts with 4 promises (Merkle root and 3 branching steps)
The original text says that both 3 and 4 possible scripts require 3 promises.
It is important to remember that if some conditions are expected to be used more frequently, it may be helpful to use incomplete/imbalanced binary trees (and we discuss this in the very next section of the book). Placing shallower parts of the tree results in using less block space on average.