From 0eeba8eadb84fa8a035b423269b57cbb536b8b3c Mon Sep 17 00:00:00 2001 From: "Ryan X. Charles" Date: Wed, 17 Sep 2014 15:22:52 -0700 Subject: [PATCH] canonical BN notation --- lib/bip32.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/bip32.js b/lib/bip32.js index 621f65f25..2ee5d6e4a 100644 --- a/lib/bip32.js +++ b/lib/bip32.js @@ -5,7 +5,7 @@ var Pubkey = require('./pubkey'); var Privkey = require('./privkey'); var Point = require('./point'); var Random = require('./random'); -var bn = require('./bn'); +var BN = require('./bn'); var constants = require('./constants'); var BIP32 = function BIP32(obj) { @@ -72,7 +72,7 @@ BIP32.prototype.fromSeed = function(bytes, networkstr) { this.chaincode = hash.slice(32, 64); this.version = constants[networkstr].bip32privkey; this.keypair = new Keypair(); - this.keypair.privkey = new Privkey({bn: bn.fromBuffer(hash.slice(0, 32))}); + this.keypair.privkey = new Privkey({bn: BN().fromBuffer(hash.slice(0, 32))}); this.keypair.privkey2pubkey(); this.hasprivkey = true; this.pubkeyhash = Hash.sha256ripemd160(this.keypair.pubkey.toBuffer()); @@ -106,7 +106,7 @@ BIP32.prototype.initFromBytes = function(bytes) { if (isPrivate && keyBytes[0] == 0) { this.keypair = new Keypair(); - this.keypair.privkey = new Privkey({bn: bn.fromBuffer(keyBytes.slice(1, 33))}); + this.keypair.privkey = new Privkey({bn: BN().fromBuffer(keyBytes.slice(1, 33))}); this.keypair.privkey2pubkey(); this.pubkeyhash = Hash.sha256ripemd160(this.keypair.pubkey.toBuffer()); this.hasprivkey = true; @@ -263,7 +263,7 @@ BIP32.prototype.deriveChild = function(i) { } var hash = Hash.sha512hmac(data, this.chaincode); - var il = bn.fromBuffer(hash.slice(0, 32), {size: 32}); + var il = BN().fromBuffer(hash.slice(0, 32), {size: 32}); var ir = hash.slice(32, 64); // ki = IL + kpar (mod n). @@ -280,7 +280,7 @@ BIP32.prototype.deriveChild = function(i) { } else { var data = Buffer.concat([this.keypair.pubkey.toBuffer(), ib]); var hash = Hash.sha512hmac(data, this.chaincode); - var il = bn(hash.slice(0, 32)); + var il = BN().fromBuffer(hash.slice(0, 32)); var ir = hash.slice(32, 64); // Ki = (IL + kpar)*G = IL*G + Kpar