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.0.14 to 0.0.15

5

index.js

@@ -42,5 +42,4 @@ const reverse = require('buffer-reverse')

createHashes(nodes) {
while (nodes.length > 1) {
while (nodes.length !== 1) {
const layerIndex = this.layers.length

@@ -122,3 +121,3 @@

getRoot() {
return this.layers[this.layers.length-1][0]
return this.layers[this.layers.length-1][0] || Buffer.from([])
}

@@ -125,0 +124,0 @@

2

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

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -225,1 +225,27 @@ const test = require('tape')

})
test('sha256 - no leaves', t => {
t.plan(1)
const leaves = []
const tree = new MerkleTree(leaves, sha256)
const root = ''
t.equal(tree.getRoot().toString('hex'), root)
})
test('sha256 - 1,000,000 leaves', t => {
t.plan(1)
let values = []
for (let i = 0; i < 1e6; i++) {
values.push(`${i}`)
}
const leaves = values.map(x => sha256(x))
const tree = new MerkleTree(leaves, sha256)
const root = '101dd357df60384d254330fe118e3046871767c2748ebd62ce031c117df483da'
t.equal(tree.getRoot().toString('hex'), root)
})
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