From 07a02ec86b447d0c9a87ddaeafa87487da063fb4 Mon Sep 17 00:00:00 2001 From: Braydon Fuller Date: Fri, 14 Aug 2015 10:54:16 -0400 Subject: [PATCH 1/3] Fix issue with crypto library browser ripemd160 support. --- lib/crypto/hash.js | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/lib/crypto/hash.js b/lib/crypto/hash.js index 730a798..4a88cc7 100644 --- a/lib/crypto/hash.js +++ b/lib/crypto/hash.js @@ -1,6 +1,5 @@ 'use strict'; -var hashjs = require('hash.js'); var sha512 = require('sha512'); var crypto = require('crypto'); var BufferUtil = require('../util/buffer'); @@ -29,19 +28,9 @@ Hash.sha256sha256 = function(buf) { Hash.ripemd160 = function(buf) { $.checkArgument(BufferUtil.isBuffer(buf)); - return crypto.createHash('ripemd160').update(buf).digest(); + return crypto.createHash('rmd160').update(buf).digest(); }; -// Node.js crypto ripemd160 hashes are not supported in a browser -// We'll replace with a (slower) version that does. -if (process.browser) { - Hash.ripemd160 = function(buf) { - $.checkArgument(BufferUtil.isBuffer(buf)); - var hash = (new hashjs.ripemd160()).update(buf).digest(); - return new Buffer(hash); - }; -} - Hash.sha256ripemd160 = function(buf) { $.checkArgument(BufferUtil.isBuffer(buf)); return Hash.ripemd160(Hash.sha256(buf)); From 41a4e6e19f8bfd8387fddab2428230f1d39d06f7 Mon Sep 17 00:00:00 2001 From: Braydon Fuller Date: Tue, 13 Oct 2015 19:53:08 -0400 Subject: [PATCH 2/3] Update for crypto-browserify. --- lib/crypto/hash.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/crypto/hash.js b/lib/crypto/hash.js index 4a88cc7..2b098b7 100644 --- a/lib/crypto/hash.js +++ b/lib/crypto/hash.js @@ -28,7 +28,7 @@ Hash.sha256sha256 = function(buf) { Hash.ripemd160 = function(buf) { $.checkArgument(BufferUtil.isBuffer(buf)); - return crypto.createHash('rmd160').update(buf).digest(); + return crypto.createHash('ripemd160').update(buf).digest(); }; Hash.sha256ripemd160 = function(buf) { From 59d2d5cf00f38ae03298a2460668d778dce27089 Mon Sep 17 00:00:00 2001 From: Braydon Fuller Date: Tue, 13 Oct 2015 20:51:04 -0400 Subject: [PATCH 3/3] Hash.js dependency is only needed by elliptic. --- npm-shrinkwrap.json | 10 +++++----- package.json | 1 - 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index a94fb99..ed38afe 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -26,14 +26,14 @@ "version": "1.0.5", "from": "brorand@^1.0.1", "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.0.5.tgz" + }, + "hash.js": { + "version": "1.0.3", + "from": "hash.js@=1.0.3", + "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.0.3.tgz" } } }, - "hash.js": { - "version": "1.0.2", - "from": "hash.js@^1.0.0", - "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.0.2.tgz" - }, "inherits": { "version": "2.0.1", "from": "inherits@=2.0.1", diff --git a/package.json b/package.json index 3203460..3dd0edd 100644 --- a/package.json +++ b/package.json @@ -84,7 +84,6 @@ "bs58": "=2.0.0", "buffer-compare": "=1.0.0", "elliptic": "=3.0.3", - "hash.js": "=1.0.2", "inherits": "=2.0.1", "lodash": "=3.10.1", "sha512": "=0.0.1"