0

Creating an HD wallet as per BIP39, adapted from O'Reilly's Mastering Bitcoin by Andreas Antonopoulos

  1. Generate pseudo-random number as 32 hex characters

$ bx seed > entropy

  1. Convert random number to 12-word mnemonic "sentence" for backup

$ bx hd-mnemonic < entropy > words

  • Q1 Presumably the checksumming was included?

$ bx mnemonic-decode < words

  • Q2 Why would we need to go back?
  1. Derive the root / master key, basis for BIP32 derivation of the hierarchy of keys

$ bx hd-new < entropy > master

  • Q3 Why is the (supposedly optional) passphrase as salt left out?

  • Q4 I do not have access to run the bx tools ATM, are there detailed docs that show the --help output text?

  • Q5 Finally, is bx the canonical CLI tool for air-gapped tasks like creating new BIP39/BIP32 wallets, hashing / encoding different formats etc? I get a bit confused using the GUI / JS tools.

1
  • Do not use bx seed because it does not generate secure mnemonic phrases. More information: milksad.info Commented Aug 17, 2023 at 7:20

1 Answer 1

2

adapted from O'Reilly's Mastering Bitcoin by Andreas Antonopoulos

Note that the bx command set has since changed significantly.

Q1 Presumably the checksumming was included?

$ bx seed -b 512 > entropy

$ bx mnemonic-new < entropy > words

$ cat words
injury motor machine bench toy repair thumb mushroom prevent toward expand 
rural then market endorse replace chief frozen forum model click payment fan 
mechanic dwarf hobby want innocent cloud ready violin boy provide faith 
favorite print broom save crowd only tonight track dinner nominee remind obtain 
pulp average

$ bx mnemonic-to-seed < words
6705d4927c78a7ef9f409e652d0631214ee0757b44cd3de434f3c0f1a9d7e52f
5be3face8ee9092409f2eebb283a091601934b89939bcef0633bc9a646f8ef81

Note

  • the above result agrees with https://iancoleman.io/bip39/
  • the words "pulp" and "average" are both acceptable dictionary words. Repeated words are permissible in mnemonics AFAIK. We can use this to test checksumming.
$ sed 's/average/pulp/' words | bx mnemonic-to-seed
WARNING: The specified words are not a valid mnemonic in any supported 
dictionary.
cc546ef85e654fdefb6bd37ffec86ae5c5f1a0e9a28e1a252368510e6d05945f
35ebb8538a6c676fe72780390c33a4eeb5851da554061015fcbae4b96ad2fdaa

I guess that warning might be because of the checksum failure I induced.


Q2 Why would we need to go back?

wallet recovery?


Q3 Why is the (supposedly optional) passphrase as salt left out?

Because it is optional?

$ bx mnemonic-to-seed -h

Usage: bx mnemonic-to-seed [-h] [--config value] [--language value]
[--passphrase value] [WORD]...

Info: Convert a mnemonic seed (BIP39) to its numeric representation.

Options (named):

-c [--config]        The path to the configuration settings file.
-h [--help]          Get a description and instructions for this command.
-l [--language]      The language identifier of the dictionary of the
                     mnemonic. Options are 'en', 'es', 'fr', 'it', 'ja',
                     'cs', 'ru', 'uk', 'zh_Hans', 'zh_Hant' and 'any',
                     defaults to 'any'.
-p [--passphrase]    An optional passphrase for converting the mnemonic
                     to a seed.

Arguments (positional):

WORD                 The set of words that that make up the mnemonic. If
                     not specified the words are read from STDIN.

Q4 are there detailed docs that show the --help output text?

https://github.com/libbitcoin/libbitcoin-explorer says

Documentation is available on the wiki.

Which it is.


Q5 is bx the canonical CLI tool

No idea, sorry.

I guess you mean "most popular" as there are not really any lawmakers in Bitcoin who can make canon law. At least, not about which implementations you should use.

Some tools seem popular but I don't know of any credible survey results.

5
  • Thanks, great response! Not at all interested in general popularity, but sometimes there is somewhat a consensus among the experts around "the right tool for the job". Some other project may have a more modern comprehensive feature set for example. So, suggestions welcome.
    – HansBKK
    Commented Feb 18, 2022 at 19:30
  • I am struggling to imagine a case where just having the raw hex entropy would be more useful. Certainly all decent wallets can be recovered using the mnemonic. And, if there were a passphrase as there should be, I never heard of that being asked for in conjunction with the raw entropy?
    – HansBKK
    Commented Feb 18, 2022 at 19:37
  • bitcoin.stackexchange.com/a/112501/132451
    – HansBKK
    Commented Feb 19, 2022 at 11:57
  • I came across a comment where Ian Coleman implied a recommendation to use libbitcoin-explorer (bx)
    – HansBKK
    Commented Feb 19, 2022 at 11:59
  • petecorey.com/blog/2018/05/07/…
    – HansBKK
    Commented Feb 19, 2022 at 12:11

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.