package: use crypto-browserify 3.0.0

This commit is contained in:
Daniel Cousens 2014-07-28 13:46:34 +10:00
parent ca0c56fa3b
commit 8e0c835919
4 changed files with 11 additions and 11 deletions

View file

@ -75,6 +75,7 @@
"bigi": "1.1.0", "bigi": "1.1.0",
"bs58": "1.1.0", "bs58": "1.1.0",
"bs58check": "1.0.0", "bs58check": "1.0.0",
"crypto-browserify": "3.0.0",
"crypto-js": "3.1.2-3", "crypto-js": "3.1.2-3",
"crypto-browserify": "2.1.8", "crypto-browserify": "2.1.8",
"ecurve": "0.10.0", "ecurve": "0.10.0",

View file

@ -1,8 +1,8 @@
var assert = require('assert') var assert = require('assert')
var base58check = require('bs58check') var base58check = require('bs58check')
var crypto = require('crypto')
var ecdsa = require('./ecdsa') var ecdsa = require('./ecdsa')
var networks = require('./networks') var networks = require('./networks')
var secureRandom = require('secure-random')
var BigInteger = require('bigi') var BigInteger = require('bigi')
var ECPubKey = require('./ecpubkey') var ECPubKey = require('./ecpubkey')
@ -43,7 +43,7 @@ ECKey.fromWIF = function(string) {
} }
ECKey.makeRandom = function(compressed, rng) { ECKey.makeRandom = function(compressed, rng) {
rng = rng || secureRandom.randomBuffer rng = rng || crypto.randomBytes
var buffer = rng(32) var buffer = rng(32)
assert(Buffer.isBuffer(buffer), 'Expected Buffer, got ' + buffer) assert(Buffer.isBuffer(buffer), 'Expected Buffer, got ' + buffer)

View file

@ -1,6 +1,6 @@
var assert = require('assert') var assert = require('assert')
var crypto = require('crypto')
var networks = require('./networks') var networks = require('./networks')
var rng = require('secure-random')
var Address = require('./address') var Address = require('./address')
var HDNode = require('./hdnode') var HDNode = require('./hdnode')
@ -25,7 +25,7 @@ function Wallet(seed, network) {
// Make a new master key // Make a new master key
this.newMasterKey = function(seed) { this.newMasterKey = function(seed) {
seed = seed || new Buffer(rng(32)) seed = seed || crypto.randomBytes(32)
masterkey = HDNode.fromSeedBuffer(seed, network) masterkey = HDNode.fromSeedBuffer(seed, network)
// HD first-level child derivation method should be hardened // HD first-level child derivation method should be hardened

View file

@ -1,8 +1,7 @@
var assert = require('assert') var assert = require('assert')
var crypto = require('../src/crypto') var crypto = require('crypto')
var crypto2 = require('../src/crypto')
var networks = require('../src/networks') var networks = require('../src/networks')
var secureRandom = require('secure-random')
var sinon = require('sinon') var sinon = require('sinon')
var BigInteger = require('bigi') var BigInteger = require('bigi')
@ -84,13 +83,13 @@ describe('ECKey', function() {
var exPrivKey = ECKey.fromWIF(exWIF) var exPrivKey = ECKey.fromWIF(exWIF)
var exBuffer = exPrivKey.d.toBuffer(32) var exBuffer = exPrivKey.d.toBuffer(32)
describe('using default RNG', function() { describe('uses default crypto RNG', function() {
beforeEach(function() { beforeEach(function() {
sinon.stub(secureRandom, 'randomBuffer').returns(exBuffer) sinon.stub(crypto, 'randomBytes').returns(exBuffer)
}) })
afterEach(function() { afterEach(function() {
secureRandom.randomBuffer.restore() crypto.randomBytes.restore()
}) })
it('generates a ECKey', function() { it('generates a ECKey', function() {
@ -116,7 +115,7 @@ describe('ECKey', function() {
}) })
describe('signing', function() { describe('signing', function() {
var hash = crypto.sha256('Vires in numeris') var hash = crypto2.sha256('Vires in numeris')
var priv = ECKey.makeRandom() var priv = ECKey.makeRandom()
var signature = priv.sign(hash) var signature = priv.sign(hash)