Key -> Keypair

...that is what is called everywhere else.
This commit is contained in:
Ryan X. Charles 2014-09-22 13:14:39 -07:00
parent e984736736
commit f3614e4a90
1 changed files with 10 additions and 10 deletions

View File

@ -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;