bytesChunkToWords static method

List<String> bytesChunkToWords(
  1. List<int> bytesChunk,
  2. MnemonicWordsList wordsList, {
  3. Endian endian = Endian.big,
})

Converts a chunk of bytes into a list of three words using a provided word list.

Implementation

static List<String> bytesChunkToWords(
  List<int> bytesChunk,
  MnemonicWordsList wordsList, {
  Endian endian = Endian.big,
}) {
  final n = wordsList.length();

  final intChunk = IntUtils.fromBytes(bytesChunk, byteOrder: endian);
  final word1Idx = intChunk % n;
  final word2Idx = ((intChunk ~/ n) + word1Idx) % n;
  final word3Idx = ((intChunk ~/ (n * n) + word2Idx)) % n;

  return [
    wordsList.getWordAtIdx(word1Idx),
    wordsList.getWordAtIdx(word2Idx),
    wordsList.getWordAtIdx(word3Idx),
  ];
}