diff --git a/src/EcRecover.php b/src/EcRecover.php index 86720eb..32d0b98 100644 --- a/src/EcRecover.php +++ b/src/EcRecover.php @@ -67,7 +67,8 @@ public static function phpEcRecover(string $message_hash, string $signature) $ec = new EC('secp256k1'); $sign = ["r" => substr($signature, 2, 64), "s" => substr($signature, 66, 64)]; - $recid = ord(hex2bin(substr($signature, 130, 2))) - 27; + $recid = ord(hex2bin(substr($signature, 130, 2))); + $recid = $recid < 2 ? $recid : 1 - ($recid % 2); $pubKey = $ec->recoverPubKey($message_hash, $sign, $recid);