Seed Phrases (Bip39)

Note that in the following example we derive our “master private key” from a Seed Phrase. This derivation is “deterministic”, therefore we do not need to backup or store actual private key, only the Seed Phrase is needed for future recovery of the key hierarchy.

class description
MnemonicCode A MnemonicCode object may be used to convert between binary seed values and lists of words as per the BIP39 specification
import org.twostack.bitcoin4j.crypto.MnemonicCode;

//seedPhrase is a BIP39 mnemonic seed
String seedPhrase = "mistake accident paddle system pyramid gown cram october hen emerge broken dose";

val words = seedPhrase?.splitToSequence(" ")?.toList()

val mc = MnemonicCode()
mc.check(words)
val seedBytes = MnemonicCode.toSeed(words, "")

val masterKey: DeterministicKey = HDKeyDerivation.createMasterPrivateKey(seedBytes)
On this page