Browse Source

Add the new operator when BN was used without it

patch-2
Esteban Ordano 10 years ago
parent
commit
6b05f20397
  1. 2
      lib/blockheader.js
  2. 4
      lib/crypto/bn.js
  3. 6
      lib/crypto/point.js
  4. 6
      lib/encoding/bufferreader.js
  5. 4
      lib/privatekey.js
  6. 12
      lib/publickey.js
  7. 30
      lib/script/interpreter.js
  8. 2
      lib/transaction/transaction.js
  9. 4
      test/block.js
  10. 4
      test/blockheader.js
  11. 2
      test/crypto/bn.js
  12. 22
      test/crypto/ecdsa.js
  13. 18
      test/crypto/signature.js
  14. 2
      test/privatekey.js

2
lib/blockheader.js

@ -195,7 +195,7 @@ BlockHeader.prototype.toBufferWriter = function toBufferWriter(bw) {
* @returns {BN} - An instance of BN with the decoded difficulty bits * @returns {BN} - An instance of BN with the decoded difficulty bits
*/ */
BlockHeader.prototype.getTargetDifficulty = function getTargetDifficulty(info) { BlockHeader.prototype.getTargetDifficulty = function getTargetDifficulty(info) {
var target = BN(this.bits & 0xffffff); var target = new BN(this.bits & 0xffffff);
var mov = 8 * ((this.bits >>> 24) - 3); var mov = 8 * ((this.bits >>> 24) - 3);
while (mov-- > 0) { while (mov-- > 0) {
target = target.mul(2); target = target.mul(2);

4
lib/crypto/bn.js

@ -14,12 +14,12 @@ var reversebuf = function(buf) {
BN.fromNumber = function(n) { BN.fromNumber = function(n) {
$.checkArgument(_.isNumber(n)); $.checkArgument(_.isNumber(n));
return BN(n); return new BN(n);
}; };
BN.fromString = function(str) { BN.fromString = function(str) {
$.checkArgument(_.isString(str)); $.checkArgument(_.isString(str));
return BN(str); return new BN(str);
}; };
BN.fromBuffer = function(buf, opts) { BN.fromBuffer = function(buf, opts) {

6
lib/crypto/point.js

@ -60,7 +60,7 @@ Point.getG = function getG() {
* @returns {BN} A BN instance of the number of points on the curve * @returns {BN} A BN instance of the number of points on the curve
*/ */
Point.getN = function getN() { Point.getN = function getN() {
return BN(ec.curve.n.toArray()); return new BN(ec.curve.n.toArray());
}; };
Point.prototype._getX = Point.prototype.getX; Point.prototype._getX = Point.prototype.getX;
@ -72,7 +72,7 @@ Point.prototype._getX = Point.prototype.getX;
* @returns {BN} A BN instance of the X coordinate * @returns {BN} A BN instance of the X coordinate
*/ */
Point.prototype.getX = function getX() { Point.prototype.getX = function getX() {
return BN(this._getX().toArray()); return new BN(this._getX().toArray());
}; };
Point.prototype._getY = Point.prototype.getY; Point.prototype._getY = Point.prototype.getY;
@ -84,7 +84,7 @@ Point.prototype._getY = Point.prototype.getY;
* @returns {BN} A BN instance of the Y coordinate * @returns {BN} A BN instance of the Y coordinate
*/ */
Point.prototype.getY = function getY() { Point.prototype.getY = function getY() {
return BN(this._getY().toArray()); return new BN(this._getY().toArray());
}; };
/** /**

6
lib/encoding/bufferreader.js

@ -141,13 +141,13 @@ BufferReader.prototype.readVarintBN = function() {
var first = this.readUInt8(); var first = this.readUInt8();
switch (first) { switch (first) {
case 0xFD: case 0xFD:
return BN(this.readUInt16LE()); return new BN(this.readUInt16LE());
case 0xFE: case 0xFE:
return BN(this.readUInt32LE()); return new BN(this.readUInt32LE());
case 0xFF: case 0xFF:
return this.readUInt64LEBN(); return this.readUInt64LEBN();
default: default:
return BN(first); return new BN(first);
} }
}; };

4
lib/privatekey.js

@ -102,7 +102,7 @@ PrivateKey.prototype._classifyArguments = function(data, network) {
info.network = Networks.get(data); info.network = Networks.get(data);
} else if (typeof(data) === 'string'){ } else if (typeof(data) === 'string'){
if (JSUtil.isHexa(data)) { if (JSUtil.isHexa(data)) {
info.bn = BN(new Buffer(data, 'hex')); info.bn = new BN(new Buffer(data, 'hex'));
} else { } else {
info = PrivateKey._transformWIF(data, network); info = PrivateKey._transformWIF(data, network);
} }
@ -216,7 +216,7 @@ PrivateKey._transformJSON = function(json) {
if (JSUtil.isValidJSON(json)) { if (JSUtil.isValidJSON(json)) {
json = JSON.parse(json); json = JSON.parse(json);
} }
var bn = BN(json.bn, 'hex'); var bn = new BN(json.bn, 'hex');
return { return {
bn: bn, bn: bn,
network: json.network, network: json.network,

12
lib/publickey.js

@ -169,18 +169,18 @@ PublicKey._transformDER = function(buf, strict) {
if (xbuf.length !== 32 || ybuf.length !== 32 || buf.length !== 65) { if (xbuf.length !== 32 || ybuf.length !== 32 || buf.length !== 65) {
throw new TypeError('Length of x and y must be 32 bytes'); throw new TypeError('Length of x and y must be 32 bytes');
} }
x = BN(xbuf); x = new BN(xbuf);
y = BN(ybuf); y = new BN(ybuf);
info.point = new Point(x, y); info.point = new Point(x, y);
info.compressed = false; info.compressed = false;
} else if (buf[0] === 0x03) { } else if (buf[0] === 0x03) {
xbuf = buf.slice(1); xbuf = buf.slice(1);
x = BN(xbuf); x = new BN(xbuf);
info = PublicKey._transformX(true, x); info = PublicKey._transformX(true, x);
info.compressed = true; info.compressed = true;
} else if (buf[0] === 0x02) { } else if (buf[0] === 0x02) {
xbuf = buf.slice(1); xbuf = buf.slice(1);
x = BN(xbuf); x = new BN(xbuf);
info = PublicKey._transformX(false, x); info = PublicKey._transformX(false, x);
info.compressed = true; info.compressed = true;
} else { } else {
@ -228,8 +228,8 @@ PublicKey._transformJSON = function(json) {
if (JSUtil.isValidJSON(json)) { if (JSUtil.isValidJSON(json)) {
json = JSON.parse(json); json = JSON.parse(json);
} }
var x = BN(json.x, 'hex'); var x = new BN(json.x, 'hex');
var y = BN(json.y, 'hex'); var y = new BN(json.y, 'hex');
var point = new Point(x, y); var point = new Point(x, y);
return new PublicKey(point, { return new PublicKey(point, {
compressed: json.compressed compressed: json.compressed

30
lib/script/interpreter.js

@ -400,7 +400,7 @@ Interpreter.prototype.step = function() {
// ( -- value) // ( -- value)
// ScriptNum bn((int)opcode - (int)(Opcode.OP_1 - 1)); // ScriptNum bn((int)opcode - (int)(Opcode.OP_1 - 1));
n = opcodenum - (Opcode.OP_1 - 1); n = opcodenum - (Opcode.OP_1 - 1);
buf = BN(n).toScriptNumBuffer(); buf = new BN(n).toScriptNumBuffer();
this.stack.push(buf); this.stack.push(buf);
// The result of these opcodes should always be the minimal way to push the data // The result of these opcodes should always be the minimal way to push the data
// they push, so no need for a CheckMinimalPush here. // they push, so no need for a CheckMinimalPush here.
@ -623,7 +623,7 @@ Interpreter.prototype.step = function() {
case Opcode.OP_DEPTH: case Opcode.OP_DEPTH:
{ {
// -- stacksize // -- stacksize
buf = BN(this.stack.length).toScriptNumBuffer(); buf = new BN(this.stack.length).toScriptNumBuffer();
this.stack.push(buf); this.stack.push(buf);
} }
break; break;
@ -748,7 +748,7 @@ Interpreter.prototype.step = function() {
this.errstr = 'SCRIPT_ERR_INVALID_STACK_OPERATION'; this.errstr = 'SCRIPT_ERR_INVALID_STACK_OPERATION';
return false; return false;
} }
bn = BN(this.stack[this.stack.length - 1].length); bn = new BN(this.stack[this.stack.length - 1].length);
this.stack.push(bn.toScriptNumBuffer()); this.stack.push(bn.toScriptNumBuffer());
} }
break; break;
@ -817,10 +817,10 @@ Interpreter.prototype.step = function() {
} }
break; break;
case Opcode.OP_NOT: case Opcode.OP_NOT:
bn = BN((bn.cmp(0) === 0) + 0); bn = new BN((bn.cmp(0) === 0) + 0);
break; break;
case Opcode.OP_0NOTEQUAL: case Opcode.OP_0NOTEQUAL:
bn = BN((bn.cmp(0) !== 0) + 0); bn = new BN((bn.cmp(0) !== 0) + 0);
break; break;
//default: assert(!'invalid opcode'); break; // TODO: does this ever occur? //default: assert(!'invalid opcode'); break; // TODO: does this ever occur?
} }
@ -850,7 +850,7 @@ Interpreter.prototype.step = function() {
} }
bn1 = BN.fromScriptNumBuffer(this.stack[this.stack.length - 2], fRequireMinimal); bn1 = BN.fromScriptNumBuffer(this.stack[this.stack.length - 2], fRequireMinimal);
bn2 = BN.fromScriptNumBuffer(this.stack[this.stack.length - 1], fRequireMinimal); bn2 = BN.fromScriptNumBuffer(this.stack[this.stack.length - 1], fRequireMinimal);
bn = BN(0); bn = new BN(0);
switch (opcodenum) { switch (opcodenum) {
case Opcode.OP_ADD: case Opcode.OP_ADD:
@ -863,39 +863,39 @@ Interpreter.prototype.step = function() {
// case Opcode.OP_BOOLAND: bn = (bn1 != bnZero && bn2 != bnZero); break; // case Opcode.OP_BOOLAND: bn = (bn1 != bnZero && bn2 != bnZero); break;
case Opcode.OP_BOOLAND: case Opcode.OP_BOOLAND:
bn = BN(((bn1.cmp(0) !== 0) && (bn2.cmp(0) !== 0)) + 0); bn = new BN(((bn1.cmp(0) !== 0) && (bn2.cmp(0) !== 0)) + 0);
break; break;
// case Opcode.OP_BOOLOR: bn = (bn1 != bnZero || bn2 != bnZero); break; // case Opcode.OP_BOOLOR: bn = (bn1 != bnZero || bn2 != bnZero); break;
case Opcode.OP_BOOLOR: case Opcode.OP_BOOLOR:
bn = BN(((bn1.cmp(0) !== 0) || (bn2.cmp(0) !== 0)) + 0); bn = new BN(((bn1.cmp(0) !== 0) || (bn2.cmp(0) !== 0)) + 0);
break; break;
// case Opcode.OP_NUMEQUAL: bn = (bn1 == bn2); break; // case Opcode.OP_NUMEQUAL: bn = (bn1 == bn2); break;
case Opcode.OP_NUMEQUAL: case Opcode.OP_NUMEQUAL:
bn = BN((bn1.cmp(bn2) === 0) + 0); bn = new BN((bn1.cmp(bn2) === 0) + 0);
break; break;
// case Opcode.OP_NUMEQUALVERIFY: bn = (bn1 == bn2); break; // case Opcode.OP_NUMEQUALVERIFY: bn = (bn1 == bn2); break;
case Opcode.OP_NUMEQUALVERIFY: case Opcode.OP_NUMEQUALVERIFY:
bn = BN((bn1.cmp(bn2) === 0) + 0); bn = new BN((bn1.cmp(bn2) === 0) + 0);
break; break;
// case Opcode.OP_NUMNOTEQUAL: bn = (bn1 != bn2); break; // case Opcode.OP_NUMNOTEQUAL: bn = (bn1 != bn2); break;
case Opcode.OP_NUMNOTEQUAL: case Opcode.OP_NUMNOTEQUAL:
bn = BN((bn1.cmp(bn2) !== 0) + 0); bn = new BN((bn1.cmp(bn2) !== 0) + 0);
break; break;
// case Opcode.OP_LESSTHAN: bn = (bn1 < bn2); break; // case Opcode.OP_LESSTHAN: bn = (bn1 < bn2); break;
case Opcode.OP_LESSTHAN: case Opcode.OP_LESSTHAN:
bn = BN((bn1.cmp(bn2) < 0) + 0); bn = new BN((bn1.cmp(bn2) < 0) + 0);
break; break;
// case Opcode.OP_GREATERTHAN: bn = (bn1 > bn2); break; // case Opcode.OP_GREATERTHAN: bn = (bn1 > bn2); break;
case Opcode.OP_GREATERTHAN: case Opcode.OP_GREATERTHAN:
bn = BN((bn1.cmp(bn2) > 0) + 0); bn = new BN((bn1.cmp(bn2) > 0) + 0);
break; break;
// case Opcode.OP_LESSTHANOREQUAL: bn = (bn1 <= bn2); break; // case Opcode.OP_LESSTHANOREQUAL: bn = (bn1 <= bn2); break;
case Opcode.OP_LESSTHANOREQUAL: case Opcode.OP_LESSTHANOREQUAL:
bn = BN((bn1.cmp(bn2) <= 0) + 0); bn = new BN((bn1.cmp(bn2) <= 0) + 0);
break; break;
// case Opcode.OP_GREATERTHANOREQUAL: bn = (bn1 >= bn2); break; // case Opcode.OP_GREATERTHANOREQUAL: bn = (bn1 >= bn2); break;
case Opcode.OP_GREATERTHANOREQUAL: case Opcode.OP_GREATERTHANOREQUAL:
bn = BN((bn1.cmp(bn2) >= 0) + 0); bn = new BN((bn1.cmp(bn2) >= 0) + 0);
break; break;
case Opcode.OP_MIN: case Opcode.OP_MIN:
bn = (bn1.cmp(bn2) < 0 ? bn1 : bn2); bn = (bn1.cmp(bn2) < 0 ? bn1 : bn2);

2
lib/transaction/transaction.js

@ -727,7 +727,7 @@ Transaction.prototype.verify = function() {
} }
// Check for negative or overflow output values // Check for negative or overflow output values
var valueoutbn = BN(0); var valueoutbn = new BN(0);
for (var i = 0; i < this.outputs.length; i++) { for (var i = 0; i < this.outputs.length; i++) {
var txout = this.outputs[i]; var txout = this.outputs[i];
var valuebn = txout._satoshisBN; var valuebn = txout._satoshisBN;

4
test/block.js

@ -69,13 +69,13 @@ describe('Block', function() {
it('should instantiate from a raw block binary', function() { it('should instantiate from a raw block binary', function() {
var x = Block.fromRawBlock(dataRawBlockBinary); var x = Block.fromRawBlock(dataRawBlockBinary);
x.header.version.should.equal(2); x.header.version.should.equal(2);
BN(x.header.bits).toString('hex').should.equal('1c3fffc0'); new BN(x.header.bits).toString('hex').should.equal('1c3fffc0');
}); });
it('should instantiate from raw block buffer', function() { it('should instantiate from raw block buffer', function() {
var x = Block.fromRawBlock(dataRawBlockBuffer); var x = Block.fromRawBlock(dataRawBlockBuffer);
x.header.version.should.equal(2); x.header.version.should.equal(2);
BN(x.header.bits).toString('hex').should.equal('1c3fffc0'); new BN(x.header.bits).toString('hex').should.equal('1c3fffc0');
}); });
}); });

4
test/blockheader.js

@ -185,13 +185,13 @@ describe('BlockHeader', function() {
it('should instantiate from a raw block binary', function() { it('should instantiate from a raw block binary', function() {
var x = BlockHeader.fromRawBlock(dataRawBlockBinary); var x = BlockHeader.fromRawBlock(dataRawBlockBinary);
x.version.should.equal(2); x.version.should.equal(2);
BN(x.bits).toString('hex').should.equal('1c3fffc0'); new BN(x.bits).toString('hex').should.equal('1c3fffc0');
}); });
it('should instantiate from raw block buffer', function() { it('should instantiate from raw block buffer', function() {
var x = BlockHeader.fromRawBlock(dataRawBlockBuffer); var x = BlockHeader.fromRawBlock(dataRawBlockBuffer);
x.version.should.equal(2); x.version.should.equal(2);
BN(x.bits).toString('hex').should.equal('1c3fffc0'); new BN(x.bits).toString('hex').should.equal('1c3fffc0');
}); });
}); });

2
test/crypto/bn.js

@ -83,7 +83,7 @@ describe('BN', function() {
describe('#toString', function() { describe('#toString', function() {
it('should make a string', function() { it('should make a string', function() {
BN(5).toString().should.equal('5'); new BN(5).toString().should.equal('5');
}); });
}); });

22
test/crypto/ecdsa.js

@ -42,8 +42,8 @@ describe('ECDSA', function() {
it('calulates this known i', function() { it('calulates this known i', function() {
var hashbuf = Hash.sha256(new Buffer('some data')); var hashbuf = Hash.sha256(new Buffer('some data'));
var r = BN('71706645040721865894779025947914615666559616020894583599959600180037551395766', 10); var r = new BN('71706645040721865894779025947914615666559616020894583599959600180037551395766', 10);
var s = BN('109412465507152403114191008482955798903072313614214706891149785278625167723646', 10); var s = new BN('109412465507152403114191008482955798903072313614214706891149785278625167723646', 10);
var ecdsa = new ECDSA({ var ecdsa = new ECDSA({
privkey: new Privkey(BN.fromBuffer(Hash.sha256(new Buffer('test')))), privkey: new Privkey(BN.fromBuffer(Hash.sha256(new Buffer('test')))),
hashbuf: hashbuf, hashbuf: hashbuf,
@ -83,7 +83,7 @@ describe('ECDSA', function() {
it('should generate a random k that is (almost always) greater than this relatively small number', function() { it('should generate a random k that is (almost always) greater than this relatively small number', function() {
ecdsa.randomK(); ecdsa.randomK();
var k1 = ecdsa.k; var k1 = ecdsa.k;
var k2 = BN(Math.pow(2, 32)).mul(BN(Math.pow(2, 32))).mul(BN(Math.pow(2, 32))); var k2 = new BN(Math.pow(2, 32)).mul(BN(Math.pow(2, 32))).mul(BN(Math.pow(2, 32)));
k2.gt(k1).should.equal(false); k2.gt(k1).should.equal(false);
}); });
@ -125,7 +125,7 @@ describe('ECDSA', function() {
describe('#toPublicKey', function() { describe('#toPublicKey', function() {
it('should calculate the correct public key', function() { it('should calculate the correct public key', function() {
ecdsa.k = BN('114860389168127852803919605627759231199925249596762615988727970217268189974335', 10); ecdsa.k = new BN('114860389168127852803919605627759231199925249596762615988727970217268189974335', 10);
ecdsa.sign(); ecdsa.sign();
ecdsa.sig.i = 0; ecdsa.sig.i = 0;
var pubkey = ecdsa.toPublicKey(); var pubkey = ecdsa.toPublicKey();
@ -133,7 +133,7 @@ describe('ECDSA', function() {
}); });
it('should calculate the correct public key for this signature with low s', function() { it('should calculate the correct public key for this signature with low s', function() {
ecdsa.k = BN('114860389168127852803919605627759231199925249596762615988727970217268189974335', 10); ecdsa.k = new BN('114860389168127852803919605627759231199925249596762615988727970217268189974335', 10);
ecdsa.sig = Signature.fromString('3045022100ec3cfe0e335791ad278b4ec8eac93d0347' + ecdsa.sig = Signature.fromString('3045022100ec3cfe0e335791ad278b4ec8eac93d0347' +
'a97877bb1d54d35d189e225c15f6650220278cf15b05ce47fb37d2233802899d94c774d5480bba9f0f2d996baa13370c43'); 'a97877bb1d54d35d189e225c15f6650220278cf15b05ce47fb37d2233802899d94c774d5480bba9f0f2d996baa13370c43');
ecdsa.sig.i = 0; ecdsa.sig.i = 0;
@ -142,7 +142,7 @@ describe('ECDSA', function() {
}); });
it('should calculate the correct public key for this signature with high s', function() { it('should calculate the correct public key for this signature with high s', function() {
ecdsa.k = BN('114860389168127852803919605627759231199925249596762615988727970217268189974335', 10); ecdsa.k = new BN('114860389168127852803919605627759231199925249596762615988727970217268189974335', 10);
ecdsa.sign(); ecdsa.sign();
ecdsa.sig = Signature.fromString('3046022100ec3cfe0e335791ad278b4ec8eac93d0347' + ecdsa.sig = Signature.fromString('3046022100ec3cfe0e335791ad278b4ec8eac93d0347' +
'a97877bb1d54d35d189e225c15f665022100d8730ea4fa31b804c82ddcc7fd766269f33a079ea38e012c9238f2e2bcff34fe'); 'a97877bb1d54d35d189e225c15f665022100d8730ea4fa31b804c82ddcc7fd766269f33a079ea38e012c9238f2e2bcff34fe');
@ -167,8 +167,8 @@ describe('ECDSA', function() {
'710fb053bb9f2b933173ff9a7baad41d04514751e6851f5304fd243751703bed21b914f6be218c0fa354a341', 'hex')); '710fb053bb9f2b933173ff9a7baad41d04514751e6851f5304fd243751703bed21b914f6be218c0fa354a341', 'hex'));
ecdsa.pubkey = pk; ecdsa.pubkey = pk;
ecdsa.sig = new Signature(); ecdsa.sig = new Signature();
ecdsa.sig.r = BN(0); ecdsa.sig.r = new BN(0);
ecdsa.sig.s = BN(0); ecdsa.sig.s = new BN(0);
ecdsa.sigError().should.equal('r and s not in range'); ecdsa.sigError().should.equal('r and s not in range');
}); });
@ -270,8 +270,8 @@ describe('ECDSA', function() {
k: BN.fromBuffer(new Buffer(obj.k, 'hex')), k: BN.fromBuffer(new Buffer(obj.k, 'hex')),
hashbuf: Hash.sha256(new Buffer(obj.message)), hashbuf: Hash.sha256(new Buffer(obj.message)),
sig: new Signature().set({ sig: new Signature().set({
r: BN(obj.signature.r), r: new BN(obj.signature.r),
s: BN(obj.signature.s), s: new BN(obj.signature.s),
i: obj.i i: obj.i
}) })
}); });
@ -290,7 +290,7 @@ describe('ECDSA', function() {
it('should validate invalid.sigError vector ' + i + ': ' + obj.description, function() { it('should validate invalid.sigError vector ' + i + ': ' + obj.description, function() {
var ecdsa = ECDSA().set({ var ecdsa = ECDSA().set({
pubkey: Pubkey.fromPoint(point.fromX(true, 1)), pubkey: Pubkey.fromPoint(point.fromX(true, 1)),
sig: new Signature(BN(obj.signature.r), BN(obj.signature.s)), sig: new Signature(BN(obj.signature.r), new BN(obj.signature.s)),
hashbuf: Hash.sha256(new Buffer(obj.message)) hashbuf: Hash.sha256(new Buffer(obj.message))
}); });
ecdsa.sigError().should.equal(obj.exception); ecdsa.sigError().should.equal(obj.exception);

18
test/crypto/signature.js

@ -18,8 +18,8 @@ describe('Signature', function() {
}); });
it('should work with conveniently setting r, s', function() { it('should work with conveniently setting r, s', function() {
var r = BN(); var r = new BN();
var s = BN(); var s = new BN();
var sig = new Signature(r, s); var sig = new Signature(r, s);
should.exist(sig); should.exist(sig);
sig.r.toString().should.equal(r.toString()); sig.r.toString().should.equal(r.toString());
@ -166,8 +166,8 @@ describe('Signature', function() {
describe('#toDER', function() { describe('#toDER', function() {
it('should convert these known r and s values into a known signature', function() { it('should convert these known r and s values into a known signature', function() {
var r = BN('63173831029936981022572627018246571655303050627048489594159321588908385378810'); var r = new BN('63173831029936981022572627018246571655303050627048489594159321588908385378810');
var s = BN('4331694221846364448463828256391194279133231453999942381442030409253074198130'); var s = new BN('4331694221846364448463828256391194279133231453999942381442030409253074198130');
var sig = new Signature({ var sig = new Signature({
r: r, r: r,
s: s s: s
@ -180,8 +180,8 @@ describe('Signature', function() {
describe('#toString', function() { describe('#toString', function() {
it('should convert this signature in to hex DER', function() { it('should convert this signature in to hex DER', function() {
var r = BN('63173831029936981022572627018246571655303050627048489594159321588908385378810'); var r = new BN('63173831029936981022572627018246571655303050627048489594159321588908385378810');
var s = BN('4331694221846364448463828256391194279133231453999942381442030409253074198130'); var s = new BN('4331694221846364448463828256391194279133231453999942381442030409253074198130');
var sig = new Signature({ var sig = new Signature({
r: r, r: r,
s: s s: s
@ -234,9 +234,9 @@ describe('Signature', function() {
}); });
describe('#hasLowS', function() { describe('#hasLowS', function() {
it('should detect high and low S', function() { it('should detect high and low S', function() {
var r = BN('63173831029936981022572627018246571655303050627048489594159321588908385378810'); var r = new BN('63173831029936981022572627018246571655303050627048489594159321588908385378810');
var s = BN('4331694221846364448463828256391194279133231453999942381442030409253074198130'); var s = new BN('4331694221846364448463828256391194279133231453999942381442030409253074198130');
var s2 = BN('7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B2000'); var s2 = new BN('7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B2000');
var sig = new Signature({ var sig = new Signature({
r: r, r: r,
s: s s: s

2
test/privatekey.js

@ -135,7 +135,7 @@ describe('PrivateKey', function() {
it('should not create a zero private key', function() { it('should not create a zero private key', function() {
expect(function() { expect(function() {
var bn = BN(0); var bn = new BN(0);
return new PrivateKey(bn); return new PrivateKey(bn);
}).to.throw(TypeError); }).to.throw(TypeError);
}); });

Loading…
Cancel
Save