pointAdd() public static method

Point addition method P + Q = R where: s = (yP - yQ)/(xP - xQ) mod p xR = s2 - xP - xQ mod p yR = -yP + s(xP - xR) mod p
public static pointAdd ( Bitpay\PointInterface $P, Bitpay\PointInterface $Q ) : Bitpay\PointInterface
$P Bitpay\PointInterface
$Q Bitpay\PointInterface
return Bitpay\PointInterface
Ejemplo n.º 1
0
 public function testPointAdd()
 {
     $point = Util::pointAdd(new Point(1, 1), new Point(1, 1));
     $expectedpoint = new Point("28948022309329048855892746252171976963317496166410141009864396001977208667916", "14474011154664524427946373126085988481658748083205070504932198000988604333958");
     $this->assertEquals($expectedpoint, $point);
     $point = Util::pointAdd(new Point(0, 0), new Point(1, 1));
     $expectedpoint = new Point("0", "0");
     $this->assertEquals($expectedpoint, $point);
     $point = Util::pointAdd(new Point(1, 0), new Point(0, 1));
     $expectedpoint = new Point("0", "115792089237316195423570985008687907853269984665640564039457584007908834671662");
     $this->assertEquals($expectedpoint, $point);
 }