hash function

BigInt hash(
  1. BigInt q,
  2. List<int> pubkey,
  3. List<int> msg
)

Implementation

BigInt hash(BigInt q, List<int> pubkey, List<int> msg) {
  final totalLength = PUBKEY_COMPRESSED_SIZE_BYTES * 2 + msg.length;

  /// 33 q + 33 pubkey + variable msgLen

  var Q = numbers.intToBytes(q);

  List<int> B = List.filled(totalLength, 0);

  B.setRange(0, Q.length, Q);

  B.setRange(33, 33 + pubkey.length, pubkey);

  B.setRange(66, 66 + msg.length, msg);

  var hashByte = sha256.convert(B).bytes;

  return numbers.bytesToInt(hashByte);
}