hashedKeyFor method

Uint8List hashedKeyFor(
  1. List keys
)

Implementation

Uint8List hashedKeyFor(List<dynamic> keys) {
  if (keys.length != hashers.length) {
    throw Exception(
        'Invalid number of keys, expect ${hashers.length}, got ${keys.length}');
  }
  int keySize = 32;
  for (int i = 0; i < keys.length; i++) {
    keySize += hashers[i].size(keys[i]);
  }
  final Uint8List hash = Uint8List(keySize);
  Hasher.twoxx128.hashTo(
      data: Uint8List.fromList(utf8.encode(prefix)),
      output: hash.buffer.asUint8List(hash.offsetInBytes, 16));
  Hasher.twoxx128.hashTo(
      data: Uint8List.fromList(utf8.encode(storage)),
      output: hash.buffer.asUint8List(hash.offsetInBytes + 16, 16));
  int cursor = hash.offsetInBytes + 32;
  for (int i = 0; i < keys.length; i++) {
    hashers[i].hashTo(key: keys[i], output: hash.buffer.asUint8List(cursor));
    cursor += hashers[i].size(keys[i]);
  }
  return hash;
}