当前位置: 首页>>代码示例>>PHP>>正文


PHP Point::getOrder方法代码示例

本文整理汇总了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");
         }
     }
 }
开发者ID:AliceWonderMiscreations,项目名称:ColdAddress,代码行数:26,代码来源:PublicKey.php

示例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");
         }
     }
 }
开发者ID:keshvenderg,项目名称:cloudshop,代码行数:40,代码来源:PrivateKey.php


注:本文中的Point::getOrder方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。