本文共 1022 字,大约阅读时间需要 3 分钟。
note commitment tree 是一种具有固定深度的增量性 Merkle 树,用于存储通过 JoinSplit 转移或 Spend 转移产生的 note commitments。它与 Bitcoin 中的 unspent transaction output set (UTXO set) 有以下相似之处:
然而,它们在防双花方面存在显著差异:
note commitment tree 的根节点位于 0 层。在第 h 层,有 (2^h) 个节点,编号从 0 到 (2^h - 1)。每个节点对应一个 255 位的 hash 值。
对于第 h 层的第 i 个节点,其 hash 值表示为 (M_i^h),其中 (M_i^h = \text{MerkleCRH}^{Sapling}(M_{2i}^{h+1}, M_{2i+1}^{h+1}))。
note position 指的是一个 note 的 commitment 在最底层(MerkleDepth 为 32)的位置。未使用的 leaf nodes 将关联特定的 hash 值,用于标识未使用的 commitment。
在 note commitment tree 中,每个节点都关联一个 255 位的 hash 值。通过从 leaf node 到 root 的 Merkle path,可以验证一个 commitment 是否存在于 tree 中。
Merkle path 由一系列 hash 值构成,例如:
[ [M_{sibling(h,i)}^h] ]
其中,(h) 和 (i) 是路径中的参数。通过计算 Merkle path,可以验证给定的 hash 值是否与 root 匹配。
对于一个已知的 Merkle path 和 root,可以验证某个 leaf node 是否存在于树中。例如,给定一个 hash 值 (M_i^{MerkleDepth}),可以通过计算其 Merkle path 并与 root 进行比较,确认其是否有效。
[1]
转载地址:http://ckqx.baihongyu.com/