isPoint method

bool isPoint(
  1. Uint8List p
)

Implementation

bool isPoint(Uint8List p) {
  if (p.length < 33) {
    return false;
  }

  final t = p[0];
  final x = p.sublist(1, 33);

  if (_compare(x, _ZERO32) == 0) {
    return false;
  }

  if (_compare(x, _EC_P) == 1) {
    return false;
  }

  try {
    const bigIntEndian = BigIntBigEndian();
    bigIntEndian.decode(p);
  } catch (err) {
    return false;
  }

  if ((t == 0x02 || t == 0x03) && p.length == 33) {
    return true;
  }

  final y = p.sublist(33);
  if (_compare(y, _ZERO32) == 0) {
    return false;
  }

  if (_compare(y, _EC_P) == 1) {
    return false;
  }

  if (t == 0x04 && p.length == 65) {
    return true;
  }

  return false;
}