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.7 to 0.0.8

15

index.js
const reverse = require('buffer-reverse')
const CryptoJS = require('crypto-js')

@@ -32,3 +33,3 @@ /**

constructor(leaves, hashAlgorithm, options={}) {
this.hashAlgo = hashAlgorithm
this.hashAlgo = bufferify(hashAlgorithm)
this.leaves = leaves

@@ -255,2 +256,14 @@ this.layers = [leaves]

function bufferify (f) {
return function (x) {
const v = f(x)
if (Buffer.isBuffer(v)) {
return v
}
// crypto-js support
return Buffer.from(f(CryptoJS.enc.Hex.parse(x.toString('hex'))).toString(CryptoJS.enc.Hex), 'hex')
}
}
module.exports = MerkleTree

6

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

@@ -39,2 +39,3 @@ "main": "index.js",

"crypto": "0.0.3",
"crypto-js": "^3.1.9-1",
"ethereumjs-util": "^5.1.2",

@@ -48,4 +49,5 @@ "jsdoc-to-markdown": "^3.0.0",

"dependencies": {
"buffer-reverse": "^1.0.1"
"buffer-reverse": "^1.0.1",
"is-buffer": "^2.0.3"
}
}
const test = require('tape')
const {sha3} = require('ethereumjs-util')
const crypto = require('crypto')
const SHA256 = require('crypto-js/sha256')

@@ -22,2 +23,13 @@ const MerkleTree = require('../')

test('crypto-js - sha256', t => {
t.plan(1)
const leaves = ['a', 'b', 'c'].map(x => sha3(x))
const tree = new MerkleTree(leaves, SHA256)
const root = '311d2e46f49b15fff8b746b74ad57f2cc9e0d9939fda94387141a2d3fdf187ae'
t.equal(tree.getRoot().toString('hex'), root)
})
test('solidity sha3 [keccak-256]', t => {

@@ -24,0 +36,0 @@ t.plan(20)

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