/** * Initialize a new instance * * @param MathAdapterInterface $adapter * @param CurveFpInterface $curve * @param int|string $x * @param int|string $y * @param int|string $order * @param bool $infinity * * @throws \RuntimeException when either the curve does not contain the given coordinates or * when order is not null and P(x, y) * order is not equal to infinity. */ public function __construct(MathAdapterInterface $adapter, CurveFpInterface $curve, $x, $y, $order, $infinity = false) { $this->adapter = $adapter; $this->modAdapter = $curve->getModAdapter(); $this->curve = $curve; $this->x = (string) $x; $this->y = (string) $y; $this->order = $order !== null ? (string) $order : '0'; $this->infinity = (bool) $infinity; if (!$infinity && !$curve->contains($x, $y)) { throw new \RuntimeException("Curve " . $curve . " does not contain point (" . $x . ", " . $y . ")"); } if ($order != null && !$this->mul($order)->isInfinity()) { throw new \RuntimeException("SELF * ORDER MUST EQUAL INFINITY. (" . (string) $this->mul($order) . " found instead)"); } }