computeChecksum function

int computeChecksum(
  1. List<int> indices,
  2. int wordlistSize
)

Implementation

int computeChecksum(List<int> indices, int wordlistSize) {
  if (indices.isEmpty) {
    throw ArgumentError('Need at least one word index');
  }

  const primes = [31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79];

  int hash = 0;
  for (int i = 0; i < indices.length; i++) {
    final prime = primes[i % primes.length];
    hash ^= indices[i] * prime;
  }

  return hash % wordlistSize;
}