@aztec/merkle-tree

中文文档
4.4.0发布于 2026/06/27TypeScriptES Module近 30 天下载 4778

The Merkle Trees package contains typescript implementations of the various Merkle Trees required by the system.

原始使用文档
文档目录4 节
  1. Overview
  2. Implementations
  3. Tree Operations
  4. Building/Testing

Merkle Tree

Overview

The Merkle Trees package contains typescript implementations of the various Merkle Trees required by the system.

  • Append only 'Standard' merkle trees. New values are inserted into the next available leaf index. Values are never updated.
  • Indexed trees are also append only in nature but retain the ability to update leaves. The reason for this is that the Indexed Tree leaves not only store the value but the index of the next highest leaf. New insertions can require prior leaves to be updated.
  • Sparse trees that can be updated at any index. The 'size' of the tree is defined by the number of non-empty leaves, not by the highest populated leaf index as is the case with a Standard Tree.

Implementations

All implementations require the following arguments:

  • An instance of level db for storing information at a tree node level as well as some tree level metadata.
  • An instance of a Hasher object. Used for hashing the nodes of the Merkle Tree.
  • A name, for namespacing the tree's nodes within the db.
  • The depth of the tree, this is exclusive of the root.

Implementations have commit/rollback semantics with modifications stored only in memory until being committed. Rolling back returns the tree discards the cached modifications and returns the tree to it's previous committed state.

Tree Operations

The primary operations available on the various implementations are:

  • Create a new, empty tree
  • Restore a tree from the provided DB
  • Append new leaves (Standard and Indexed trees only)
  • Update a leaf (Sparse tree and Indexed trees only)
  • Retrieve the number of leaves. This is the number of non empty leaves for a Sparse tree and the highest populated index for Standard and Indexed trees.
  • Commit modifications
  • Rollback modifications
  • Retrieve a Sibling Path for a given index. For performing Merkle proofs it is necessary to derive the set of nodes from a leaf index to the root of the tree, known as the 'hash path'. Given a leaf, it is therefore required to have the 'sibling' node at each tree level in order for the hash path to be computed.

Note: Tree operations are not 'thread' safe. Operations should be queued or otherwise executed serially to ensure consistency of the data structures and any data retrieved from them.

Building/Testing

To build the package, execute yarn build in the root.

To run the tests, execute yarn test.

版本与发布记录

@aztec/merkle-tree 共发布 1,036 个版本,首次发布于 2023/07/08;过去 12 个月发布了 481 个版本。

版本发布日期距今
4.4.0latest2026/06/274 个月前
0.0.1-dev2026/06/264 个月前
4.4.0-nightly.202606182026/06/184 个月前
4.4.0-nightly.202606172026/06/174 个月前
4.4.0-nightly.202606162026/06/164 个月前
4.4.0-nightly.202606152026/06/154 个月前

其他发布通道:next → 0.75.0-commit.c03ba01a2a4122e43e90d5133ba017e54b90e9d2,test → 0.0.0-test.1,alpha-testnet → 0.85.0-alpha-testnet.11,starknet → 0.87.4-starknet.1,staging → 1.0.0-staging.6,canary → 3.0.0-canary.a9708bd。

关于 @aztec/merkle-tree 的常见问题

@aztec/merkle-tree 是什么?

The Merkle Trees package contains typescript implementations of the various Merkle Trees required by the system.

如何安装 @aztec/merkle-tree?

在项目目录运行 npm install @aztec/merkle-tree,或使用 pnpm add / yarn add / bun add。

@aztec/merkle-tree 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@aztec/merkle-tree 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@aztec/merkle-tree 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20.10。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@aztec/merkle-tree 可以商用吗?

@aztec/merkle-tree 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@aztec/merkle-tree 的下载量有多少?

根据 npm 官方下载统计,@aztec/merkle-tree 在 2026/10/08 – 2026/11/06 这 30 天内被下载 4,778 次,日均约 159 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@aztec/merkle-tree 还在维护吗?

最新版本 4.4.0 发布于 2026/06/27(4 个月前);至今共发布 1036 个版本,其中过去 12 个月发布了 481 个;首次发布于 2023/07/08。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。