1 | <?php |
||
22 | class EcAdapter implements EcAdapterInterface |
||
23 | { |
||
24 | /** |
||
25 | * @var Math |
||
26 | */ |
||
27 | private $math; |
||
28 | |||
29 | /** |
||
30 | * @var GeneratorPoint |
||
31 | */ |
||
32 | private $generator; |
||
33 | |||
34 | /** |
||
35 | * @var resource |
||
36 | */ |
||
37 | private $context; |
||
38 | |||
39 | /** |
||
40 | * @param Math $math |
||
41 | * @param GeneratorPoint $generator |
||
42 | * @param resource $secp256k1_context_t |
||
43 | */ |
||
44 | 2 | public function __construct(Math $math, GeneratorPoint $generator, $secp256k1_context_t) |
|
53 | |||
54 | /** |
||
55 | * @return Math |
||
56 | */ |
||
57 | 1526 | public function getMath(): Math |
|
61 | |||
62 | /** |
||
63 | * @return GeneratorPoint |
||
64 | */ |
||
65 | 74 | public function getGenerator() |
|
69 | |||
70 | /** |
||
71 | * @param BufferInterface $privateKey |
||
72 | * @return bool |
||
73 | */ |
||
74 | 82 | public function validatePrivateKey(BufferInterface $privateKey): bool |
|
78 | |||
79 | /** |
||
80 | * @param \GMP $element |
||
81 | * @param bool $half |
||
82 | * @return bool |
||
83 | */ |
||
84 | 4 | public function validateSignatureElement(\GMP $element, bool $half = false): bool |
|
94 | |||
95 | /** |
||
96 | * @param \GMP $int |
||
97 | * @param bool $compressed |
||
98 | * @return PrivateKeyInterface |
||
99 | */ |
||
100 | 76 | public function getPrivateKey(\GMP $int, bool $compressed = false): PrivateKeyInterface |
|
104 | |||
105 | /** |
||
106 | * @return resource |
||
107 | */ |
||
108 | 336 | public function getContext() |
|
112 | |||
113 | /** |
||
114 | * @param BufferInterface $msg32 |
||
115 | * @param PrivateKey $privateKey |
||
116 | * @return Signature |
||
117 | */ |
||
118 | 66 | private function doSign(BufferInterface $msg32, PrivateKey $privateKey): Signature |
|
137 | |||
138 | /** |
||
139 | * @param BufferInterface $msg32 |
||
140 | * @param PrivateKeyInterface $privateKey |
||
141 | * @param RbgInterface|null $rbg |
||
142 | * @return SignatureInterface |
||
143 | */ |
||
144 | 66 | public function sign(BufferInterface $msg32, PrivateKeyInterface $privateKey, RbgInterface $rbg = null): SignatureInterface |
|
149 | |||
150 | /** |
||
151 | * @param BufferInterface $msg32 |
||
152 | * @param PublicKey $publicKey |
||
153 | * @param Signature $signature |
||
154 | * @return bool |
||
155 | */ |
||
156 | 181 | private function doVerify(BufferInterface $msg32, PublicKey $publicKey, Signature $signature): bool |
|
160 | |||
161 | /** |
||
162 | * @param BufferInterface $msg32 |
||
163 | * @param PublicKeyInterface $publicKey |
||
164 | * @param SignatureInterface $signature |
||
165 | * @return bool |
||
166 | */ |
||
167 | 181 | public function verify(BufferInterface $msg32, PublicKeyInterface $publicKey, SignatureInterface $signature): bool |
|
173 | |||
174 | /** |
||
175 | * @param BufferInterface $msg32 |
||
176 | * @param CompactSignature $compactSig |
||
177 | * @return PublicKey |
||
178 | */ |
||
179 | 6 | private function doRecover(BufferInterface $msg32, CompactSignature $compactSig): PublicKey |
|
191 | |||
192 | /** |
||
193 | * @param BufferInterface $msg32 |
||
194 | * @param CompactSignatureInterface $compactSig |
||
195 | * @return PublicKeyInterface |
||
196 | */ |
||
197 | 6 | public function recover(BufferInterface $msg32, CompactSignatureInterface $compactSig): PublicKeyInterface |
|
202 | |||
203 | /** |
||
204 | * @param BufferInterface $msg32 |
||
205 | * @param PrivateKey $privateKey |
||
206 | * @return CompactSignature |
||
207 | */ |
||
208 | 5 | private function doSignCompact(BufferInterface $msg32, PrivateKey $privateKey): CompactSignature |
|
230 | |||
231 | /** |
||
232 | * @param BufferInterface $msg32 |
||
233 | * @param PrivateKeyInterface $privateKey |
||
234 | * @param RbgInterface|null $rbg |
||
235 | * @return CompactSignatureInterface |
||
236 | */ |
||
237 | 5 | public function signCompact(BufferInterface $msg32, PrivateKeyInterface $privateKey, RbgInterface $rbg = null): CompactSignatureInterface |
|
242 | } |
||
243 |
This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.
Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.