Bitcoin

Hash – Generate private key from bip-39 seed phrase?

You can use Bitcoin Core to generate a new private key and its associated public address, but what you really want to do is generate a new private key from a 24-word seed phrase. I’m not sure how to solve this problem and couldn’t 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, we will generate a hash from 24 randomly selected words (from the BIP-39 word list) and then use that to generate the private key. What are the steps and format for hashing a seed phrase?

Related Articles

Back to top button