recoveryId method
Implementation
int recoveryId(ECSignature signature, Uint8List messageHash, Uint8List publicKeyBytes, ) {
final isCompressed = publicKeyBytes.length == 33;
BigInt publicKey = decodeBigIntToUnsigned(publicKeyBytes);
int recId = -1;
for (int i = 0; i < 4; i++) {
Uint8List? k =
recoverFromSignature(i, signature, messageHash, isCompressed);
if (k != null &&
decodeBigIntToUnsigned(k.sublist(isCompressed ? 0 : 1)) == publicKey) {
recId = i;
break;
}
}
if (recId == -1) {
throw Exception(
'Could not construct a recoverable key. Are your credentials valid?',
);
}
return recId;
}