convenience: new Pubkey(point)
This commit is contained in:
parent
6f56c8d1fc
commit
a768755764
|
@ -2,11 +2,15 @@ var Point = require('./point');
|
||||||
var bn = require('./bn');
|
var bn = require('./bn');
|
||||||
var privkey = require('./privkey');
|
var privkey = require('./privkey');
|
||||||
|
|
||||||
var Pubkey = function Pubkey(obj) {
|
var Pubkey = function Pubkey(point) {
|
||||||
if (!(this instanceof Pubkey))
|
if (!(this instanceof Pubkey))
|
||||||
return new Pubkey(obj);
|
return new Pubkey(obj);
|
||||||
if (obj)
|
if (point instanceof Point)
|
||||||
|
this.point = point;
|
||||||
|
else if (point) {
|
||||||
|
var obj = point;
|
||||||
this.set(obj);
|
this.set(obj);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Pubkey.prototype.set = function(obj) {
|
Pubkey.prototype.set = function(obj) {
|
||||||
|
|
|
@ -17,6 +17,13 @@ describe('Pubkey', function() {
|
||||||
should.exist(pk.point);
|
should.exist(pk.point);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should create a public key with a point with this convenient method', function() {
|
||||||
|
var p = Point();
|
||||||
|
var pk = new Pubkey(p);
|
||||||
|
should.exist(pk.point);
|
||||||
|
pk.point.toString().should.equal(p.toString());
|
||||||
|
});
|
||||||
|
|
||||||
describe('#set', function() {
|
describe('#set', function() {
|
||||||
|
|
||||||
it('should make a public key from a point', function() {
|
it('should make a public key from a point', function() {
|
||||||
|
|
Loading…
Reference in New Issue