diff --git a/lib/key.js b/lib/key.js index d7baf4a..bf4ad94 100644 --- a/lib/key.js +++ b/lib/key.js @@ -17,6 +17,12 @@ Key.prototype.set = function(obj) { return this; }; +Key.prototype.fromPrivkey = function(privkey) { + this.privkey = privkey; + this.privkey2pubkey(); + return this; +}; + Key.prototype.fromRandom = function() { this.privkey = Privkey().fromRandom(); this.privkey2pubkey(); diff --git a/test/test.key.js b/test/test.key.js index 488237f..a321c44 100644 --- a/test/test.key.js +++ b/test/test.key.js @@ -30,6 +30,14 @@ describe('Key', function() { }); + describe("#fromPrivkey", function() { + + it('should make a new key from a privkey', function() { + should.exist(Key().fromPrivkey(Privkey().fromRandom()).pubkey); + }); + + }); + describe("#fromRandom", function() { it('should make a new priv and pub, should be compressed, mainnet', function() {