1 | <?php |
||
47 | final class Point |
||
48 | { |
||
49 | /** |
||
50 | * @var \GMP |
||
51 | */ |
||
52 | private $x; |
||
53 | |||
54 | /** |
||
55 | * @var \GMP |
||
56 | */ |
||
57 | private $y; |
||
58 | |||
59 | /** |
||
60 | * @var \GMP |
||
61 | */ |
||
62 | private $order; |
||
63 | |||
64 | /** |
||
65 | * @var bool |
||
66 | */ |
||
67 | private $infinity = false; |
||
68 | |||
69 | /** |
||
70 | * Initialize a new instance. |
||
71 | * |
||
72 | * @param \GMP $x |
||
73 | * @param \GMP $y |
||
74 | * @param \GMP $order |
||
75 | * @param bool $infinity |
||
76 | * |
||
77 | * @throws \RuntimeException when either the curve does not contain the given coordinates or |
||
78 | * when order is not null and P(x, y) * order is not equal to infinity |
||
79 | */ |
||
80 | private function __construct(\GMP $x, \GMP $y, \GMP $order, bool $infinity = false) |
||
87 | |||
88 | /** |
||
89 | * @param \GMP $x |
||
90 | * @param \GMP $y |
||
91 | * @param \GMP|null $order |
||
92 | * |
||
93 | * @return Point |
||
94 | */ |
||
95 | public static function create(\GMP $x, \GMP $y, ?\GMP $order = null): Point |
||
99 | |||
100 | /** |
||
101 | * @return Point |
||
102 | */ |
||
103 | public static function infinity(): Point |
||
109 | |||
110 | /** |
||
111 | * @return bool |
||
112 | */ |
||
113 | public function isInfinity(): bool |
||
117 | |||
118 | /** |
||
119 | * @return \GMP |
||
120 | */ |
||
121 | public function getOrder(): \GMP |
||
125 | |||
126 | /** |
||
127 | * @return \GMP |
||
128 | */ |
||
129 | public function getX(): \GMP |
||
133 | |||
134 | /** |
||
135 | * @return \GMP |
||
136 | */ |
||
137 | public function getY(): \GMP |
||
141 | |||
142 | /** |
||
143 | * @param Point $a |
||
144 | * @param Point $b |
||
145 | * @param int $cond |
||
146 | */ |
||
147 | public static function cswap(Point $a, Point $b, int $cond) |
||
154 | |||
155 | /** |
||
156 | * @param $a |
||
157 | * @param $b |
||
158 | * @param $cond |
||
159 | */ |
||
160 | private static function cswapBoolean(bool &$a, bool &$b, int $cond) |
||
170 | |||
171 | /** |
||
172 | * @param \GMP $sa |
||
173 | * @param \GMP $sb |
||
174 | * @param int $cond |
||
175 | */ |
||
176 | private static function cswapGMP(\GMP &$sa, \GMP &$sb, int $cond) |
||
188 | } |
||
189 |