diff --git a/docs/README.md b/docs/README.md index 18bc68e..03f1440 100644 --- a/docs/README.md +++ b/docs/README.md @@ -133,6 +133,10 @@ npm test - Q: Is there an NFT whitelist example in Solidity? - A: Check out the example repo [merkletreejs-nft-whitelist](https://github.com/miguelmota/merkletreejs-nft-whitelist) on how to generate merkle root of whitelisted accounts and merkle proofs with this library and verify them in Solidity. +- Q: What other types of merkle trees are supported? + + - Besides standard `MerkleTree`, there's also `MerkleMountainRange`, `MerkleSumTree`, and `IncrementalMerkleTree` implemenation classes available. + - Q: Is there a CLI version of this library? - Yes, see [merkletreejs-cli](https://github.com/miguelmota/merkletreejs-cli). diff --git a/docs/classes/_src_base_.base.md b/docs/classes/_src_base_.base.md index 6d5e862..36236bc 100644 --- a/docs/classes/_src_base_.base.md +++ b/docs/classes/_src_base_.base.md @@ -10,6 +10,8 @@ ↳ [MerkleMountainRange](_src_merklemountainrange_.merklemountainrange.md) + ↳ [MerkleSumTree](_src_merklesumtree_.merklesumtree.md) + ↳ [MerkleTree](_src_merkletree_.merkletree.md) ## Index diff --git a/docs/classes/_src_merklesumtree_.bucket.md b/docs/classes/_src_merklesumtree_.bucket.md new file mode 100644 index 0000000..fa83d19 --- /dev/null +++ b/docs/classes/_src_merklesumtree_.bucket.md @@ -0,0 +1,66 @@ +[merkletreejs](../README.md) › [Globals](../globals.md) › ["src/MerkleSumTree"](../modules/_src_merklesumtree_.md) › [Bucket](_src_merklesumtree_.bucket.md) + +# Class: Bucket + +## Hierarchy + +* **Bucket** + +## Index + +### Constructors + +* [constructor](_src_merklesumtree_.bucket.md#constructor) + +### Properties + +* [hashed](_src_merklesumtree_.bucket.md#hashed) +* [left](_src_merklesumtree_.bucket.md#left) +* [parent](_src_merklesumtree_.bucket.md#parent) +* [right](_src_merklesumtree_.bucket.md#right) +* [size](_src_merklesumtree_.bucket.md#size) + +## Constructors + +### constructor + +\+ **new Bucket**(`size`: BigInt | number, `hashed`: Buffer): *[Bucket](_src_merklesumtree_.bucket.md)* + +**Parameters:** + +Name | Type | +------ | ------ | +`size` | BigInt | number | +`hashed` | Buffer | + +**Returns:** *[Bucket](_src_merklesumtree_.bucket.md)* + +## Properties + +### hashed + +• **hashed**: *Buffer* + +___ + +### left + +• **left**: *[Bucket](_src_merklesumtree_.bucket.md) | null* + +___ + +### parent + +• **parent**: *[Bucket](_src_merklesumtree_.bucket.md) | null* + +___ + +### right + +• **right**: *[Bucket](_src_merklesumtree_.bucket.md) | null* + +___ + +### size + +• **size**: *BigInt* diff --git a/docs/classes/_src_merklesumtree_.leaf.md b/docs/classes/_src_merklesumtree_.leaf.md new file mode 100644 index 0000000..4c1b917 --- /dev/null +++ b/docs/classes/_src_merklesumtree_.leaf.md @@ -0,0 +1,65 @@ +[merkletreejs](../README.md) › [Globals](../globals.md) › ["src/MerkleSumTree"](../modules/_src_merklesumtree_.md) › [Leaf](_src_merklesumtree_.leaf.md) + +# Class: Leaf + +## Hierarchy + +* **Leaf** + +## Index + +### Constructors + +* [constructor](_src_merklesumtree_.leaf.md#constructor) + +### Properties + +* [data](_src_merklesumtree_.leaf.md#data) +* [hashFn](_src_merklesumtree_.leaf.md#hashfn) +* [rng](_src_merklesumtree_.leaf.md#rng) + +### Methods + +* [getBucket](_src_merklesumtree_.leaf.md#getbucket) + +## Constructors + +### constructor + +\+ **new Leaf**(`hashFn`: [THashFn](../modules/_src_merklesumtree_.md#thashfn), `rng`: (number | BigInt)[], `data`: Buffer | null): *[Leaf](_src_merklesumtree_.leaf.md)* + +**Parameters:** + +Name | Type | +------ | ------ | +`hashFn` | [THashFn](../modules/_src_merklesumtree_.md#thashfn) | +`rng` | (number | BigInt)[] | +`data` | Buffer | null | + +**Returns:** *[Leaf](_src_merklesumtree_.leaf.md)* + +## Properties + +### data + +• **data**: *Buffer | null* + +___ + +### hashFn + +• **hashFn**: *[THashFn](../modules/_src_merklesumtree_.md#thashfn)* + +___ + +### rng + +• **rng**: *BigInt[]* + +## Methods + +### getBucket + +▸ **getBucket**(): *[Bucket](_src_merklesumtree_.bucket.md)‹›* + +**Returns:** *[Bucket](_src_merklesumtree_.bucket.md)‹›* diff --git a/docs/classes/_src_merklesumtree_.merklesumtree.md b/docs/classes/_src_merklesumtree_.merklesumtree.md new file mode 100644 index 0000000..5354952 --- /dev/null +++ b/docs/classes/_src_merklesumtree_.merklesumtree.md @@ -0,0 +1,674 @@ +[merkletreejs](../README.md) › [Globals](../globals.md) › ["src/MerkleSumTree"](../modules/_src_merklesumtree_.md) › [MerkleSumTree](_src_merklesumtree_.merklesumtree.md) + +# Class: MerkleSumTree + +## Hierarchy + +* [Base](_src_base_.base.md) + + ↳ **MerkleSumTree** + +## Index + +### Constructors + +* [constructor](_src_merklesumtree_.merklesumtree.md#constructor) + +### Properties + +* [buckets](_src_merklesumtree_.merklesumtree.md#buckets) +* [hashFn](_src_merklesumtree_.merklesumtree.md#hashfn) +* [leaves](_src_merklesumtree_.merklesumtree.md#leaves) +* [root](_src_merklesumtree_.merklesumtree.md#root) + +### Methods + +* [bigNumberify](_src_merklesumtree_.merklesumtree.md#bignumberify) +* [binarySearch](_src_merklesumtree_.merklesumtree.md#binarysearch) +* [bufferIndexOf](_src_merklesumtree_.merklesumtree.md#protected-bufferindexof) +* [bufferToHex](_src_merklesumtree_.merklesumtree.md#buffertohex) +* [bufferify](_src_merklesumtree_.merklesumtree.md#bufferify) +* [bufferifyFn](_src_merklesumtree_.merklesumtree.md#bufferifyfn) +* [getProof](_src_merklesumtree_.merklesumtree.md#getproof) +* [isHexString](_src_merklesumtree_.merklesumtree.md#protected-ishexstring) +* [linearSearch](_src_merklesumtree_.merklesumtree.md#linearsearch) +* [log2](_src_merklesumtree_.merklesumtree.md#protected-log2) +* [print](_src_merklesumtree_.merklesumtree.md#print) +* [sizeToBuffer](_src_merklesumtree_.merklesumtree.md#sizetobuffer) +* [sum](_src_merklesumtree_.merklesumtree.md#sum) +* [verifyProof](_src_merklesumtree_.merklesumtree.md#verifyproof) +* [zip](_src_merklesumtree_.merklesumtree.md#protected-zip) +* [bigNumberify](_src_merklesumtree_.merklesumtree.md#static-bignumberify) +* [binarySearch](_src_merklesumtree_.merklesumtree.md#static-binarysearch) +* [bufferToHex](_src_merklesumtree_.merklesumtree.md#static-buffertohex) +* [bufferify](_src_merklesumtree_.merklesumtree.md#static-bufferify) +* [checkConsecutive](_src_merklesumtree_.merklesumtree.md#static-checkconsecutive) +* [hexZeroPad](_src_merklesumtree_.merklesumtree.md#static-hexzeropad) +* [isHexString](_src_merklesumtree_.merklesumtree.md#static-ishexstring) +* [linearSearch](_src_merklesumtree_.merklesumtree.md#static-linearsearch) +* [print](_src_merklesumtree_.merklesumtree.md#static-print) + +## Constructors + +### constructor + +\+ **new MerkleSumTree**(`leaves`: [Leaf](_src_merklesumtree_.leaf.md)[], `hashFn`: [THashFn](../modules/_src_merklesumtree_.md#thashfn)): *[MerkleSumTree](_src_merklesumtree_.merklesumtree.md)* + +**Parameters:** + +Name | Type | +------ | ------ | +`leaves` | [Leaf](_src_merklesumtree_.leaf.md)[] | +`hashFn` | [THashFn](../modules/_src_merklesumtree_.md#thashfn) | + +**Returns:** *[MerkleSumTree](_src_merklesumtree_.merklesumtree.md)* + +## Properties + +### buckets + +• **buckets**: *[Bucket](_src_merklesumtree_.bucket.md)[]* + +___ + +### hashFn + +• **hashFn**: *[THashFn](../modules/_src_merklesumtree_.md#thashfn)* + +___ + +### leaves + +• **leaves**: *[Leaf](_src_merklesumtree_.leaf.md)[]* + +___ + +### root + +• **root**: *[Bucket](_src_merklesumtree_.bucket.md)* + +## Methods + +### bigNumberify + +▸ **bigNumberify**(`value`: any): *BigInt* + +*Inherited from [Base](_src_base_.base.md).[bigNumberify](_src_base_.base.md#bignumberify)* + +**Parameters:** + +Name | Type | +------ | ------ | +`value` | any | + +**Returns:** *BigInt* + +___ + +### binarySearch + +▸ **binarySearch**(`array`: Buffer[], `element`: Buffer, `compareFunction`: function): *number* + +*Inherited from [Base](_src_base_.base.md).[binarySearch](_src_base_.base.md#static-binarysearch)* + +binarySearch + +**`desc`** Returns the first index of which given item is found in array using binary search. + +**`example`** +```js +const index = tree.binarySearch(array, element, Buffer.compare) +``` + +**Parameters:** + +▪ **array**: *Buffer[]* + +Array of items. + +▪ **element**: *Buffer* + +Item to find. + +▪ **compareFunction**: *function* + +▸ (`a`: unknown, `b`: unknown): *number* + +**Parameters:** + +Name | Type | +------ | ------ | +`a` | unknown | +`b` | unknown | + +**Returns:** *number* + +- Index number + +___ + +### `Protected` bufferIndexOf + +▸ **bufferIndexOf**(`array`: Buffer[], `element`: Buffer, `isSorted`: boolean): *number* + +*Inherited from [Base](_src_base_.base.md).[bufferIndexOf](_src_base_.base.md#protected-bufferindexof)* + +bufferIndexOf + +**`desc`** Returns the first index of which given buffer is found in array. + +**`example`** +```js +const index = tree.bufferIndexOf(haystack, needle) +``` + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`array` | Buffer[] | - | +`element` | Buffer | - | +`isSorted` | boolean | false | + +**Returns:** *number* + +- Index number + +___ + +### bufferToHex + +▸ **bufferToHex**(`value`: Buffer, `withPrefix`: boolean): *string* + +*Inherited from [Base](_src_base_.base.md).[bufferToHex](_src_base_.base.md#buffertohex)* + +bufferToHex + +**`desc`** Returns a hex string with 0x prefix for given buffer. + +**`example`** +```js +const hexStr = tree.bufferToHex(Buffer.from('A')) +``` + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`value` | Buffer | - | +`withPrefix` | boolean | true | + +**Returns:** *string* + +___ + +### bufferify + +▸ **bufferify**(`value`: any): *Buffer* + +*Inherited from [Base](_src_base_.base.md).[bufferify](_src_base_.base.md#static-bufferify)* + +bufferify + +**`desc`** Returns a buffer type for the given value. + +**`example`** +```js +const buf = tree.bufferify('0x1234') +``` + +**Parameters:** + +Name | Type | +------ | ------ | +`value` | any | + +**Returns:** *Buffer* + +___ + +### bufferifyFn + +▸ **bufferifyFn**(`f`: any): *any* + +*Inherited from [Base](_src_base_.base.md).[bufferifyFn](_src_base_.base.md#bufferifyfn)* + +bufferifyFn + +**`desc`** Returns a function that will bufferify the return value. + +**`example`** +```js +const fn = tree.bufferifyFn((value) => sha256(value)) +``` + +**Parameters:** + +Name | Type | +------ | ------ | +`f` | any | + +**Returns:** *any* + +___ + +### getProof + +▸ **getProof**(`index`: number | BigInt): *any[]* + +**Parameters:** + +Name | Type | +------ | ------ | +`index` | number | BigInt | + +**Returns:** *any[]* + +___ + +### `Protected` isHexString + +▸ **isHexString**(`value`: string): *boolean* + +*Inherited from [Base](_src_base_.base.md).[isHexString](_src_base_.base.md#static-ishexstring)* + +isHexString + +**`desc`** Returns true if value is a hex string. + +**`example`** +```js +console.log(MerkleTree.isHexString('0x1234')) +``` + +**Parameters:** + +Name | Type | +------ | ------ | +`value` | string | + +**Returns:** *boolean* + +___ + +### linearSearch + +▸ **linearSearch**(`array`: Buffer[], `element`: Buffer, `eqChecker`: function): *number* + +*Inherited from [Base](_src_base_.base.md).[linearSearch](_src_base_.base.md#static-linearsearch)* + +linearSearch + +**`desc`** Returns the first index of which given item is found in array using linear search. + +**`example`** +```js +const index = tree.linearSearch(array, element, (a, b) => a === b) +``` + +**Parameters:** + +▪ **array**: *Buffer[]* + +Array of items. + +▪ **element**: *Buffer* + +Item to find. + +▪ **eqChecker**: *function* + +▸ (`a`: unknown, `b`: unknown): *boolean* + +**Parameters:** + +Name | Type | +------ | ------ | +`a` | unknown | +`b` | unknown | + +**Returns:** *number* + +- Index number + +___ + +### `Protected` log2 + +▸ **log2**(`n`: number): *number* + +*Inherited from [Base](_src_base_.base.md).[log2](_src_base_.base.md#protected-log2)* + +log2 + +**`desc`** Returns the log2 of number. + +**Parameters:** + +Name | Type | +------ | ------ | +`n` | number | + +**Returns:** *number* + +___ + +### print + +▸ **print**(): *void* + +*Inherited from [Base](_src_base_.base.md).[print](_src_base_.base.md#print)* + +print + +**`desc`** Prints out a visual representation of the merkle tree. + +**`example`** +```js +tree.print() +``` + +**Returns:** *void* + +___ + +### sizeToBuffer + +▸ **sizeToBuffer**(`size`: BigInt): *Buffer‹›* + +**Parameters:** + +Name | Type | +------ | ------ | +`size` | BigInt | + +**Returns:** *Buffer‹›* + +___ + +### sum + +▸ **sum**(`arr`: BigInt[]): *bigint* + +**Parameters:** + +Name | Type | +------ | ------ | +`arr` | BigInt[] | + +**Returns:** *bigint* + +___ + +### verifyProof + +▸ **verifyProof**(`root`: [Bucket](_src_merklesumtree_.bucket.md), `leaf`: [Leaf](_src_merklesumtree_.leaf.md), `proof`: [ProofStep](_src_merklesumtree_.proofstep.md)[]): *boolean* + +**Parameters:** + +Name | Type | +------ | ------ | +`root` | [Bucket](_src_merklesumtree_.bucket.md) | +`leaf` | [Leaf](_src_merklesumtree_.leaf.md) | +`proof` | [ProofStep](_src_merklesumtree_.proofstep.md)[] | + +**Returns:** *boolean* + +___ + +### `Protected` zip + +▸ **zip**(`a`: any[], `b`: any[]): *any[][]* + +*Inherited from [Base](_src_base_.base.md).[zip](_src_base_.base.md#protected-zip)* + +zip + +**`desc`** Returns true if value is a hex string. + +**`example`** +```js +const zipped = tree.zip(['a', 'b'],['A', 'B']) +console.log(zipped) // [ [ 'a', 'A' ], [ 'b', 'B' ] ] +``` + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`a` | any[] | first array | +`b` | any[] | second array | + +**Returns:** *any[][]* + +___ + +### `Static` bigNumberify + +▸ **bigNumberify**(`value`: any): *BigInt* + +*Inherited from [Base](_src_base_.base.md).[bigNumberify](_src_base_.base.md#bignumberify)* + +**Parameters:** + +Name | Type | +------ | ------ | +`value` | any | + +**Returns:** *BigInt* + +___ + +### `Static` binarySearch + +▸ **binarySearch**(`array`: Buffer[], `element`: Buffer, `compareFunction`: function): *number* + +*Inherited from [Base](_src_base_.base.md).[binarySearch](_src_base_.base.md#static-binarysearch)* + +binarySearch + +**`desc`** Returns the first index of which given item is found in array using binary search. + +**`example`** +```js +const index = MerkleTree.binarySearch(array, element, Buffer.compare) +``` + +**Parameters:** + +▪ **array**: *Buffer[]* + +Array of items. + +▪ **element**: *Buffer* + +Item to find. + +▪ **compareFunction**: *function* + +▸ (`a`: unknown, `b`: unknown): *number* + +**Parameters:** + +Name | Type | +------ | ------ | +`a` | unknown | +`b` | unknown | + +**Returns:** *number* + +- Index number + +___ + +### `Static` bufferToHex + +▸ **bufferToHex**(`value`: Buffer, `withPrefix`: boolean): *string* + +*Inherited from [Base](_src_base_.base.md).[bufferToHex](_src_base_.base.md#buffertohex)* + +bufferToHex + +**`desc`** Returns a hex string with 0x prefix for given buffer. + +**`example`** +```js +const hexStr = MerkleTree.bufferToHex(Buffer.from('A')) +``` + +**Parameters:** + +Name | Type | Default | +------ | ------ | ------ | +`value` | Buffer | - | +`withPrefix` | boolean | true | + +**Returns:** *string* + +___ + +### `Static` bufferify + +▸ **bufferify**(`value`: any): *Buffer* + +*Inherited from [Base](_src_base_.base.md).[bufferify](_src_base_.base.md#static-bufferify)* + +bufferify + +**`desc`** Returns a buffer type for the given value. + +**`example`** +```js +const buf = MerkleTree.bufferify('0x1234') +``` + +**Parameters:** + +Name | Type | +------ | ------ | +`value` | any | + +**Returns:** *Buffer* + +___ + +### `Static` checkConsecutive + +▸ **checkConsecutive**(`leaves`: [Leaf](_src_merklesumtree_.leaf.md)[]): *void* + +**Parameters:** + +Name | Type | +------ | ------ | +`leaves` | [Leaf](_src_merklesumtree_.leaf.md)[] | + +**Returns:** *void* + +___ + +### `Static` hexZeroPad + +▸ **hexZeroPad**(`hexStr`: string, `length`: number): *string* + +*Inherited from [Base](_src_base_.base.md).[hexZeroPad](_src_base_.base.md#static-hexzeropad)* + +**Parameters:** + +Name | Type | +------ | ------ | +`hexStr` | string | +`length` | number | + +**Returns:** *string* + +___ + +### `Static` isHexString + +▸ **isHexString**(`v`: string): *boolean* + +*Inherited from [Base](_src_base_.base.md).[isHexString](_src_base_.base.md#static-ishexstring)* + +isHexString + +**`desc`** Returns true if value is a hex string. + +**`example`** +```js +console.log(MerkleTree.isHexString('0x1234')) +``` + +**Parameters:** + +Name | Type | +------ | ------ | +`v` | string | + +**Returns:** *boolean* + +___ + +### `Static` linearSearch + +▸ **linearSearch**(`array`: Buffer[], `element`: Buffer, `eqChecker`: function): *number* + +*Inherited from [Base](_src_base_.base.md).[linearSearch](_src_base_.base.md#static-linearsearch)* + +linearSearch + +**`desc`** Returns the first index of which given item is found in array using linear search. + +**`example`** +```js +const index = MerkleTree.linearSearch(array, element, (a, b) => a === b) +``` + +**Parameters:** + +▪ **array**: *Buffer[]* + +Array of items. + +▪ **element**: *Buffer* + +Item to find. + +▪ **eqChecker**: *function* + +▸ (`a`: unknown, `b`: unknown): *boolean* + +**Parameters:** + +Name | Type | +------ | ------ | +`a` | unknown | +`b` | unknown | + +**Returns:** *number* + +- Index number + +___ + +### `Static` print + +▸ **print**(`tree`: any): *void* + +*Inherited from [Base](_src_base_.base.md).[print](_src_base_.base.md#print)* + +print + +**`desc`** Prints out a visual representation of the given merkle tree. + +**`example`** +```js +MerkleTree.print(tree) +``` + +**Parameters:** + +Name | Type | Description | +------ | ------ | ------ | +`tree` | any | Merkle tree instance. | + +**Returns:** *void* diff --git a/docs/classes/_src_merklesumtree_.proofstep.md b/docs/classes/_src_merklesumtree_.proofstep.md new file mode 100644 index 0000000..193b6c5 --- /dev/null +++ b/docs/classes/_src_merklesumtree_.proofstep.md @@ -0,0 +1,45 @@ +[merkletreejs](../README.md) › [Globals](../globals.md) › ["src/MerkleSumTree"](../modules/_src_merklesumtree_.md) › [ProofStep](_src_merklesumtree_.proofstep.md) + +# Class: ProofStep + +## Hierarchy + +* **ProofStep** + +## Index + +### Constructors + +* [constructor](_src_merklesumtree_.proofstep.md#constructor) + +### Properties + +* [bucket](_src_merklesumtree_.proofstep.md#bucket) +* [right](_src_merklesumtree_.proofstep.md#right) + +## Constructors + +### constructor + +\+ **new ProofStep**(`bucket`: [Bucket](_src_merklesumtree_.bucket.md), `right`: boolean): *[ProofStep](_src_merklesumtree_.proofstep.md)* + +**Parameters:** + +Name | Type | +------ | ------ | +`bucket` | [Bucket](_src_merklesumtree_.bucket.md) | +`right` | boolean | + +**Returns:** *[ProofStep](_src_merklesumtree_.proofstep.md)* + +## Properties + +### bucket + +• **bucket**: *[Bucket](_src_merklesumtree_.bucket.md)* + +___ + +### right + +• **right**: *boolean* diff --git a/docs/globals.md b/docs/globals.md index 63219fe..c3ebe7d 100644 --- a/docs/globals.md +++ b/docs/globals.md @@ -9,5 +9,6 @@ * ["src/Base"](modules/_src_base_.md) * ["src/IncrementalMerkleTree"](modules/_src_incrementalmerkletree_.md) * ["src/MerkleMountainRange"](modules/_src_merklemountainrange_.md) +* ["src/MerkleSumTree"](modules/_src_merklesumtree_.md) * ["src/MerkleTree"](modules/_src_merkletree_.md) * ["src/index"](modules/_src_index_.md) diff --git a/docs/modules/_src_index_.md b/docs/modules/_src_index_.md index ad91663..92e05b9 100644 --- a/docs/modules/_src_index_.md +++ b/docs/modules/_src_index_.md @@ -8,6 +8,7 @@ * [IncrementalMerkleTree](_src_index_.md#incrementalmerkletree) * [MerkleMountainRange](_src_index_.md#merklemountainrange) +* [MerkleSumTree](_src_index_.md#merklesumtree) ## References @@ -20,3 +21,9 @@ ___ ### MerkleMountainRange • **MerkleMountainRange**: + +___ + +### MerkleSumTree + +• **MerkleSumTree**: diff --git a/docs/modules/_src_merklesumtree_.md b/docs/modules/_src_merklesumtree_.md new file mode 100644 index 0000000..9755f2c --- /dev/null +++ b/docs/modules/_src_merklesumtree_.md @@ -0,0 +1,39 @@ +[merkletreejs](../README.md) › [Globals](../globals.md) › ["src/MerkleSumTree"](_src_merklesumtree_.md) + +# Module: "src/MerkleSumTree" + +## Index + +### Classes + +* [Bucket](../classes/_src_merklesumtree_.bucket.md) +* [Leaf](../classes/_src_merklesumtree_.leaf.md) +* [MerkleSumTree](../classes/_src_merklesumtree_.merklesumtree.md) +* [ProofStep](../classes/_src_merklesumtree_.proofstep.md) + +### Type aliases + +* [THashFn](_src_merklesumtree_.md#thashfn) +* [TValue](_src_merklesumtree_.md#tvalue) + +## Type aliases + +### THashFn + +Ƭ **THashFn**: *function* + +#### Type declaration: + +▸ (`value`: [TValue](_src_merklesumtree_.md#tvalue)): *Buffer* + +**Parameters:** + +Name | Type | +------ | ------ | +`value` | [TValue](_src_merklesumtree_.md#tvalue) | + +___ + +### TValue + +Ƭ **TValue**: *Buffer | BigInt | string | number | null | undefined* diff --git a/test/MerkleSumTree.test.js b/test/MerkleSumTree.test.js index 8346ab0..7ef72e0 100644 --- a/test/MerkleSumTree.test.js +++ b/test/MerkleSumTree.test.js @@ -4,7 +4,7 @@ const { MerkleSumTree, Leaf } = require('../dist/MerkleSumTree') const sha256 = (data) => crypto.createHash('sha256').update(data).digest() -test('MerkleSumTree', t => { +test('MerkleSumTree - sha256', t => { t.plan(4) const treeSize = 2n ** 64n