I am trying to use the cryptowallet library LibWally to convert a 12-word mnemonic into a set of derived addresses. I believe my mistake is not with the library itself, but a process flow/algorithmic one, so even if you don't aren't familiar with the library, you may be able to help.

First I validate and convert the mnemonic to a seed with the following code:

    char *mnemonic = "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about";
    bip39_mnemonic_to_seed((const char *)mnemonic, "",
                          (unsigned char *)bytes_output, HMAC_SHA512_LEN,
     wally_hex_from_bytes((unsigned char*)bytes_output, size_written, &hex_output)

This gives me the proper seed value; at least it matches what I see on Ian Coleman's Site. Next I take the seed value in bytes_input (not the hex coded value) and call:

bip32_key_from_seed( (unsigned char*) bytes_output, 

And then retrieve the private key with:

bip32_key_to_base58(&key_structure, BIP32_FLAG_KEY_PRIVATE, &output_privkey);

The value in privKey does not match the Bip32 root key shown in Ian's site, though interestingly enough, it matches on the first 16 characters, before diverging (and winding up 4 chars longer).

Am I missing a step here? Or doing something else wrong?

Edit: Adding some output data. Using the phrase given above: my (and IanColeman's) seed is:


Root Key results:

Mine: xprv9s21ZrQH143K2fH5FXCJ4B1iTN2wJSq1h9z2wTZkytm3YgVRxP621bDZ7yqo4KdNWVNcMEyWBHrjThJ9jXMabog7R1RTWFNdSAz2mhX2VjL

IanColeman: xprv9s21ZrQH143K3GJpoapnV8SFfukcVBSfeCficPSGfubmSFDxo1kuHnLisriDvSnRRuL2Qrg5ggqHKNVpxR86QEC8w35uxmGoggxtQTPvfUu


  • what is the value of 'BIP32 Extended Private Key' for this example on iancoleman.io ? Is it same as the value you get from bip32_key_from_base58() ? – Prayank Sep 10 '20 at 13:29
  • I added some output data above. Do you mean "to" base58, the function I'm already calling? Also, the docs for bip32_key_from_seed says it creates a new master root key. But the output is an "extkey", an extended key structure w/ public/private pair on it. It feels like I should first have to create the root key, then use that to create the extended key, no? – Endymio Sep 10 '20 at 14:31
  • Yes I pasted the wrong thing. To be honest I am not the best person to answer this question, since nobody else answered, question looks interesting, trying to understand how to solve the problem. Will test few things on my system in sometime. – Prayank Sep 10 '20 at 14:51
  • The extended private key on Coleman's site doesn't match the return value from my to_base58() call either. After the same "xprv9" prefix, it diverges. – Endymio Sep 10 '20 at 15:38
  • This might be helpful: bitcoin.stackexchange.com/questions/76655/… – Prayank Sep 12 '20 at 4:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.