toSigFromBytes static method

Signature toSigFromBytes(
  1. Uint8List data
)

Implementation

static Signature toSigFromBytes(Uint8List data) {
  final int l = data.length;
  if (l < 2 || data[0] != 0x30) {
    throw Exception('Invalid signature tag');
  }
  if (data[1] != l - 2) {
    throw Exception('Invalid signature: incorrect length');
  }
  final (r, sBytes) = DER._parseInt(data.sublist(2));
  final (s, rBytesLeft) = DER._parseInt(sBytes);
  if (rBytesLeft.isNotEmpty) {
    throw Exception('Invalid signature: left bytes after parsing');
  }
  return Signature(r: r, s: s);
}