|
@ -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'); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|