recoverPublicKey method
Implementation
ECDSAPublicKey? recoverPublicKey(
List<int> hash, ProjectiveECCPoint generator, int recId) {
final curve = generator.curve;
final order = generator.order!;
final secret = BigintUtils.fromBytes(hash);
final alpha =
(r.modPow(BigInt.from(3), curve.p) + curve.a * r + curve.b) % curve.p;
final beta = ECDSAUtils.modularSquareRootPrime(alpha, curve.p);
BigInt y = (beta % BigInt.two == BigInt.zero) ? beta : (curve.p - beta);
if (recId > 0) {
y = -y;
}
final ProjectiveECCPoint r1 = ProjectiveECCPoint(
curve: curve, x: r, y: y, z: BigInt.one, order: order);
final ProjectiveECCPoint q1 = ((r1 * s) + (generator * (-secret % order))) *
BigintUtils.inverseMod(r, order) as ProjectiveECCPoint;
return ECDSAPublicKey(generator, q1);
}