Skip to content

Commit 4ff7cd0

Browse files
berryjamgitbook-bot
authored andcommitted
GITBOOK-101: No subject
1 parent 81a11a4 commit 4ff7cd0

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

di-shi-yi-zhang-.-qu-kuai-lian/mo-ke-er-shu.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,26 @@ HAB = SHA256(SHA256(HA || HB))
5050
<figure><img src="../.gitbook/assets/11.6.png" alt=""><figcaption><p>图 11-6. 用于证明数据元素包含在内的 Merkle 路径</p></figcaption></figure>
5151

5252
当规模增加时,Merkle 树的效率变得明显。最大可能的区块可以容纳近 16,000 笔交易,占用 4,000,000 字节,但证明其中的任何一笔交易是该区块的一部分只需要交易的副本、80 字节区块头的副本和 448 字节的 Merkle 证明。这使得最大可能的证明几乎比最大可能的比特币区块小了 10,000 倍。
53+
54+
补充说明下,这里为什么需要448字节的Merkle证明。
55+
56+
构造16000笔交易的Merkle树过程如下(只包含当前层数,节点当前数量):
57+
58+
<pre><code><strong>1.16000
59+
</strong>2.8000
60+
3.4000
61+
4.2000
62+
5.1000
63+
6.500
64+
7.250
65+
8.125->126 (这里125为奇数,需要复制最后一个节点)
66+
9.64
67+
10.32
68+
11.16
69+
12.8
70+
13.4
71+
14.2
72+
15.1
73+
</code></pre>
74+
75+
可以看出整颗树高为15,而构造出Merkle path只需要前14层各一个hash即可,root可直接计算出。由于每个hash是32个字节,所以一共需要14\*32=448字节。

0 commit comments

Comments
 (0)