incrementLimb method

void incrementLimb()

Implementation

void incrementLimb() {
  curIdx += 1;
  curLimb = nextLimb;

  if (buf.isEmpty) {
    // No more bytes → zero-extend
    nextLimb = BigInt.zero;
  } else if (buf.length <= 7) {
    // Fewer than 8 bytes → zero-extend
    final padded = List<int>.filled(8, 0);
    for (int i = 0; i < buf.length; i++) {
      padded[i] = buf[i];
    }
    nextLimb = BigintUtils.fromBytes(padded, byteOrder: Endian.little);
    buf = const [];
  } else {
    // At least 8 bytes → read next u64
    final next = buf.sublist(0, 8);
    nextLimb = BigintUtils.fromBytes(next, byteOrder: Endian.little);
    buf = buf.sublist(8);
  }
}