update to include new version of bn.js and elliptic that include hex padding

This commit is contained in:
Braydon Fuller 2014-11-03 16:53:14 -05:00
parent 4a710e8fa6
commit 8ca49fb523
3 changed files with 21 additions and 27 deletions

View File

@ -41,8 +41,6 @@ BN.fromBuffer = function(buf, opts) {
buf = nbuf; buf = nbuf;
} }
var hex = buf.toString('hex'); var hex = buf.toString('hex');
if (hex.length % 2)
hex = "0" + hex;
var bn = new BN(hex, 16); var bn = new BN(hex, 16);
return bn; return bn;
}; };
@ -57,9 +55,7 @@ BN.prototype.fromBuffer = function(buf, opts) {
BN.prototype.toBuffer = function(opts) { BN.prototype.toBuffer = function(opts) {
var buf; var buf;
if (opts && opts.size) { if (opts && opts.size) {
var hex = this.toString(16); var hex = this.toString(16, 2);
if (hex.length % 2)
hex = "0" + hex;
var natlen = hex.length/2; var natlen = hex.length/2;
buf = new Buffer(hex, 'hex'); buf = new Buffer(hex, 'hex');
@ -81,9 +77,7 @@ BN.prototype.toBuffer = function(opts) {
} }
} }
else { else {
var hex = this.toString(16); var hex = this.toString(16, 2);
if (hex.length % 2)
hex = "0" + hex;
buf = new Buffer(hex, 'hex'); buf = new Buffer(hex, 'hex');
} }

30
npm-shrinkwrap.json generated
View File

@ -8,9 +8,9 @@
"resolved": "https://registry.npmjs.org/aes/-/aes-0.1.0.tgz" "resolved": "https://registry.npmjs.org/aes/-/aes-0.1.0.tgz"
}, },
"bn.js": { "bn.js": {
"version": "0.14.0", "version": "0.15.0",
"from": "bn.js@0.14.0", "from": "bn.js@0.15.0",
"resolved": "https://registry.npmjs.org/bn.js/-/bn.js-0.14.0.tgz" "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-0.15.0.tgz"
}, },
"bs58": { "bs58": {
"version": "1.2.1", "version": "1.2.1",
@ -18,19 +18,19 @@
"resolved": "https://registry.npmjs.org/bs58/-/bs58-1.2.1.tgz" "resolved": "https://registry.npmjs.org/bs58/-/bs58-1.2.1.tgz"
}, },
"elliptic": { "elliptic": {
"version": "0.15.10", "version": "0.15.12",
"from": "elliptic@0.15.10", "from": "elliptic@0.15.12",
"resolved": "https://registry.npmjs.org/elliptic/-/elliptic-0.15.10.tgz", "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-0.15.12.tgz",
"dependencies": { "dependencies": {
"bn.js": { "bn.js": {
"version": "0.11.7", "version": "0.15.0",
"from": "bn.js@0.11.7", "from": "bn.js@0.15.0",
"resolved": "https://registry.npmjs.org/bn.js/-/bn.js-0.11.7.tgz" "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-0.15.0.tgz"
}, },
"hash.js": { "hash.js": {
"version": "0.2.1", "version": "0.3.2",
"from": "hash.js@0.2.1", "from": "hash.js@0.3.2",
"resolved": "https://registry.npmjs.org/hash.js/-/hash.js-0.2.1.tgz" "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-0.3.2.tgz"
}, },
"inherits": { "inherits": {
"version": "2.0.1", "version": "2.0.1",
@ -39,9 +39,9 @@
} }
}, },
"hash.js": { "hash.js": {
"version": "0.3.1", "version": "0.3.2",
"from": "hash.js@0.3.1", "from": "hash.js@0.3.2",
"resolved": "https://registry.npmjs.org/hash.js/-/hash.js-0.3.1.tgz", "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-0.3.2.tgz",
"dependencies": { "dependencies": {
"inherits": { "inherits": {
"version": "2.0.1", "version": "2.0.1",

View File

@ -5,7 +5,7 @@
"author": "BitPay <dev@bitpay.com>", "author": "BitPay <dev@bitpay.com>",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"test": "mocha", "test": "mocha --reporter spec",
"coverage": "istanbul cover _mocha" "coverage": "istanbul cover _mocha"
}, },
"contributors": [ "contributors": [
@ -65,10 +65,10 @@
}, },
"dependencies": { "dependencies": {
"aes": "=0.1.0", "aes": "=0.1.0",
"bn.js": "=0.14.0", "bn.js": "=0.15.0",
"bs58": "=1.2.1", "bs58": "=1.2.1",
"elliptic": "=0.15.10", "elliptic": "=0.15.12",
"hash.js": "=0.3.1", "hash.js": "=0.3.2",
"sha512": "=0.0.1" "sha512": "=0.0.1"
}, },
"devDependencies": { "devDependencies": {