博客
关于我
Zcash中的merkle tree
阅读量:270 次
发布时间:2019-03-01

本文共 1022 字,大约阅读时间需要 3 分钟。

1. 引言

note commitment tree 是一种具有固定深度的增量性 Merkle 树,用于存储通过 JoinSplit 转移或 Spend 转移产生的 note commitments。它与 Bitcoin 中的 unspent transaction output set (UTXO set) 有以下相似之处:

  • 存在价值的表达:两者都能表达存在价值的能力。

然而,它们在防双花方面存在显著差异:

  • note commitment tree 是 append-only 的,这意味着它无法用于防双花。

2. Merkle 树结构

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}))。

3. note position

note position 指的是一个 note 的 commitment 在最底层(MerkleDepth 为 32)的位置。未使用的 leaf nodes 将关联特定的 hash 值,用于标识未使用的 commitment。

4. Merkle path validity

在 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 匹配。

5. 检查 Merkle path

对于一个已知的 Merkle path 和 root,可以验证某个 leaf node 是否存在于树中。例如,给定一个 hash 值 (M_i^{MerkleDepth}),可以通过计算其 Merkle path 并与 root 进行比较,确认其是否有效。

6. 参考资料

[1]

转载地址:http://ckqx.baihongyu.com/

你可能感兴趣的文章
openshift搭建Istio企业级实战
查看>>
OpenSLL
查看>>
Openssh Openssl升级
查看>>
openssh 加固
查看>>
OPENSSH升级为7.4
查看>>
ViewPager切换滑动速度修改
查看>>
OpenSSL 引入了新的治理模式和项目,来增强社区参与和决策
查看>>
openssl内存分配,查看内存泄露
查看>>
OpenSSL创建SSL证书
查看>>
openssl在cygwin下编译错误:CPU不支持x86_64(CPU you selected does not support x86-64 instruction set )
查看>>
openssl安装
查看>>
openssl安装
查看>>
OpenSSL生成root CA及签发证书
查看>>
Openstack CLI命令管理私有云主机实战(附OpenStack实验环境)
查看>>
openStack instance error 恢复
查看>>
openstack instance resize to
查看>>