diff options
-rw-r--r-- | src/js/index.js | 2 | ||||
-rw-r--r-- | tests/spec/tests.js | 22 |
2 files changed, 23 insertions, 1 deletions
diff --git a/src/js/index.js b/src/js/index.js index 96fc451..c502208 100644 --- a/src/js/index.js +++ b/src/js/index.js | |||
@@ -1238,7 +1238,7 @@ | |||
1238 | address = libs.ethUtil.addHexPrefix(checksumAddress); | 1238 | address = libs.ethUtil.addHexPrefix(checksumAddress); |
1239 | pubkey = libs.ethUtil.addHexPrefix(pubkey); | 1239 | pubkey = libs.ethUtil.addHexPrefix(pubkey); |
1240 | if (hasPrivkey) { | 1240 | if (hasPrivkey) { |
1241 | privkey = libs.ethUtil.bufferToHex(keyPair.d.toBuffer()); | 1241 | privkey = libs.ethUtil.bufferToHex(keyPair.d.toBuffer(32)); |
1242 | } | 1242 | } |
1243 | } | 1243 | } |
1244 | //TRX is different | 1244 | //TRX is different |
diff --git a/tests/spec/tests.js b/tests/spec/tests.js index 10575ef..d57b753 100644 --- a/tests/spec/tests.js +++ b/tests/spec/tests.js | |||
@@ -5122,4 +5122,26 @@ it('Generates ethereum addresses from a public key', function(done) { | |||
5122 | }); | 5122 | }); |
5123 | }); | 5123 | }); |
5124 | 5124 | ||
5125 | // https://github.com/iancoleman/bip39/issues/469 | ||
5126 | fit('Generates ethereum private keys with the correct padding', function(done) { | ||
5127 | var phrase = "flip vicious divorce angle toward say derive blue refuse load word creek once expire bounce"; | ||
5128 | let withoutPadding = "0x53121fc5d193e623d2dbf43b2a96640bbed16bd530947fff8dda12f1aec828"; | ||
5129 | let withPadding = "0x0053121fc5d193e623d2dbf43b2a96640bbed16bd530947fff8dda12f1aec828"; | ||
5130 | let skIndex = 15; | ||
5131 | driver.findElement(By.css('.phrase')) | ||
5132 | .sendKeys(phrase); | ||
5133 | selectNetwork('ETH - Ethereum'); | ||
5134 | driver.sleep(generateDelay).then(function() { | ||
5135 | driver.findElements(By.css(".privkey")) | ||
5136 | .then(function(els) { | ||
5137 | els[skIndex].getText() | ||
5138 | .then(function(sk) { | ||
5139 | expect(sk).toBe(withPadding); | ||
5140 | expect(sk).not.toBe(withoutPadding); | ||
5141 | done(); | ||
5142 | }); | ||
5143 | }) | ||
5144 | }); | ||
5145 | }); | ||
5146 | |||
5125 | }); | 5147 | }); |