iancoleman / bip39

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

Discrepancies with Ledger wallet addresses and extended keys #166

Closed pmgriphone closed 6 years ago

pmgriphone commented 6 years ago

I have tried to verify wallet addresses and keys generated by the Ledger Nano S and this tool.

I note that I ran into an issue when verifying the extended public keys. So far I have only tried this for Bitcoin Segwit (derivation path m/49'/0'/0'). The problem is that when selecting the BIP44 tab on the BIP39 html page, it does properly generate the wallet address (i.e. it is the same as the one the ledger generated), but the extended public key does not match the one from the ledger chrome app. If I instead go to the BIP32 tab of the BIP39 html page and enter the custom derivation path as m/49'/0'/0' then the proper extended public key is generated (same as the one the ledger chrome app gives me), but the wallet address is not the same as the ledger wallet address!

The BIP39 page says that the wallet addresses are generated from the BIP32 extended keys, so the question is now: which tool contains a bug: the ledger chrome app or the BIP39 html tool. Or am I missing something here? Shouldn't both tools generate the same wallet addresses AND extended keys?

Any insights into this appreciated.

Thanks.

iancoleman commented 6 years ago

have only tried this for Bitcoin Segwit (derivation path m/49'/0'/0')

On that tab there's a field 'Account Extended Public Key' - does that match the expected ledger nano s output?

I'm not especially familiar with the ledger but usually the backup extended keys are for the account (and the derivation path seems to indicate as such).

Read about BIP44 / BIP49 'change addresses' to understand what this is about. Hopefully this helps, if there's still confusion I'm happy to explain in more detail.

pmgriphone commented 6 years ago

Thanks for the speedy reply Ian!

On the BIP49 tab of the Derivation Path, NONE of the extended keys matches the extended public key of Ledger. The first wallet address under 'Derived Addresses' however matches the Ledges wallet.

However, if I change the tab under the Derivation Path from BIP49 to BIP32, then the BIP32 Extended Public Key matches the Ledger's one (as a sidenote, I note that there is no 'Account Extended Public Key' on this BIP32 tab, it was on the BIP49 tab but didn't match). However, the wallet address under 'Derived Addresses' doesn't match the Ledger's wallet address anymore.

It is still not clear to me if this is a bug or if this is just the way it is supposed to be as it makes it very hard to verify that the Ledger's wallet/extended keys can be reproduced if ever needed.

Any explanation appreciated.

testosteronecyp commented 6 years ago

I am having the same issue. You figure out a fix?

avialias commented 6 years ago

Read issue 18... I have same problem with ETH...some values dont mach...maybe its just bug on mapping values to wrong elements on html form.

I can provide test seed from my Ledger Nano S, and pictures from MyEtherWallet and Bitcoin Chrome wallet...

pmgriphone commented 6 years ago

Try this tool instead

https://coinomi.com/recovery-phrase-tool.html

Please report back here if this gives the correct numbers.

iancoleman commented 6 years ago

Fixed by https://github.com/iancoleman/bip39/commit/f83d786dd7c26e5b3e4feac22f14893464f9f8c4#diff-99a85c3932c0670278158f38d818e0efR2562