isPrivate function

bool isPrivate(
  1. Uint8List x
)

Generator point 'G' This function checks if a Uint8List 'x' represents a valid private key. It performs multiple checks to ensure 'x' is a valid scalar within a specified range. It returns true if 'x' is a valid private key; otherwise, it returns false.

Implementation

/// This function checks if a Uint8List 'x' represents a valid private key.
/// It performs multiple checks to ensure 'x' is a valid scalar within a specified range.
/// It returns true if 'x' is a valid private key; otherwise, it returns false.
bool isPrivate(Uint8List x) {
  /// Check if 'x' is a valid scalar; if not, return false.
  if (!isScalar(x)) {
    return false;
  }

  /// Compare 'x' to the all-zero byte sequence and the elliptic curve group order.
  /// If 'x' is greater than 0 and less than the group order, it's a valid private key.
  return _compare(x, Uint8List(32)) > 0 && _compare(x, _rcOrderBytes) < 0;
}