decodeWithChecksum method
Decode a BIP39 mnemonic phrase to obtain the entropy bytes with checksum.
This method is similar to decode, but it ensures that the mnemonic bit length is a multiple of 8 by zero-padding. It then returns the corresponding entropy bytes as a List<int>.
Parameters:
mnemonic
: The BIP39 mnemonic phrase to decode.
Example usage:
final decoder = Bip39MnemonicDecoder();
final entropy = decoder.decodeWithChecksum("your BIP39 mnemonic phrase here");
Returns: A List<int> containing the decoded entropy bytes with zero-padding.
Implementation
List<int> decodeWithChecksum(String mnemonic) {
final mnemonicBinStr = _decodeAndVerifyBinaryStr(mnemonic);
final mnemonicBitLen = mnemonicBinStr.length;
final padBitLen = mnemonicBitLen % 8 == 0
? mnemonicBitLen
: mnemonicBitLen + (8 - mnemonicBitLen % 8);
return BytesUtils.fromBinary(mnemonicBinStr,
zeroPadByteLen: padBitLen ~/ 4);
}