toSeed

fun Mnemonics.MnemonicCode.toSeed(passphrase: CharArray = charArrayOf(), validate: Boolean = true): ByteArray

Given a mnemonic, create a seed per BIP-0039.

Per the proposal, "A user may decide to protect their mnemonic with a passphrase. If a passphrase is not present, an empty string "" is used instead. To create a binary seed from the mnemonic, we use the PBKDF2 function with a mnemonic sentence (in UTF-8 NFKD) used as the password and the string "mnemonic" + passphrase (again in UTF-8 NFKD) used as the salt. The iteration count is set to 2048 and HMAC-SHA512 is used as the pseudo-random function. The length of the derived key is 512 bits (= 64 bytes).

Parameters

passphrase

an optional password to protect the phrase. Defaults to an empty string. This gets added to the salt. Note: it is expected that the passphrase has been normalized via a call to something like Normalizer.normalize(passphrase, Normalizer.Form.NFKD) but this only becomes important when additional language support is added.

validate

true to validate the mnemonic before attempting to generate the seed. This can add a bit of extra time to the calculation and is mainly only necessary when the seed is provided by user input. Meaning, in most cases, this can be false but we default to true to be "safe by default."