From 6e1f95163795d07a3c6eaed7384f7017a2a75774 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Tue, 8 Mar 2016 21:44:42 +0000 Subject: [PATCH] Support Quorum Wallet seed --- README.md | 1 + index.js | 10 ++++++++++ test/index.js | 7 +++++++ 3 files changed, 18 insertions(+) diff --git a/README.md b/README.md index 3c5434b..d3f1b7c 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,7 @@ Constructors: * `fromEtherCamp(passphrase)` - import a brain wallet used by Ether.Camp * `fromEtherWallet(input, password)` - import a wallet generated by EtherWallet * `fromKryptoKit(seed)` - import a wallet from a KryptoKit seed +* `fromQuorumWallet(passphrase, userid)` - import a brain wallet used by Quorum Wallet For the V1, V3 and EthSale formats the input is a JSON serialized string. All these formats require a password. diff --git a/index.js b/index.js index 7697e48..be55ea6 100644 --- a/index.js +++ b/index.js @@ -418,4 +418,14 @@ Wallet.fromKryptoKit = function (entropy, password) { return new Wallet(privKey) } +Wallet.fromQuorumWallet = function (passphrase, userid) { + assert(passphrase.length >= 10) + assert(userid.length >= 10) + + var seed = passphrase + userid + seed = crypto.pbkdf2Sync(seed, seed, 2000, 32, 'sha256'); + + return new Wallet(seed) +} + module.exports = Wallet diff --git a/test/index.js b/test/index.js index 400334c..60ef537 100644 --- a/test/index.js +++ b/test/index.js @@ -148,3 +148,10 @@ describe('.fromKryptoKit()', function () { assert.equal(wallet.getAddressString(), '0x3c753e27834db67329d1ec1fab67970ec1e27112') }) }) + +describe('.fromQuorumWallet()', function () { + it('should work', function () { + var wallet = Wallet.fromQuorumWallet('testtesttest', 'ethereumjs-wallet') + assert.equal(wallet.getAddressString(), '0x1b86ccc22e8f137f204a41a23033541242a48815') + }) +})