calcPubKeyRecoveryParam static method

int calcPubKeyRecoveryParam(
  1. BigInt e,
  2. ECSignature ecSig,
  3. AMAXPublicKey publicKey
)

Find the public key recovery factor

Implementation

static int calcPubKeyRecoveryParam(BigInt e, ECSignature ecSig, AMAXPublicKey publicKey) {
  for (int i = 0; i < 4; i++) {
    ECPoint? Qprime = recoverPubKey(e, ecSig, i);
    if (Qprime == publicKey.q) {
      return i;
    }
  }
  throw 'Unable to find valid recovery factor';
}