computeChecksum static method

List<int> computeChecksum(
  1. String hrp,
  2. List<int> data, [
  3. Bech32Encodings encoding = Bech32Encodings.bech32
])

Compute the checksum from the specified HRP and data.

Implementation

static List<int> computeChecksum(String hrp, List<int> data,
    [Bech32Encodings encoding = Bech32Encodings.bech32]) {
  final values = [...hrpExpand(hrp), ...data];
  final polymod = (polyMod([...values, 0, 0, 0, 0, 0, 0]) ^
      Bech32Const.encodingChecksumConst[encoding]!);

  return List<int>.from([
    for (var i = 0; i < Bech32Const.checksumStrLen; i++)
      (polymod >> (5 * (5 - i))) & 0x1f
  ]);
}