iancoleman / bip39

A web tool for converting BIP39 mnemonic codes
https://iancoleman.io/bip39/
MIT License
3.43k stars 1.42k forks source link

Ethereum private key incorrect #399

Closed iancoleman closed 4 years ago

iancoleman commented 4 years ago

Continuing from https://github.com/iancoleman/bip39/issues/395#issuecomment-578420534

I get the expected ETH address in standalone (without any Chrome or Brave issues) from my 12 word seed but it's giving me an incorrect private key

My manual tests (abandon abandon ability m/44'/60'/0'/0/0) give

0.3.11 Address 0xe5815d Public Key 0x03e723e Private Key 0x8f253078

0.4.0 Address 0xe5815d Public Key 0x03e723e Private Key 0xL21y1q

Private key is not matching.

To do:

iancoleman commented 4 years ago

It's using the bitcoin privkey WIF string instead of the ethereum hex encoded privkey.

Need to change

https://github.com/iancoleman/bip39/blob/927450e169e15e31b8f402c78a016cac47fc582d/src/js/index.js#L1137

to

privkey = libs.ethUtil.bufferToHex(keyPair.d.toBuffer())

I'll add this change and release asap (once the tests are all updated, a lot of extra test data to add so will take some time).

Thanks for bringing this to my attention @pieman64 and @PaulUD

PaulUD commented 4 years ago

Cheers @iancoleman

iancoleman commented 4 years ago

See https://github.com/iancoleman/bip39/commit/dd496c82c10ddd9612c80c70b4a21e05f2720624

Fix released in 0.4.2

spyhandler commented 4 years ago

Thank you. As of my understanding, anyone who would have generated a seed within 0.3.11 could have used it without any problems on Ledger / Trezor, but if he tried exporting private keys through the tool, he would have freaked out because of the messed up private key?

BR.

PaulUD commented 4 years ago

@spyhandler almost. 0.3.14 was fine.