![](/img/trans.png)
[英]Symfony service container - Catchable Fatal Error - Argument passed to construct
[英]Elliptic Curve Cryptography PHP: catchable fatal error argument 1 passed to __construct()
我正在嘗試使用Matyas Danter的phpecc庫(可在1中使用)使用橢圓曲線密碼術。 但是,當我創建變量Alice時,出現以下錯誤,盡管傳遞的參數是Point ..請幫助..
可捕獲的致命錯誤:傳遞給EcDH :: __ construct()的參數1必須是Point的實例,給定字符串,在第31行的C:\\ xampp \\ htdocs \\ ECC-example.php中調用並在C:\\ xampp \\ htdocs中定義第39行的\\ classes \\ EcDH.php
include 'autoload.inc.php';
include 'classes/EcDH.php';
include 'classes/PHPECC.class.php';
include 'classes/SECurve.class.php';
$keypair = PHPECC::hex_keypair_genorate();
$g = NISTcurve::generator_192();
echo $g;
$Alice = new EcDH(g);
..........................................
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)->正確
一個愚蠢的錯誤,導致了巨大的錯誤。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.