base58ToBinary function
Convert an unsigned base-58 number in s
to a bignum
@param size bignum size (bytes)
Implementation
Uint8List base58ToBinary(int size, String s) {
var result = new Uint8List(size);
for (var i = 0; i < s.length; ++i) {
var carry = base58Map[s.codeUnitAt(i)];
if (carry < 0) {
throw 'invalid base-58 value';
}
for (var j = 0; j < size; ++j) {
var x = result[j] * 58 + carry;
result[j] = x;
carry = x >> 8;
}
if (carry != 0) {
throw 'base-58 value is out of range';
}
}
return Uint8List.fromList(result.reversed.toList());
}