Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

merkletreejs

Package Overview
Dependencies
Maintainers
1
Versions
78
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

merkletreejs - npm Package Compare versions

Comparing version 0.2.21 to 0.2.22

19

dist/MerkleTree.d.ts

@@ -43,3 +43,3 @@ /// <reference types="node" />

* @param {Buffer[]} leaves - Array of hashed leaves. Each leaf must be a Buffer.
* @param {Function} hashFunction - Algorithm used for hashing leaves and nodes
* @param {Function} hashFunction - Hash function to use for hashing leaves and nodes
* @param {Object} options - Additional options

@@ -344,2 +344,19 @@ * @example

/**
* verify
* @desc Returns true if the proof path (array of hashes) can connect the target node
* to the Merkle root.
* @param {Object[]} proof - Array of proof objects that should connect
* target node to Merkle root.
* @param {Buffer} targetNode - Target node Buffer
* @param {Buffer} root - Merkle root Buffer
* @param {Function} hashFunction - Hash function for hashing leaves and nodes
* @param {Object} options - Additional options
* @return {Boolean}
* @example
*```js
*const verified = MerkleTree.verify(proof, leaf, root, sha256, options)
*```
*/
static verify(proof: any[], targetNode: Buffer | string, root: Buffer | string, hashFn?: any, options?: Options): boolean;
/**
* getMultiProof

@@ -346,0 +363,0 @@ * @desc Returns the multiproof for given tree indices.

@@ -21,3 +21,3 @@ "use strict";

* @param {Buffer[]} leaves - Array of hashed leaves. Each leaf must be a Buffer.
* @param {Function} hashFunction - Algorithm used for hashing leaves and nodes
* @param {Function} hashFunction - Hash function to use for hashing leaves and nodes
* @param {Object} options - Additional options

@@ -329,2 +329,5 @@ * @example

getProof(leaf, index) {
if (typeof leaf === 'undefined') {
throw new Error('leaf is required');
}
leaf = this.bufferify(leaf);

@@ -797,2 +800,22 @@ const proof = [];

/**
* verify
* @desc Returns true if the proof path (array of hashes) can connect the target node
* to the Merkle root.
* @param {Object[]} proof - Array of proof objects that should connect
* target node to Merkle root.
* @param {Buffer} targetNode - Target node Buffer
* @param {Buffer} root - Merkle root Buffer
* @param {Function} hashFunction - Hash function for hashing leaves and nodes
* @param {Object} options - Additional options
* @return {Boolean}
* @example
*```js
*const verified = MerkleTree.verify(proof, leaf, root, sha256, options)
*```
*/
static verify(proof, targetNode, root, hashFn = sha256_1.default, options = {}) {
const tree = new MerkleTree([], hashFn, options);
return tree.verify(proof, targetNode, root);
}
/**
* getMultiProof

@@ -799,0 +822,0 @@ * @desc Returns the multiproof for given tree indices.

3

package.json
{
"name": "merkletreejs",
"version": "0.2.21",
"version": "0.2.22",
"description": "Construct Merkle Trees and verify proofs",

@@ -17,2 +17,3 @@ "main": "dist/index.js",

"lint": "standardx --fix src/*.ts test/*.js",
"lint:example": "standardx --fix example/*.js",
"docs": "rimraf docs/ && typedoc --plugin typedoc-plugin-markdown --hideSources --theme markdown --hideGenerator --excludeExternals --excludePrivate --out docs index.ts",

@@ -19,0 +20,0 @@ "prepare": "npm run lint && npm run build"

@@ -173,3 +173,3 @@ <h3 align="center">

\+ **new MerkleTree**(`leaves`: any[], `hashAlgorithm`: any, `options`: [Options](#options)): *[MerkleTree](_index_.merkletree.md)*
\+ **new MerkleTree**(`leaves`: any[], `hashFn`: any, `options`: [Options](#options)): *[MerkleTree](_index_.merkletree.md)*

@@ -200,3 +200,3 @@ **`desc`** Constructs a Merkle Tree.

`leaves` | any[] | - | Array of hashed leaves. Each leaf must be a Buffer. |
`hashAlgorithm` | any | SHA256 | Algorithm used for hashing leaves and nodes |
`hashFn` | any | SHA256 | Hash function to use for hashing leaves and nodes |
`options` | [Options](#options) | {} | Additional options |

@@ -978,3 +978,3 @@

If set to `true`, the leaves will hashed using the set hashing algorithms.
If set to `true`, the leaves will hashed using the set hashing functions.

@@ -1031,3 +1031,3 @@ ___

As is, this implemenation is vulnerable to a [second pre-image attack](https://en.wikipedia.org/wiki/Merkle_tree#Second_preimage_attack). Use a difference hashing algorithm function for leaves and nodes, so that `H(x) != H'(x)`.
As is, this implemenation is vulnerable to a [second pre-image attack](https://en.wikipedia.org/wiki/Merkle_tree#Second_preimage_attack). Use a difference hashing function for leaves and nodes, so that `H(x) != H'(x)`.

@@ -1034,0 +1034,0 @@ Also, as is, this implementation is vulnerable to a forgery attack for an unbalanced tree, where the last leaf node can be duplicated to create an artificial balanced tree, resulting in the same Merkle root hash. Do not accept unbalanced tree to prevent this.

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc