From faa7a81cacea11a6eecca5fbc6d5c21ff10bb2e8 Mon Sep 17 00:00:00 2001 From: "Ryan X. Charles" Date: Fri, 29 Aug 2014 12:43:55 -0700 Subject: [PATCH] Key().fromPrivkey() --- lib/key.js | 6 ++++++ test/test.key.js | 8 ++++++++ 2 files changed, 14 insertions(+) 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() {