椭圆曲线加密PHP:传递给_构造()的可捕获致命错误参数1
我正在尝试使用Matyas Danter的phpecc库使用椭圆曲线加密,该库可在中找到。然而,当我创建变量Alice时,我得到了以下错误,尽管传递的参数是一个点。。请帮忙 可捕获的致命错误:传递给EcDH的参数1::_construct()必须是Point的实例,字符串给定,在第31行的C:\xampp\htdocs\ECC-example.php中调用,并在第39行的C:\xampp\htdocs\classes\EcDH.php中定义 NISTcurve.php具有以下功能:椭圆曲线加密PHP:传递给_构造()的可捕获致命错误参数1,php,encryption,public-key-encryption,elliptic-curve,diffie-hellman,Php,Encryption,Public Key Encryption,Elliptic Curve,Diffie Hellman,我正在尝试使用Matyas Danter的phpecc库使用椭圆曲线加密,该库可在中找到。然而,当我创建变量Alice时,我得到了以下错误,尽管传递的参数是一个点。。请帮忙 可捕获的致命错误:传递给EcDH的参数1::_construct()必须是Point的实例,字符串给定,在第31行的C:\xampp\htdocs\ECC-example.php中调用,并在第39行的C:\xampp\htdocs\classes\EcDH.php中定义 NISTcurve.php具有以下功能:
public static function generator_192() {
// NIST Curve P-192:
if (extension_loaded('gmp') && USE_EXT == 'GMP') {
$_p = '6277101735386680763835789423207666416083908700390324961279';
$_r = '6277101735386680763835789423176059013767194773182842284081';
$_b = gmp_Utils::gmp_hexdec('0x64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1');
$_Gx = gmp_Utils::gmp_hexdec('0x188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012');
$_Gy = gmp_Utils::gmp_hexdec('0x07192b95ffc8da78631011ed6b24cdd573f977a11e794811');
$curve_192 = new CurveFp($_p, -3, $_b);
$generator_192 = new Point($curve_192, $_Gx, $_Gy, $_r);
} else if (extension_loaded('bcmath') && USE_EXT == 'BCMATH') {
$_p = '6277101735386680763835789423207666416083908700390324961279';
$_r = '6277101735386680763835789423176059013767194773182842284081';
$_b = bcmath_Utils::bchexdec('0x64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1');
$_Gx = bcmath_Utils::bchexdec('0x188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012');
$_Gy = bcmath_Utils::bchexdec('0x07192b95ffc8da78631011ed6b24cdd573f977a11e794811');
$curve_192 = new CurveFp($_p, -3, $_b);
$generator_192 = new Point($curve_192, $_Gx, $_Gy, $_r);
}
return $generator_192;
}
错误在最后一行 $Alice=新EcDH(g)->错误 $Alice=新的EcDH($g)->正确 一个愚蠢的错误导致了一个巨大的错误
public static function generator_192() {
// NIST Curve P-192:
if (extension_loaded('gmp') && USE_EXT == 'GMP') {
$_p = '6277101735386680763835789423207666416083908700390324961279';
$_r = '6277101735386680763835789423176059013767194773182842284081';
$_b = gmp_Utils::gmp_hexdec('0x64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1');
$_Gx = gmp_Utils::gmp_hexdec('0x188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012');
$_Gy = gmp_Utils::gmp_hexdec('0x07192b95ffc8da78631011ed6b24cdd573f977a11e794811');
$curve_192 = new CurveFp($_p, -3, $_b);
$generator_192 = new Point($curve_192, $_Gx, $_Gy, $_r);
} else if (extension_loaded('bcmath') && USE_EXT == 'BCMATH') {
$_p = '6277101735386680763835789423207666416083908700390324961279';
$_r = '6277101735386680763835789423176059013767194773182842284081';
$_b = bcmath_Utils::bchexdec('0x64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1');
$_Gx = bcmath_Utils::bchexdec('0x188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012');
$_Gy = bcmath_Utils::bchexdec('0x07192b95ffc8da78631011ed6b24cdd573f977a11e794811');
$curve_192 = new CurveFp($_p, -3, $_b);
$generator_192 = new Point($curve_192, $_Gx, $_Gy, $_r);
}
return $generator_192;
}