mnemonicToSeed

suspend fun mnemonicToSeed(mnemonic: String, passphrase: String = ""): ByteArray

Converts a BIP-39 mnemonic phrase to a 64-byte seed.

Uses PBKDF2-HMAC-SHA512 with the following parameters per BIP-39:

  • Password: NFKD-normalized mnemonic phrase (UTF-8 encoded)

  • Salt: "mnemonic" + NFKD-normalized passphrase (UTF-8 encoded)

  • Iterations: 2048

  • Output length: 64 bytes (512 bits)

Both the mnemonic and passphrase are NFKD-normalized per BIP-39 specification to ensure consistent seed derivation across different Unicode representations.

The passphrase provides an additional security layer. Using different passphrases with the same mnemonic produces completely different seeds and wallets.

Warning: Lost passphrases cannot be recovered. The mnemonic alone cannot restore access to funds if a passphrase was used.

Return

64-byte BIP-39 seed

Example:

val mnemonic = "illness spike retreat truth genius clock brain pass fit cave bargain toe"

// Without passphrase
val seed = MnemonicUtils.mnemonicToSeed(mnemonic)

// With passphrase (creates a different wallet)
val seedWithPassphrase = MnemonicUtils.mnemonicToSeed(mnemonic, "secret passphrase")

Parameters

mnemonic

Space-separated mnemonic phrase

passphrase

Optional passphrase for additional security (default: empty string)