/** * {@inheritDoc} * @see \Mdanter\Ecc\PointInterface::getDouble() */ public function getDouble() { if ($this->isInfinity()) { return $this->curve->getInfinity(); } $math = $this->adapter; $modMath = $this->modAdapter; $a = $this->curve->getA(); $threeX2 = $math->mul(3, $math->pow($this->x, 2)); $tangent = $modMath->div($math->add($threeX2, $a), $math->mul(2, $this->y)); $x3 = $modMath->sub($math->pow($tangent, 2), $math->mul(2, $this->x)); $y3 = $modMath->sub($math->mul($tangent, $math->sub($this->x, $x3)), $this->y); return new self($this->adapter, $this->curve, $x3, $y3, $this->order); }
/** * {@inheritDoc} * @see \Mdanter\Ecc\CurveFpInterface::cmp() */ public function cmp(CurveFpInterface $other) { $math = $this->adapter; $equal = $math->cmp($this->a, $other->getA()) == 0; $equal &= $math->cmp($this->b, $other->getB()) == 0; $equal &= $math->cmp($this->prime, $other->getPrime()) == 0; return $equal ? 0 : 1; }