How does `bitcoind` generate the private key?

2

1

My question is how the bitcoin core client generates a (master) private key(s)?

I know from other wallets, that they take the mnemonic and generate a HD wallet master key. With the master key, the other keys can be generated.

To my question. How does the bitcoin core software do it? I've never seen a mnemonic there.

  • Does it use a mnemonic?
  • I know about the backupwallet command to make a backup.
    Is there nothing like a mnemonic I can use? If there isn't, do I have to constantly do backups?

dvg

Posted 2019-01-20T15:51:32.330

Reputation: 95

Answers

1

Bitcoind does not support BIP39, which encodes a seed (128, 160, 192, 224, 256 bits) in a mnemonic phrase, from which the 512b HD root seed is later generated via PBKDF2 (Password-Based Key Derivation Function 2). This 512b root seed is used to derive the (extended) master keys.

For wallets without BIP39, the 512b HD root seed is directly supplied as entropy, without the intermediary step involving an encoded mnemonic phrase and PBKDF2.

Backing up the wallet.dat file. https://bitcoin.stackexchange.com/a/22722/90088

Amended: Bitcoin Core wallets will deterministically derive new extended key pairs and addresses as wallet usage progresses, which is reflected and updated in the wallet.dat file. However, when restoring a wallet from an older wallet file, the wallet will (re)derive all standard child key derivation paths, whilst (re)scanning the blockchain to determine past usage of these keys in transactions, thereby recreating the last used hd wallet state. The wallet can be fully restored, even if the wallet file backup is not the most recent one because of this rescan.

James C.

Posted 2019-01-20T15:51:32.330

Reputation: 2 183

So could you expand on the 512b HD root seed is directly supplied as entropy? The 512b HD root seed is randomly generated. What's used for the randomness(entropy)?dvg 2019-01-20T16:23:58.060

And that means that I have to continously make backups from my keys because I don't have a seed ?dvg 2019-01-20T16:25:16.450

1@dvg New Bitcoin Core wallets do use BIP32 (with hardened derivation), so the keys are deterministic, and you don't need a new backup all the time. There just is no text form of the master key.Pieter Wuille 2019-01-20T17:03:25.573

@PieterWuille Thanks. I have amended the answer accordingly.James C. 2019-01-20T17:24:43.433

Thx @PieterWuille & JamesC. for the helpful responses!dvg 2019-01-20T18:11:36.393