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

你可能感兴趣的文章
Postman的使用说明
查看>>
Postman被低估的功能 — 自动化接口测试
查看>>
Postman被低估的功能 — 自动化接口测试
查看>>
Postman轻松签名,让SHA256withRSA保驾护航
查看>>
Postman还能做Mock?又学了一招!
查看>>
Postman还能做Mock?又学了一招!
查看>>
postman进行http接口测试
查看>>
Postman高阶技能:Collection集合批量运行!
查看>>
postMessage跨标签页共享数据
查看>>
post为什么会发送两次请求?
查看>>
Post表单提交TextArea的值出现转译乱码问题 - Spring MVC处理表单提交
查看>>
Power BI 中的 Python 可视化需要什么设置?任何特定的 matplotlib 包版本或系统设置?
查看>>
Power BI:如何在 Power Query 编辑器中将 Python 与多个表一起使用?
查看>>
power english (3) main text -emotion mastery - focus
查看>>
POWER ENGLISH (6) - MODEL
查看>>
power english (1) —— passion
查看>>
Power English (1) 原文
查看>>
power English (3)原文
查看>>
POWER ENGLISH(7)- repetition
查看>>
SpringBoot中集成SpringBatch详细解析与实战示例(CSV文件读取十万条数据进行业务处理后写入Mysql数据库)
查看>>