isValidPrivateKey function

bool isValidPrivateKey(
  1. Uint8List privateKey
)

Test if the private key is valid.

@param privateKey Uint8List of a private key. @return true/false

Implementation

bool isValidPrivateKey(Uint8List privateKey) {
  var hexKey = bytesToInt(privateKey);
  if (hexKey.toInt() == 0) {
    return false;
  }

  if (hexKey >= _maxForPrivateKeyInt) {
    return false;
  }

  if (privateKey.length != 32) {
    return false;
  }
  return true;
}