/** * Initialize from curve point coordinates. * * @param int|string $x X coordinate as a base10 number * @param int|string $y Y coordinate as a base10 number * @param string|null $named_curve Named curve OID * @param int|null $bits Size of <i>p</i> in bits * @return self */ public static function fromCoordinates($x, $y, $named_curve = null, $bits = null) { // if bitsize is not explicitly set, check from supported curves if (!isset($bits) && isset($named_curve)) { $bits = self::_curveSize($named_curve); } $mlen = null; if (isset($bits)) { $mlen = ceil($bits / 8); } $x_os = ECConversion::integerToOctetString(new Integer($x), $mlen)->string(); $y_os = ECConversion::integerToOctetString(new Integer($y), $mlen)->string(); $ec_point = "{$x_os}{$y_os}"; return new self($ec_point, $named_curve); }