本文整理匯總了PHP中Point::getOrder方法的典型用法代碼示例。如果您正苦於以下問題:PHP Point::getOrder方法的具體用法?PHP Point::getOrder怎麽用?PHP Point::getOrder使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Point
的用法示例。
在下文中一共展示了Point::getOrder方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: __construct
public function __construct(Point $generator, Point $point)
{
$this->curve = $generator->getCurve();
$this->generator = $generator;
$this->point = $point;
$n = $generator->getOrder();
if ($n == null) {
throw new ErrorExcpetion("Generator Must have order.");
}
if (Point::cmp(Point::mul($n, $point), Point::$infinity) != 0) {
throw new ErrorException("Generator Point order is bad.");
}
if (extension_loaded('gmp') && USE_EXT == 'GMP') {
if (gmp_cmp($point->getX(), 0) < 0 || gmp_cmp($n, $point->getX()) <= 0 || gmp_cmp($point->getY(), 0) < 0 || gmp_cmp($n, $point->getY()) <= 0) {
throw new ErrorException("Generator Point has x and y out of range.");
}
} else {
if (extension_loaded('bcmath') && USE_EXT == 'BCMATH') {
if (bccomp($point->getX(), 0) == -1 || bccomp($n, $point->getX()) != 1 || bccomp($point->getY(), 0) == -1 || bccomp($n, $point->getY()) != 1) {
throw new ErrorException("Generator Point has x and y out of range.");
}
} else {
throw new ErrorException("Please install BCMATH or GMP");
}
}
}
示例2: point_is_valid
public static function point_is_valid(Point $generator, $x, $y)
{
if (extension_loaded('gmp') && USE_EXT == 'GMP') {
$n = $generator->getOrder();
$curve = $generator->getCurve();
if (gmp_cmp($x, 0) < 0 || gmp_cmp($n, $x) <= 0 || gmp_cmp($y, 0) < 0 || gmp_cmp($n, $y) <= 0) {
return false;
}
$containment = $curve->contains($x, $y);
if (!$containment) {
return false;
}
$point = new Point($curve, $x, $y);
$op = Point::mul($n, $point);
if (!(Point::cmp($op, Point::$infinity) == 0)) {
return false;
}
return true;
} else {
if (extension_loaded('bcmath') && USE_EXT == 'BCMATH') {
$n = $generator->getOrder();
$curve = $generator->getCurve();
if (bccomp($x, 0) == -1 || bccomp($n, $x) != 1 || bccomp($y, 0) == -1 || bccomp($n, $y) != 1) {
return false;
}
$containment = $curve->contains($x, $y);
if (!$containment) {
return false;
}
$point = new Point($curve, $x, $y);
$op = Point::mul($n, $point);
if (!(Point::cmp($op, Point::$infinity) == 0)) {
return false;
}
return true;
} else {
throw new ErrorException("Please install BCMATH or GMP");
}
}
}