verifySecp256k1 function
Implementation
bool verifySecp256k1(
String message,
Uint8List signature,
Secp256k1PublicKey publicKey,
) {
final blob = message.plainToU8a(useDartEncode: true);
final digest = SHA256Digest();
final signer = ECDSASigner(digest, HMac(digest, 64));
final sig = ECSignature(
signature.sublist(0, 32).toBn(endian: Endian.big),
signature.sublist(32).toBn(endian: Endian.big),
);
final kpub = secp256k1Params.curve.decodePoint(publicKey.toRaw())!;
final pub = ECPublicKey(kpub, secp256k1Params);
signer.init(false, p_api.PublicKeyParameter(pub));
return signer.verifySignature(blob, sig);
}