Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@0xcert/merkle

0xcert1kMIT2.1.1TypeScript support: included

Implementation of basic functions of binary Merkle tree.

0xcert, framework, protocol, asset, value, values, currency, token, non-fungible, fungible, erc-721, erc-20, blockchain, javascript, typescript, nodejs, vuejs, nuxtjs, npm, libraries, smart-contract, ethereum, zxc

readme

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.

changelog

Change Log - @0xcert/merkle

This log was last generated on Mon, 15 Mar 2021 13:36:24 GMT and should not be manually modified.

2.1.1

Mon, 15 Mar 2021 13:36:24 GMT

Version update only

2.1.0

Thu, 14 Jan 2021 09:48:04 GMT

Version update only

2.0.4

Thu, 14 Jan 2021 09:44:14 GMT

Version update only

2.0.3

Wed, 12 Aug 2020 11:26:03 GMT

Version update only

2.0.2

Mon, 04 May 2020 17:35:38 GMT

Version update only

2.0.1

Fri, 06 Mar 2020 12:54:59 GMT

Version update only

2.0.0

Wed, 19 Jun 2019 10:31:05 GMT

Version update only

1.7.3

Thu, 13 Jun 2019 12:48:22 GMT

Version update only

1.7.2

Wed, 05 Jun 2019 08:40:14 GMT

Version update only

1.7.1

Wed, 05 Jun 2019 08:19:55 GMT

Version update only

1.7.0

Wed, 29 May 2019 13:47:23 GMT

Version update only

1.6.0

Thu, 16 May 2019 16:19:39 GMT

Version update only

1.5.3

Thu, 16 May 2019 16:18:17 GMT

Version update only

1.5.2

Fri, 10 May 2019 16:39:10 GMT

Version update only

1.5.1

Mon, 06 May 2019 16:02:11 GMT

Version update only

1.5.0

Fri, 03 May 2019 12:52:02 GMT

Version update only

1.4.0

Tue, 23 Apr 2019 15:50:38 GMT

Version update only

1.3.0

Tue, 23 Apr 2019 15:15:01 GMT

Version update only

1.2.0

Tue, 23 Apr 2019 14:07:07 GMT

Version update only

1.1.0

Tue, 23 Apr 2019 14:00:03 GMT

Version update only

1.0.2

Tue, 23 Apr 2019 13:16:49 GMT

Version update only

1.0.1

Fri, 22 Mar 2019 09:48:00 GMT

Version update only

1.0.0

Thu, 22 Nov 2018 00:51:03 GMT

Initial release