@0xcert/merkle

中文文档
2.1.1发布于 2021/03/15MITTypeScriptCommonJS零依赖近 30 天下载 2159

Implementation of basic functions of binary Merkle tree.

原始使用文档

Implementation of basic functions of a binary Merkle tree.

This module handles binary trees like this (v = value, n = node, r = nonce):

       n0
       |
   ---------
   |       |
   n1      n2
   |       |
|-----|    |
v0    r0   |
      ---------
      |       |
      n3      n4
      |       |
   |-----|    |
   v1    r1   r2

A user defines an array of values where these values are hashed into an imprint, which is a Merkle root tree hash. A user can expose selected values to a third-party by providing the evidence file which includes a recipe of values and nodes. This file holds enough information for a third-party to recreate the imprint.

import { sha } from '@0xcert/utils'; 
import { Merkle } from '@0xcert/merkle'; 

const merkle = new Merkle({
  hasher: (v, p, k) => sha(256, v),
  noncer: (p) => Math.random().toString(36).substring(7),
});
const values = ['A', 'B', 'C', 'D', 'E'];
const expose = [2, 3];
const fullRecipe = await merkle.notarize(values);
const minRecipe = await merkle.disclose(fullRecipe, expose);
const imprint = await merkle.imprint(minRecipe);

The 0xcert Framework is a free and open-source JavaScript library that provides tools for building powerful decentralized applications. Please refer to the official documentation for more details.

This module is one of the bricks of the 0xcert Framework. It's written with TypeScript and it's actively maintained. The source code is available on GitHub where you can also find our issue tracker.

版本与发布记录

@0xcert/merkle 共发布 76 个版本,首次发布于 2018/11/21;过去 12 个月发布了 0 个版本。

版本发布日期距今
2.1.1latest2021/03/155 年前
2.1.02021/01/145 年前
2.0.32020/08/126 年前
2.0.22020/05/056 年前
2.0.12020/03/066 年前
2.0.1-beta02020/03/056 年前

关于 @0xcert/merkle 的常见问题

@0xcert/merkle 是什么?

Implementation of basic functions of binary Merkle tree.

如何安装 @0xcert/merkle?

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

@0xcert/merkle 支持 TypeScript 吗?

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

@0xcert/merkle 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@0xcert/merkle 可以商用吗?

@0xcert/merkle 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@0xcert/merkle 的下载量有多少?

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

@0xcert/merkle 还在维护吗?

最新版本 2.1.1 发布于 2021/03/15(5 年前);至今共发布 76 个版本,其中过去 12 个月发布了 0 个;首次发布于 2018/11/21。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。