Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: Forsyth Jones on July 30, 2024, 02:39:22 PM



Title: What is the extended private key in WIF format for? BIP32 root key (WIF)
Post by: Forsyth Jones on July 30, 2024, 02:39:22 PM
There is a way to convert an extended root private key to WIF format. Some tools do this (https://bitcoiner.guide/seed/), but I haven't found any use cases yet. Can it be used to recover the same wallet calculated by the extended private key? If not, what is its use?

https://www.talkimg.com/images/2024/07/30/5aRNj.png

I don't know of any wallet or tool that restores or derives addresses from a wallet using only the extended private key in WIF format, except for Bitcoin Core in the legacy wallet format (https://developer.bitcoin.org/reference/rpc/sethdseed.html).

Remember that an extended private key in WIF format is also a single common private key, so it can derive a common address.

In my opinion, if it's possible to restore a wallet using the WIF extended private key, it'd be much more practical to use an xpriv to restore, as it's an additional option.


Title: Re: What is the extended private key in WIF format for? BIP32 root key (WIF)
Post by: Charles-Tim on July 30, 2024, 02:53:31 PM
The private key that starts from 05, K or L are referred to as wallet import format (WIF). They are private keys that a single address is derived from. So in HD wallet, they are child keys that generate their responding addresses.

BIP32 Root Key generates child keys while the child keys generate their corresponding addressed. It is the BIP32 which was used before BIP44 and others. BIP32 defines the path to HD wallet.

You can use it on Electrum.


Title: Re: What is the extended private key in WIF format for? BIP32 root key (WIF)
Post by: Forsyth Jones on July 30, 2024, 10:30:21 PM
The private key that starts from 05, K or L are referred to as wallet import format (WIF). They are private keys that a single address is derived from. So in HD wallet, they are child keys that generate their responding addresses.

BIP32 Root Key generates child keys while the child keys generate their corresponding addressed. It is the BIP32 which was used before BIP44 and others. BIP32 defines the path to HD wallet.

You can use it on Electrum.
Thank you.

I would also like to know if it is possible to convert an extended private key in WIF format to xpriv. If so, what tool or code allows you to do this?

We know that it is possible to convert an xpriv to WIF format.


Title: Re: What is the extended private key in WIF format for? BIP32 root key (WIF)
Post by: Charles-Tim on July 30, 2024, 10:35:29 PM
I would also like to know if it is possible to convert an extended private key in WIF format to xpriv. If so, what tool or code allows you to do this?
It is like asking if a leave can result to a tree. It is a tree that can result to leaves.

So that is not possible. I do not know how to explain this better than to tell you to read the mastering bitcoin chapter 4 which discussed about keys, addresses and wallet.

https://www.oreilly.com/library/view/mastering-bitcoin/9781491902639/ch04.html


Title: Re: What is the extended private key in WIF format for? BIP32 root key (WIF)
Post by: odolvlobo on July 31, 2024, 05:32:32 PM
You answered your own question. It is used to set/restore the seed value for a Bitcoin Core HD wallet. The BIP32 Root WIF holds the 256-bit seed. It is not an extended key. The extended keys are derived from it.


Title: Re: What is the extended private key in WIF format for? BIP32 root key (WIF)
Post by: Forsyth Jones on August 01, 2024, 12:21:27 AM
I would also like to know if it is possible to convert an extended private key in WIF format to xpriv. If so, what tool or code allows you to do this?
It is like asking if a leave can result to a tree. It is a tree that can result to leaves.

So that is not possible. I do not know how to explain this better than to tell you to read the mastering bitcoin chapter 4 which discussed about keys, addresses and wallet.

https://www.oreilly.com/library/view/mastering-bitcoin/9781491902639/ch04.html
I think you haven't gotten my point yet, the point here is that it is possible to generate an HD wallet, that is, derive receiving and change addresses using a single WIF key as an HD seed, the only wallet that did this was Bitcoin Core.

According to this post (https://bitcoin.stackexchange.com/questions/89036/bip32-bitcoin-core-wallet-hdseed-format-from-xprv-master-key), Achow explains that in Bitcoin Core (bdb - legacy) the hdseed (WIF-key) is used to derive the extended private key (root master key) and then generate new keys using the new seed. Bitcoin Core used the BIP32 method to generate the master private key from a seed, the seed used was a WIF private key and not the common mnemonic in BIP39.

Today with the new descriptor format, this method is no longer necessary to derive an HD wallet using the WIF private key with the sethdseed command.

You answered your own question. It is used to set/restore the seed value for a Bitcoin Core HD wallet. The BIP32 Root WIF holds the 256-bit seed. It is not an extended key. The extended keys are derived from it.

I see, so why in the bitcoin core dumpfile, both the WIF key (which produces the keys from the WIF key seed value) and the xpriv master private key, but both generate the same keys?

I always thought that the WIF private key that contains the value hdseed=1 represented the same value as the xpriv, just converted to WIF.