1 | <?php |
||
14 | class PublicKey extends Key implements PublicKeyInterface |
||
15 | { |
||
16 | /** |
||
17 | * @var EcAdapter |
||
18 | */ |
||
19 | private $ecAdapter; |
||
20 | |||
21 | /** |
||
22 | * @var PointInterface |
||
23 | */ |
||
24 | private $point; |
||
25 | |||
26 | /** |
||
27 | * @var bool |
||
28 | */ |
||
29 | private $compressed; |
||
30 | |||
31 | /** |
||
32 | * @param EcAdapter $ecAdapter |
||
33 | * @param PointInterface $point |
||
34 | * @param bool $compressed |
||
35 | */ |
||
36 | 255 | public function __construct( |
|
48 | |||
49 | /** |
||
50 | * @return PointInterface |
||
51 | */ |
||
52 | 209 | public function getPoint() |
|
56 | |||
57 | /** |
||
58 | * @param BufferInterface $msg32 |
||
59 | * @param SignatureInterface $signature |
||
60 | * @return bool |
||
61 | */ |
||
62 | public function verify(BufferInterface $msg32, SignatureInterface $signature) |
||
66 | |||
67 | /** |
||
68 | * @param \GMP $tweak |
||
69 | * @return PublicKeyInterface |
||
70 | */ |
||
71 | 4 | public function tweakAdd(\GMP $tweak) |
|
72 | { |
||
73 | 4 | $offset = $this->ecAdapter->getGenerator()->mul($tweak); |
|
74 | 4 | $newPoint = $this->point->add($offset); |
|
75 | 4 | return $this->ecAdapter->getPublicKey($newPoint, $this->compressed); |
|
76 | } |
||
77 | |||
78 | /** |
||
79 | * @param \GMP $tweak |
||
80 | * @return PublicKeyInterface |
||
81 | */ |
||
82 | 2 | public function tweakMul(\GMP $tweak) |
|
87 | |||
88 | /** |
||
89 | * @param BufferInterface $publicKey |
||
90 | * @return bool |
||
91 | */ |
||
92 | 48 | public static function isCompressedOrUncompressed(BufferInterface $publicKey) |
|
116 | |||
117 | /** |
||
118 | * @return bool |
||
119 | */ |
||
120 | 241 | public function isCompressed() |
|
124 | |||
125 | /** |
||
126 | * @return BufferInterface |
||
127 | */ |
||
128 | 200 | public function getBuffer() |
|
132 | } |
||
133 |