bits2int static method

BigInt bits2int(
  1. Uint8List bytes
)

RFC6979: ensure ECDSA msg is X bytes.

Implementation

static BigInt bits2int(Uint8List bytes) {
  // RFC suggests optional truncating via bits2octets
  final int delta = bytes.length * 8 - 256;
  // FIPS 186-4 4.6 suggests the leftmost min(nBitLen, outLen) bits, which
  final BigInt bigInt = bytesToBigInt(bytes);
  // matches bits2int. bits2int can produce res>N.
  return delta > 0 ? bigInt >> delta : bigInt;
}