BNToInt64BE function
Convert a big int to 64-bit big endian buffer.
Implementation
List<int> BNToInt64BE(BigInt bn) {
if (bn.isNegative) {
throw('bn not positive integer');
}
if (bn > BigInt.parse("18446744073709551615")) {
throw('bn outside of range');
}
var hexStr = '';
while (bn != BigInt.from(0)) {
int temp = 0;
temp = (bn % BigInt.from(16)).toInt();
if (temp.toInt() < 10) {
hexStr = String.fromCharCode(temp + 48) + hexStr;
} else {
hexStr = String.fromCharCode(temp + 55) + hexStr;
}
bn = bn ~/ BigInt.from(16);
}
return hex.decode(hexStr.padLeft(16, '0'));
}