mnemonic To Entropy
Converts a BIP-39 mnemonic phrase back to its original entropy.
This function validates the mnemonic by:
Checking word count (must be 12, 15, 18, 21, or 24)
Verifying all words exist in the word list
Validating the checksum
Algorithm:
Split mnemonic into words
Look up each word's index in word list (O(1) HashMap lookup)
Convert indices to 11-bit binary strings
Concatenate all bits
Split into entropy bits and checksum bits
Verify checksum using constant-time comparison
Return entropy bytes
This function is suspend because JavaScript requires async initialization of the cryptographic library for SHA-256 checksum validation. On JVM and Native platforms, the suspend keyword has zero overhead.
Return
Original entropy bytes
Parameters
Space-separated mnemonic phrase
Word list language (default: English)
Throws
if word count is invalid
if a word is not in the word list
if checksum validation fails
Example:
val mnemonic = "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about"
val entropy = MnemonicUtils.mnemonicToEntropy(mnemonic)
// entropy is 16 bytes of zeros