publicVerify static method

bool publicVerify(
  1. String strPublicKey,
  2. String message,
  3. String strSignature
)

Implementation

static bool publicVerify(
  String strPublicKey,
  String message,
  String strSignature,
) {
  ECPublicKey publicKey = loadPublicKey(strPublicKey);
  ECDSASigner verifySinger = ECDSASigner(SHA512Digest(), Mac('SHA-512/HMAC'));
  var pubkeyParam =
      PublicKeyParameter(ECPublicKey(publicKey.Q, publicKey.parameters));

  final strR = strSignature.substring(0, 64);
  final strS = strSignature.substring(64, 128);
  final r = BigInt.parse(strR, radix: 16);
  final s = BigInt.parse(strS, radix: 16);

  ECSignature signature = ECSignature(r, s);
  verifySinger.init(false, pubkeyParam);
  return verifySinger.verifySignature(
      Uint8List.fromList(convert.utf8.encode(message)), signature);
}