4

I'm able to generate a new private key and associated public addresses using bitcoin-core, but what I really want to do is generate a new private key from a 24 word seed phrase. I'm not sure how to go about this and I have not been able to find any examples.

BIP-39 Word list:

https://github.com/bitcoin/bips/blob/master/bip-0039/english.txt

Current code:

var bitcore=require("bitcore-lib");
var buffer=bitcore.crypto.Random.getRandomBuffer(256);
var hash=bitcore.crypto.Hash.sha256(buffer);
var bn=bitcore.crypto.BN.fromBuffer(hash);
var pk=new bitcore.PrivateKey(bn).toWIF();
var address=new bitcore.PrivateKey(bn).toAddress()+'';

If I understand correctly I will generate a hash from 24 randomly selected words (from the BIP-39 word list) then use that to generate a private key. What are the steps and format for hashing the seed phrase?

3
  • The 24 seed words can't be arbitrarily chosen. For examples for synthesizing seed words look at github.com/libbitcoin/libbitcoin-explorer/wiki/….
    – skaht
    Commented Mar 2, 2018 at 1:56
  • Thank you. I am developing in a Windows NodeJS environment using bitcoin-core. These examples look to be some kind of command line operation with "bx" which is not recognized as anything executable in my environment.
    – Corbin
    Commented Mar 2, 2018 at 2:40
  • At least you now have some test vector information when doing NodeJS work.
    – skaht
    Commented Mar 2, 2018 at 3:38

3 Answers 3

2

https://github.com/iancoleman/bip39

"A tool for converting BIP39 mnemonic phrases to addresses and private keys."

0

Bitcoin Core knows nothing of BIP39 seed phrases, since the developers never took those recommendations on board.

1
  • OP was asking about the bitcore JS library, not Bitcoin Core (though seems like they were confused about that themselves). Commented Aug 11, 2022 at 3:28
-1

Look at Example 7. There are also adjacent examples for other altcoins as well.

1
  • Thank you. I am developing in a Windows NodeJS environment using bitcoin-core. These examples look to be some kind of command line operation with "bx" which is not recognized as anything executable in my environment.
    – Corbin
    Commented Mar 2, 2018 at 2:40

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.