Beispiel #1
0
 public function testConditionalSwap()
 {
     $a = '104564512312317874865';
     $b = '04156456456456456456';
     $curve = new CurveFp(23, 1, 1, new Gmp());
     $point = $curve->getPoint(13, 7, 7);
     $point->cswapValue($a, $b, false);
     $this->assertEquals('104564512312317874865', $a);
     $this->assertEquals('4156456456456456456', $b);
     $point->cswapValue($a, $b, true);
     $this->assertEquals('104564512312317874865', $b);
     $this->assertEquals('4156456456456456456', $a);
     $point->cswapValue($a, $b, false);
     $this->assertEquals('104564512312317874865', $b);
     $this->assertEquals('4156456456456456456', $a);
 }
Beispiel #2
0
 /**
  * @param int|string           $name
  * @param int|string           $prime
  * @param int|string           $a
  * @param MathAdapterInterface $b
  * @param MathAdapterInterface $adapter
  */
 public function __construct($name, $prime, $a, $b, MathAdapterInterface $adapter)
 {
     $this->name = $name;
     parent::__construct($prime, $a, $b, $adapter);
 }
Beispiel #3
0
 /**
  *
  * @dataProvider getAdapters
  */
 public function testInfinity(MathAdapterInterface $math)
 {
     $c = new CurveFp(23, 1, 1, $math);
     $g = $c->getPoint(13, 7, 7);
     $check = $c->getInfinity();
     for ($i = 0; $i < 8; $i++) {
         $mul = $i % 7;
         $p = $g->mul($mul);
         $this->assertTrue($check->equals($p), "{$g} * {$mul} = {$p}, expected {$check}");
         $check = $g->add($check);
     }
 }