From 8e0c835919b4e00de2aa721d9806d32a08e97cee Mon Sep 17 00:00:00 2001 From: Daniel Cousens Date: Mon, 28 Jul 2014 13:46:34 +1000 Subject: [PATCH 1/3] package: use crypto-browserify 3.0.0 --- package.json | 1 + src/eckey.js | 4 ++-- src/wallet.js | 4 ++-- test/eckey.js | 13 ++++++------- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index cc07c9f..765495d 100644 --- a/package.json +++ b/package.json @@ -75,6 +75,7 @@ "bigi": "1.1.0", "bs58": "1.1.0", "bs58check": "1.0.0", + "crypto-browserify": "3.0.0", "crypto-js": "3.1.2-3", "crypto-browserify": "2.1.8", "ecurve": "0.10.0", diff --git a/src/eckey.js b/src/eckey.js index 87a9367..a3073ec 100644 --- a/src/eckey.js +++ b/src/eckey.js @@ -1,8 +1,8 @@ var assert = require('assert') var base58check = require('bs58check') +var crypto = require('crypto') var ecdsa = require('./ecdsa') var networks = require('./networks') -var secureRandom = require('secure-random') var BigInteger = require('bigi') var ECPubKey = require('./ecpubkey') @@ -43,7 +43,7 @@ ECKey.fromWIF = function(string) { } ECKey.makeRandom = function(compressed, rng) { - rng = rng || secureRandom.randomBuffer + rng = rng || crypto.randomBytes var buffer = rng(32) assert(Buffer.isBuffer(buffer), 'Expected Buffer, got ' + buffer) diff --git a/src/wallet.js b/src/wallet.js index da14080..c056c95 100644 --- a/src/wallet.js +++ b/src/wallet.js @@ -1,6 +1,6 @@ var assert = require('assert') +var crypto = require('crypto') var networks = require('./networks') -var rng = require('secure-random') var Address = require('./address') var HDNode = require('./hdnode') @@ -25,7 +25,7 @@ function Wallet(seed, network) { // Make a new master key this.newMasterKey = function(seed) { - seed = seed || new Buffer(rng(32)) + seed = seed || crypto.randomBytes(32) masterkey = HDNode.fromSeedBuffer(seed, network) // HD first-level child derivation method should be hardened diff --git a/test/eckey.js b/test/eckey.js index 7694a1b..a5ce620 100644 --- a/test/eckey.js +++ b/test/eckey.js @@ -1,8 +1,7 @@ var assert = require('assert') -var crypto = require('../src/crypto') +var crypto = require('crypto') +var crypto2 = require('../src/crypto') var networks = require('../src/networks') - -var secureRandom = require('secure-random') var sinon = require('sinon') var BigInteger = require('bigi') @@ -84,13 +83,13 @@ describe('ECKey', function() { var exPrivKey = ECKey.fromWIF(exWIF) var exBuffer = exPrivKey.d.toBuffer(32) - describe('using default RNG', function() { + describe('uses default crypto RNG', function() { beforeEach(function() { - sinon.stub(secureRandom, 'randomBuffer').returns(exBuffer) + sinon.stub(crypto, 'randomBytes').returns(exBuffer) }) afterEach(function() { - secureRandom.randomBuffer.restore() + crypto.randomBytes.restore() }) it('generates a ECKey', function() { @@ -116,7 +115,7 @@ describe('ECKey', function() { }) describe('signing', function() { - var hash = crypto.sha256('Vires in numeris') + var hash = crypto2.sha256('Vires in numeris') var priv = ECKey.makeRandom() var signature = priv.sign(hash) From 75b51995e5299ac1f5fb7e9b159055cf1ece9cb9 Mon Sep 17 00:00:00 2001 From: Daniel Cousens Date: Fri, 25 Jul 2014 11:20:23 +1000 Subject: [PATCH 2/3] package: use bs58 1.2.1 --- package.json | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 765495d..3947bbd 100644 --- a/package.json +++ b/package.json @@ -73,12 +73,10 @@ }, "dependencies": { "bigi": "1.1.0", - "bs58": "1.1.0", - "bs58check": "1.0.0", - "crypto-browserify": "3.0.0", + "bs58": "1.2.1", + "bs58check": "1.0.1", "crypto-js": "3.1.2-3", - "crypto-browserify": "2.1.8", - "ecurve": "0.10.0", - "secure-random": "1.1.1" + "crypto-browserify": "3.0.0", + "ecurve": "0.10.0" } } From a8d1a525e5230683762c51054191580189cdf1bd Mon Sep 17 00:00:00 2001 From: Daniel Cousens Date: Mon, 28 Jul 2014 13:48:00 +1000 Subject: [PATCH 3/3] package: use ecurve 1.0.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3947bbd..4b3bbe8 100644 --- a/package.json +++ b/package.json @@ -77,6 +77,6 @@ "bs58check": "1.0.1", "crypto-js": "3.1.2-3", "crypto-browserify": "3.0.0", - "ecurve": "0.10.0" + "ecurve": "1.0.0" } }