Key -> Keypair
...that is what is called everywhere else.
This commit is contained in:
parent
e984736736
commit
f3614e4a90
|
@ -3,32 +3,32 @@ var Pubkey = require('./pubkey');
|
|||
var BN = require('./bn');
|
||||
var point = require('./point');
|
||||
|
||||
var Key = function Key(obj) {
|
||||
if (!(this instanceof Key))
|
||||
return new Key(obj);
|
||||
var Keypair = function Keypair(obj) {
|
||||
if (!(this instanceof Keypair))
|
||||
return new Keypair(obj);
|
||||
if (obj)
|
||||
this.set(obj);
|
||||
};
|
||||
|
||||
Key.prototype.set = function(obj) {
|
||||
Keypair.prototype.set = function(obj) {
|
||||
this.privkey = obj.privkey || this.privkey || undefined;
|
||||
this.pubkey = obj.pubkey || this.pubkey || undefined;
|
||||
return this;
|
||||
};
|
||||
|
||||
Key.prototype.fromPrivkey = function(privkey) {
|
||||
Keypair.prototype.fromPrivkey = function(privkey) {
|
||||
this.privkey = privkey;
|
||||
this.privkey2pubkey();
|
||||
return this;
|
||||
};
|
||||
|
||||
Key.prototype.fromRandom = function() {
|
||||
Keypair.prototype.fromRandom = function() {
|
||||
this.privkey = Privkey().fromRandom();
|
||||
this.privkey2pubkey();
|
||||
return this;
|
||||
};
|
||||
|
||||
Key.prototype.fromString = function(str) {
|
||||
Keypair.prototype.fromString = function(str) {
|
||||
var obj = JSON.parse(str);
|
||||
if (obj.privkey) {
|
||||
this.privkey = new Privkey();
|
||||
|
@ -40,11 +40,11 @@ Key.prototype.fromString = function(str) {
|
|||
}
|
||||
};
|
||||
|
||||
Key.prototype.privkey2pubkey = function() {
|
||||
Keypair.prototype.privkey2pubkey = function() {
|
||||
this.pubkey = Pubkey().fromPrivkey(this.privkey);
|
||||
};
|
||||
|
||||
Key.prototype.toString = function() {
|
||||
Keypair.prototype.toString = function() {
|
||||
var obj = {};
|
||||
if (this.privkey)
|
||||
obj.privkey = this.privkey.toString();
|
||||
|
@ -53,4 +53,4 @@ Key.prototype.toString = function() {
|
|||
return JSON.stringify(obj);
|
||||
};
|
||||
|
||||
module.exports = Key;
|
||||
module.exports = Keypair;
|
||||
|
|
Loading…
Reference in New Issue