computeChecksum static method
Computes the checksum word for a list of Monero mnemonic words.
This method takes a list of Monero mnemonic words and a specified Monero language. It computes a checksum word for the given mnemonic words to enhance error detection and correction.
mnemonic
: The list of Monero mnemonic words for which to compute the checksum.
language
: The Monero language used in the mnemonic.
Returns the computed checksum word.
Implementation
static String computeChecksum(
List<String> mnemonic, MnemonicLanguages language) {
final uniqueLen = MoneroMnemonicConst.languageUniquePrefixLen[language]!;
final String prefixes = mnemonic.map((word) {
final len = word.length >= uniqueLen ? uniqueLen : word.length;
return word.substring(0, len);
}).join();
final int index =
Crc32.quickIntDigest(StringUtils.encode(prefixes)) % mnemonic.length;
return mnemonic[index];
}