Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/281.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
验证签名在椭圆php上失败,错误为;无法初始化";_Php_Signature_Verify_Recover - Fatal编程技术网

验证签名在椭圆php上失败,错误为;无法初始化";

验证签名在椭圆php上失败,错误为;无法初始化";,php,signature,verify,recover,Php,Signature,Verify,Recover,我试图使用椭圆php库验证签名,但我得到了错误:无法初始化。这是我的密码: <?php public static function verifySignature($hash, $signature, $address) { try { $sign = [ "r" => substr($signature, 0, 64), "s"

我试图使用椭圆php库验证签名,但我得到了错误:无法初始化。这是我的密码:

<?php
    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");
?>
你能告诉我是否有人知道原因吗

$ec->recoverPubKey($hash, $sign, $reCid);