博客
关于我
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/

你可能感兴趣的文章
Process.run() 和 Process.start() 之间的区别
查看>>
Processes
查看>>
Processing通过编程实现艺术设计_实现艺术和现实的交互---数据设计分析002
查看>>
ProcessOnLoading
查看>>
SpringBoot中集成screw(螺丝钉)实现数据库表结构文档生成
查看>>
PROFINET 模拟器使用教程
查看>>
Program type already present: android.support.v4.widget.EdgeEffectCompat
查看>>
PyTorch中文版官方教程来啦(附下载)
查看>>
Progress Kemp LoadMaster 远程命令执行漏洞复现(CVE-2024-1212)
查看>>
Project configuration is not up-to-date with pom.xml. Run Maven->Update Project
查看>>
Project Euler 15 Lattice paths
查看>>
Project Euler 48 Self powers( 大数求余 )
查看>>
Project Euler Problem 12: Highly divisible triangular number
查看>>
ProjectEuler 2
查看>>
projection介绍及EPSG:4326和EPSG:3857的投射转换
查看>>
project打开文件时,显示无法识别此文件格式?
查看>>
Prometheus + Grafana on Kubernetes部署
查看>>
prometheus + grafana进行服务器资源监控
查看>>
Prometheus Alertmanager 告警配置详解
查看>>
Prometheus Grafana 展示平台
查看>>