1 | <?php |
||
45 | final class Point |
||
46 | { |
||
47 | /** |
||
48 | * @var \GMP |
||
49 | */ |
||
50 | private $x; |
||
51 | |||
52 | /** |
||
53 | * @var \GMP |
||
54 | */ |
||
55 | private $y; |
||
56 | |||
57 | /** |
||
58 | * @var \GMP |
||
59 | */ |
||
60 | private $order; |
||
61 | |||
62 | /** |
||
63 | * @var bool |
||
64 | */ |
||
65 | private $infinity = false; |
||
66 | |||
67 | /** |
||
68 | * Initialize a new instance. |
||
69 | * |
||
70 | * @param \GMP $x |
||
71 | * @param \GMP $y |
||
72 | * @param \GMP $order |
||
73 | * @param bool $infinity |
||
74 | * |
||
75 | * @throws \RuntimeException when either the curve does not contain the given coordinates or |
||
76 | * when order is not null and P(x, y) * order is not equal to infinity |
||
77 | */ |
||
78 | private function __construct(\GMP $x, \GMP $y, \GMP $order, bool $infinity = false) |
||
85 | |||
86 | /** |
||
87 | * @param \GMP $x |
||
88 | * @param \GMP $y |
||
89 | * @param \GMP|null $order |
||
90 | * |
||
91 | * @return Point |
||
92 | */ |
||
93 | public static function create(\GMP $x, \GMP $y, ?\GMP $order = null): Point |
||
97 | |||
98 | /** |
||
99 | * @return Point |
||
100 | */ |
||
101 | public static function infinity(): Point |
||
107 | |||
108 | /** |
||
109 | * @return bool |
||
110 | */ |
||
111 | public function isInfinity(): bool |
||
115 | |||
116 | /** |
||
117 | * @return \GMP |
||
118 | */ |
||
119 | public function getOrder(): \GMP |
||
123 | |||
124 | /** |
||
125 | * @return \GMP |
||
126 | */ |
||
127 | public function getX(): \GMP |
||
131 | |||
132 | /** |
||
133 | * @return \GMP |
||
134 | */ |
||
135 | public function getY(): \GMP |
||
139 | |||
140 | /** |
||
141 | * @param Point $a |
||
142 | * @param Point $b |
||
143 | * @param int $cond |
||
144 | */ |
||
145 | public static function cswap(Point $a, Point $b, int $cond) |
||
152 | |||
153 | /** |
||
154 | * @param $a |
||
155 | * @param $b |
||
156 | * @param $cond |
||
157 | */ |
||
158 | private static function cswapBoolean(bool &$a, bool &$b, int $cond) |
||
168 | |||
169 | /** |
||
170 | * @param \GMP $sa |
||
171 | * @param \GMP $sb |
||
172 | * @param int $cond |
||
173 | */ |
||
174 | private static function cswapGMP(\GMP &$sa, \GMP &$sb, int $cond) |
||
186 | } |
||
187 |