1 | <?php |
||
13 | class PublicKey extends Key implements PublicKeyInterface, \Mdanter\Ecc\Crypto\Key\PublicKeyInterface |
||
14 | { |
||
15 | /** |
||
16 | * @var EcAdapter |
||
17 | */ |
||
18 | private $ecAdapter; |
||
19 | |||
20 | /** |
||
21 | * @var PointInterface |
||
22 | */ |
||
23 | private $point; |
||
24 | |||
25 | /** |
||
26 | * @var bool |
||
27 | */ |
||
28 | private $compressed; |
||
29 | |||
30 | /** |
||
31 | * @param EcAdapter $ecAdapter |
||
32 | * @param PointInterface $point |
||
33 | * @param bool $compressed |
||
34 | */ |
||
35 | 255 | public function __construct( |
|
36 | EcAdapter $ecAdapter, |
||
37 | PointInterface $point, |
||
38 | $compressed = false |
||
39 | ) { |
||
40 | 255 | if (false === is_bool($compressed)) { |
|
41 | throw new \InvalidArgumentException('PublicKey: Compressed must be a boolean'); |
||
42 | } |
||
43 | 255 | $this->ecAdapter = $ecAdapter; |
|
44 | 255 | $this->point = $point; |
|
45 | 255 | $this->compressed = $compressed; |
|
46 | 255 | } |
|
47 | |||
48 | /** |
||
49 | * @return \Mdanter\Ecc\Primitives\GeneratorPoint |
||
50 | */ |
||
51 | 47 | public function getGenerator() |
|
55 | |||
56 | /** |
||
57 | * @return \Mdanter\Ecc\Primitives\CurveFpInterface |
||
58 | */ |
||
59 | public function getCurve() |
||
63 | |||
64 | /** |
||
65 | * @return PointInterface |
||
66 | */ |
||
67 | 209 | public function getPoint() |
|
71 | |||
72 | /** |
||
73 | * @param BufferInterface $msg32 |
||
74 | * @param SignatureInterface $signature |
||
75 | * @return bool |
||
76 | */ |
||
77 | public function verify(BufferInterface $msg32, SignatureInterface $signature) |
||
81 | |||
82 | /** |
||
83 | * @param \GMP $tweak |
||
84 | * @return PublicKeyInterface |
||
85 | */ |
||
86 | 4 | public function tweakAdd(\GMP $tweak) |
|
92 | |||
93 | /** |
||
94 | * @param \GMP $tweak |
||
95 | * @return PublicKeyInterface |
||
96 | */ |
||
97 | 2 | public function tweakMul(\GMP $tweak) |
|
102 | |||
103 | /** |
||
104 | * @param BufferInterface $publicKey |
||
105 | * @return bool |
||
106 | */ |
||
107 | 48 | public static function isCompressedOrUncompressed(BufferInterface $publicKey) |
|
132 | |||
133 | /** |
||
134 | * @return bool |
||
135 | */ |
||
136 | 241 | public function isCompressed() |
|
140 | |||
141 | /** |
||
142 | * @return BufferInterface |
||
143 | */ |
||
144 | 200 | public function getBuffer() |
|
148 | } |
||
149 |