Esempio n. 1
0
 public function testAddInfinityReturnsOriginalPoint()
 {
     $adapter = new Gmp();
     $curve = new CurveFp(23, 1, 1, $adapter);
     $infinity = $curve->getInfinity();
     $point = new Point($adapter, $curve, 13, 7, 7);
     $sum = $point->add($infinity);
     $this->assertTrue($point->equals($sum));
     $sum = $infinity->add($point);
     $this->assertTrue($point->equals($sum));
 }
Esempio n. 2
0
 /**
  * @param MathAdapterInterface           $adapter
  * @param CurveFpInterface               $curve
  * @param int|string                     $x
  * @param int|string                     $y
  * @param null                           $order
  * @param RandomNumberGeneratorInterface $generator
  */
 public function __construct(MathAdapterInterface $adapter, CurveFpInterface $curve, $x, $y, $order = null, RandomNumberGeneratorInterface $generator = null)
 {
     $this->generator = $generator ?: RandomGeneratorFactory::getRandomGenerator();
     parent::__construct($adapter, $curve, $x, $y, $order);
 }
Esempio n. 3
0
 /**
  * Take X, Y, and a generator point, and we can get what we need!
  *
  * @param Math $math
  * @param GeneratorPoint $generator
  * @param int|string $x
  * @param int|string $y
  */
 public function __construct(Math $math, GeneratorPoint $generator, $x, $y)
 {
     parent::__construct($math, $generator->getCurve(), $x, $y, $generator->getOrder());
 }