1

I have the following problem in Bitcoin Core. With this command:

echo carpet begin bacon master draft fortune food cherry cage axis vault clown | \
bx mnemonic-to-seed | \
bx hd-new -v 70615956 | \
bx hd-to-ec -c bx-testnet.cfg | \
sed 's/$/01/' | \
bx base58check-encode -v 239

What I am doing is from the mnemonic carpet begin bacon master draft fortune food cherry cage axis vault clown, I am generating an hdseed for Bitcoin Core in regtest. Results:

cNQQqyR81GZXU3Pa1pK1gQQp6jgni5HyLYM99nL2JpzVRmdCyrFE

Then I use the command:

bitcoin-cli -regtest sethdseed true cNQQqyR81GZXU3Pa1pK1gQQp6jgni5HyLYM99nL2JpzVRmdCyrFE

Where I change the hdseed for which I just got you and Bitcoin Core generates a key pool. When I put that same mnemonic on the page BIP39 it gives me as root key the same that gives me the command up to this part:

echo carpet begin bacon master draft fortune food cherry cage axis vault clown | \
bx mnemonic-to-seed | \
bx hd-new -v 70615956

which is: tprv8ZgxMBicQKsPd5cY6ZZzsRzkcfDANp2y3jFtYNQZsp953sXiFNP9ZFod1fAhkgtCJZGvTcLJVdhFCj7VDNu68nuP4m2QGLcd4JpkteG8Ccc

However, the derivations of private keys generated by Bitcoin Core do not coincide with those of BIP39, nor does the BIP32 root key of BIP39 coincide with the private masterkey of Bitcoin Core, while the hdseed if it matches the one that happens in the command. Both the derivations, hdseed and the Bitcoin Core master key are obtained with the command bitcoin-cli -regtest dumpwallet test_wallet

I get two big unknowns:

  1. Is the way in which I am generating the hdseed from the mnemonic correct?
  2. Bitcoin Core generates its private master key from hdseed? And if so, is that operation reversible?

But in general I want to know why they are giving different!!!

Thanks in advance.

1 Answer 1

2

I want to know why the two tools are giving different results

Bitcoin Core uses hardened derivation to derive child private keys from the master private key. You can check the embedded link for more details, but in summary it means that the software uses parent private keys within the hash function to generate child private keys. This compares to non-hardened derivation which uses parent public keys in the hash function. Since Bitcoin Core uses hardened derivation while the online tool that you mentioned uses non-hardened derivation (and also different paths), there is a natural mismatch in the keys generated by the two of them.

Bitcoin Core generates private keys using the hierarchical deterministic key generation using the path m/0'/0'/k' where k is the kth key generated from the master private key. Most wallets use the path m/44'/0'/0'/0/k for generating the kth receiving key.

Bitcoin Core generates its private master key from hdseed? And if so, is that operation reversible?

HD seed is used to generate the master private key using a hash function. So the operation is only one way and cannot work the other way.

Is the way in which I am generating the hdseed from the mnemonic correct?

It looks to be correct but on other aspect, the mnemonic that you provided in the question is not valid (I'm unsure if it was intentional) as the checksum does not match up with the entropy.

3
  • BIP-39 works with hardened derivation. Calculate the derived private key with m / 0 '/ 0' and then derive the keys
    – wic
    Commented Jan 21, 2020 at 15:08
  • @wic it can, but the paths are different.
    – Ugam Kamat
    Commented Jan 21, 2020 at 18:47
  • I use bx mnemonic-to-seed command to verify mnemonic and it is correct, because if it is not correct, it return exception
    – wic
    Commented Jan 29, 2020 at 22:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.