Bitcoin Forum

Bitcoin => Hardware wallets => Topic started by: Rickorick on March 13, 2018, 12:09:33 AM



Title: Does Ledger Give Different Extended Public Keys for Both Segwit and Legacy Addr
Post by: Rickorick on March 13, 2018, 12:09:33 AM
I want to know if Ledger Gives Different Extended Public Keys for Both Segwit and Legacy Addresses, because i tried exporting my extended public key to recover BCH i mistakenly sent to a segwit address using https://bch.btc.com/docs/help/bch_segwit_recovery, but they said they xpub key is not associated with the address, but when i log in to ledger on chrome, i see the address there.


Title: Re: Does Ledger Give Different Extended Public Keys for Both Segwit and Legacy Addr
Post by: HCP on March 13, 2018, 04:48:43 AM
Yes...

SegWit uses m/49'/0'/0' derivation path
Legacy uses m/44'/0'/0' derivation path

if you look at: https://iancoleman.io/bip39/

Generate a random 24 word seed... (DO NOT put your Ledger seed in here!) click the BIP44 Tab and look at the "Account Extended Public Key". Then click the "BIP32" tab... set the "client" to "Custom"... and set the derivation path to: m/44'/0'/0' You'll notice that the "BIP32 Extended Public Key" is the same as the "Account Extended Public Key" form the BIP44 tab... this will be the same as the xpub generated by the "Legacy" wallet in Ledger (using the same seed mnemonic)

If you now change the derivation path to: m/49'/0'/0' you'll note that the "BIP32 Extended Public Key" changes... this should be the same as the xpub for a "SegWit" wallet in Ledger (using the same seed mnemonic)


Title: Re: Does Ledger Give Different Extended Public Keys for Both Segwit and Legacy Addr
Post by: Rickorick on March 13, 2018, 09:42:07 AM
Thanks man.


Title: Re: Does Ledger Give Different Extended Public Keys for Both Segwit and Legacy Addr
Post by: merclyn on January 16, 2019, 12:13:46 PM
I found a website that will convert the extended public key from xpub to ypub, or zpub. (actually can convert from any to any)

https://jlopp.github.io/xpub-converter/

the git project is at: https://github.com/jlopp/xpub-converter

I converted the core conversion logic to python for another project im working on.  I can post if anyone needs


Title: Re: Does Ledger Give Different Extended Public Keys for Both Segwit and Legacy Addr
Post by: jackg on January 16, 2019, 12:21:22 PM
@merclyn, that one wont work in this case because it's different derivation paths so it's different public keys from the seed.


Title: Re: Does Ledger Give Different Extended Public Keys for Both Segwit and Legacy Addr
Post by: merclyn on January 16, 2019, 01:15:23 PM
@merclyn, that one wont work in this case because it's different derivation paths so it's different public keys from the seed.


Your right, I should have understood the OP's main issue before I posted.

What I thought I was responding to was this scenario:
A Ledger Nano S was setup new with segwit addresses, but it provides a xpub in the log.

According to SLIP-0132 (https://github.com/satoshilabs/slips/blob/master/slip-0132.md) there should be different version byte (or different prefix on that key)
The ledger I tested should have produced a key that started with ypub (P2WPKH in P2SH), but it produced an xpub key.
The Trezor I tested displays the correct extended public key for the address scheme used..

The site I posted earlier would change the Bytes and return a ypub (or zpub if needed).

Thanks for the correction.


Title: Re: Does Ledger Give Different Extended Public Keys for Both Segwit and Legacy Addr
Post by: jackg on January 16, 2019, 02:13:44 PM
Yeah it's a really useful tool if it was the right derivation path, it's a bit of a shame it isn't imo.