replace jsbn's rng with module secure-random

This uses window.crypto.getRandomValues on browser
and crypto.randomBytes on node
This commit is contained in:
Wei Lu 2014-03-20 17:18:45 +08:00
parent ff625968ce
commit b7861e4336
8 changed files with 18 additions and 141 deletions

View file

@ -7,8 +7,7 @@ var Transaction = require('./transaction').Transaction;
var TransactionIn = require('./transaction').TransactionIn;
var TransactionOut = require('./transaction').TransactionOut;
var HDNode = require('./hdwallet.js')
var SecureRandom = require('./jsbn/rng');
var rng = new SecureRandom();
var rng = require('secure-random');
var Wallet = function (seed, options) {
if (!(this instanceof Wallet)) { return new Wallet(seed, options); }
@ -32,10 +31,7 @@ var Wallet = function (seed, options) {
// Make a new master key
this.newMasterKey = function(seed, network) {
if (!seed) {
var seed= new Array(32);
rng.nextBytes(seed);
}
if (!seed) seed= rng(32, { array: true })
masterkey = new HDNode(seed, network);
// HD first-level child derivation method should be private