We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I am trying to verify the signature, but I got the error: Cannot initialize. Here is my code:
public static function verifySignature($hash, $signature, $address) { try { $sign = [ "r" => substr($signature, 0, 64), "s" => substr($signature, 64, 64), ]; $reCid = ord(hex2bin(substr($signature, 128, 2))); if ($reCid != ($reCid & 1)) { return false; } $ec = new EC('secp256k1'); $publicKey = $ec->recoverPubKey($hash, $sign, $reCid); return $address == self::pubKeyToAddress($publicKey); }catch (\Exception $exception) { throw new HashException($exception->getCode(),$exception->getMessage()); } } verifySignature("c230e229e1e7edd299b4c142ac105a84df7c114ef1d6c538ee9e8461f70b2ad3",""W6AdiMNBTRb/a9oa43CFnL+UjpdhJ4QuxfnVQuTY8EB0RQQ2pvWEeIF9c5oMrokVrCmtBiXe4vW3Fvu+mIZ2bwA=","0x38737be4bb9bdB44Fa4367935E087Dad925CE172");
I traced the error and found it threw out when executed to $ec->recoverPubKey($hash, $sign, $reCid);
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I am trying to verify the signature, but I got the error: Cannot initialize.
Here is my code:
public static function verifySignature($hash, $signature, $address) {
try {
$sign = [
"r" => substr($signature, 0, 64),
"s" => substr($signature, 64, 64),
];
$reCid = ord(hex2bin(substr($signature, 128, 2)));
if ($reCid != ($reCid & 1)) {
return false;
}
$ec = new EC('secp256k1');
$publicKey = $ec->recoverPubKey($hash, $sign, $reCid);
return $address == self::pubKeyToAddress($publicKey);
}catch (\Exception $exception) {
throw new HashException($exception->getCode(),$exception->getMessage());
}
}
verifySignature("c230e229e1e7edd299b4c142ac105a84df7c114ef1d6c538ee9e8461f70b2ad3",""W6AdiMNBTRb/a9oa43CFnL+UjpdhJ4QuxfnVQuTY8EB0RQQ2pvWEeIF9c5oMrokVrCmtBiXe4vW3Fvu+mIZ2bwA=","0x38737be4bb9bdB44Fa4367935E087Dad925CE172");
I traced the error and found it threw out when executed to $ec->recoverPubKey($hash, $sign, $reCid);
The text was updated successfully, but these errors were encountered: