compressed by default with fromRandom
This commit is contained in:
parent
b7bde14e06
commit
40e8dfec06
|
@ -31,6 +31,7 @@ ECDSA.prototype.calci = function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Qprime.point.eq(this.key.pubkey.point)) {
|
if (Qprime.point.eq(this.key.pubkey.point)) {
|
||||||
|
this.sig.compressed = this.key.pubkey.compressed;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,11 @@ Privkey.prototype.fromRandom = function() {
|
||||||
var bn = BN().fromBuffer(privbuf);
|
var bn = BN().fromBuffer(privbuf);
|
||||||
var condition = bn.lt(Point.getN());
|
var condition = bn.lt(Point.getN());
|
||||||
} while (!condition);
|
} while (!condition);
|
||||||
this.bn = bn;
|
this.set({
|
||||||
|
bn: bn,
|
||||||
|
networkstr: 'mainnet',
|
||||||
|
compressed: true
|
||||||
|
});
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ describe('Key', function() {
|
||||||
|
|
||||||
describe("#fromRandom", function() {
|
describe("#fromRandom", function() {
|
||||||
|
|
||||||
it('should make a new priv and pub', function() {
|
it('should make a new priv and pub, should be compressed, mainnet', function() {
|
||||||
var key = new Key();
|
var key = new Key();
|
||||||
key.fromRandom();
|
key.fromRandom();
|
||||||
should.exist(key.privkey);
|
should.exist(key.privkey);
|
||||||
|
@ -40,6 +40,9 @@ describe('Key', function() {
|
||||||
key.privkey.bn.gt(bn(0)).should.equal(true);
|
key.privkey.bn.gt(bn(0)).should.equal(true);
|
||||||
key.pubkey.point.getX().gt(bn(0)).should.equal(true);
|
key.pubkey.point.getX().gt(bn(0)).should.equal(true);
|
||||||
key.pubkey.point.getY().gt(bn(0)).should.equal(true);
|
key.pubkey.point.getY().gt(bn(0)).should.equal(true);
|
||||||
|
key.privkey.compressed.should.equal(true);
|
||||||
|
key.privkey.networkstr.should.equal('mainnet');
|
||||||
|
key.pubkey.compressed.should.equal(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -42,10 +42,11 @@ describe('Privkey', function() {
|
||||||
|
|
||||||
describe('#fromRandom', function() {
|
describe('#fromRandom', function() {
|
||||||
|
|
||||||
it('should set bn gt 0 and lt n', function() {
|
it('should set bn gt 0 and lt n, and should be compressed', function() {
|
||||||
var privkey = Privkey().fromRandom();
|
var privkey = Privkey().fromRandom();
|
||||||
privkey.bn.gt(BN(0)).should.equal(true);
|
privkey.bn.gt(BN(0)).should.equal(true);
|
||||||
privkey.bn.lt(Point.getN()).should.equal(true);
|
privkey.bn.lt(Point.getN()).should.equal(true);
|
||||||
|
privkey.compressed.should.equal(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue