diff --git a/lib/crypto/bn.js b/lib/crypto/bn.js index a1d381c81..20b53f86d 100644 --- a/lib/crypto/bn.js +++ b/lib/crypto/bn.js @@ -21,9 +21,9 @@ BN.fromNumber = function(n) { return new BN(n); }; -BN.fromString = function(str) { +BN.fromString = function(str, base) { $.checkArgument(_.isString(str)); - return new BN(str); + return new BN(str, base); }; BN.fromBuffer = function(buf, opts) { diff --git a/test/crypto/bn.js b/test/crypto/bn.js index 45d6272e8..085b40c81 100644 --- a/test/crypto/bn.js +++ b/test/crypto/bn.js @@ -79,9 +79,9 @@ describe('BN', function() { it('should make BN from a string', function() { BN.fromString('5').toString().should.equal('5'); }); - it('should work with 7fffff0000000000000000000000000000000000000000000000000000000000', function() { - BN.fromString('7fffff0000000000000000000000000000000000000000000000000000000000') - .toString().should.equal('7fffff0000000000000000000000000000000000000000000000000000000000'); + it('should work with hex string', function() { + BN.fromString('7fffff0000000000000000000000000000000000000000000000000000000000', 16) + .toString(16).should.equal('7fffff0000000000000000000000000000000000000000000000000000000000'); }); });