1 | <?php |
||
19 | class EcAdapter implements EcAdapterInterface |
||
20 | { |
||
21 | /** |
||
22 | * @var Math |
||
23 | */ |
||
24 | private $math; |
||
25 | |||
26 | /** |
||
27 | * @var GeneratorPoint |
||
28 | */ |
||
29 | private $generator; |
||
30 | |||
31 | /** |
||
32 | * @var resource |
||
33 | */ |
||
34 | private $context; |
||
35 | |||
36 | /** |
||
37 | * @param Math $math |
||
38 | * @param GeneratorPoint $generator |
||
39 | * @param resource $secp256k1_context_t |
||
40 | */ |
||
41 | 33 | public function __construct(Math $math, GeneratorPoint $generator, $secp256k1_context_t) |
|
50 | |||
51 | /** |
||
52 | * @return Math |
||
53 | */ |
||
54 | 924 | public function getMath() |
|
58 | |||
59 | /** |
||
60 | * @return GeneratorPoint |
||
61 | */ |
||
62 | 69 | public function getGenerator() |
|
66 | |||
67 | /** |
||
68 | * @param Buffer $privateKey |
||
69 | * @return bool |
||
70 | */ |
||
71 | 234 | public function validatePrivateKey(Buffer $privateKey) |
|
75 | |||
76 | /** |
||
77 | * @param int|string $element |
||
78 | * @param bool $half |
||
79 | * @return bool |
||
80 | */ |
||
81 | 12 | public function validateSignatureElement($element, $half = false) |
|
91 | |||
92 | /** |
||
93 | * @param int|string $int |
||
94 | * @param bool|false $compressed |
||
95 | * @return PrivateKey |
||
96 | */ |
||
97 | 228 | public function getPrivateKey($int, $compressed = false) |
|
101 | |||
102 | /** |
||
103 | * @return resource |
||
104 | */ |
||
105 | 432 | public function getContext() |
|
109 | |||
110 | /** |
||
111 | * @param Buffer $msg32 |
||
112 | * @param PrivateKey $privateKey |
||
113 | * @return Signature |
||
114 | */ |
||
115 | 48 | private function doSign(Buffer $msg32, PrivateKey $privateKey) |
|
134 | |||
135 | /** |
||
136 | * @param Buffer $msg32 |
||
137 | * @param PrivateKeyInterface $privateKey |
||
138 | * @param RbgInterface|null $rbg |
||
139 | * @return Signature |
||
140 | */ |
||
141 | 48 | public function sign(Buffer $msg32, PrivateKeyInterface $privateKey, RbgInterface $rbg = null) |
|
146 | |||
147 | /** |
||
148 | * @param Buffer $msg32 |
||
149 | * @param PublicKey $publicKey |
||
150 | * @param Signature $signature |
||
151 | * @return bool |
||
152 | */ |
||
153 | 18 | private function doVerify(Buffer $msg32, PublicKey $publicKey, Signature $signature) |
|
157 | |||
158 | /** |
||
159 | * @param Buffer $msg32 |
||
160 | * @param PublicKeyInterface $publicKey |
||
161 | * @param SignatureInterface $signature |
||
162 | * @return bool |
||
163 | */ |
||
164 | 18 | public function verify(Buffer $msg32, PublicKeyInterface $publicKey, SignatureInterface $signature) |
|
170 | |||
171 | /** |
||
172 | * @param Buffer $msg32 |
||
173 | * @param CompactSignature $compactSig |
||
174 | * @return PublicKey |
||
175 | */ |
||
176 | 21 | private function doRecover(Buffer $msg32, CompactSignature $compactSig) |
|
188 | |||
189 | /** |
||
190 | * @param Buffer $msg32 |
||
191 | * @param CompactSignatureInterface $compactSig |
||
192 | * @return PublicKey |
||
193 | */ |
||
194 | 21 | public function recover(Buffer $msg32, CompactSignatureInterface $compactSig) |
|
199 | |||
200 | /** |
||
201 | * @param Buffer $msg32 |
||
202 | * @param PrivateKey $privateKey |
||
203 | * @return CompactSignature |
||
204 | */ |
||
205 | 18 | private function doSignCompact(Buffer $msg32, PrivateKey $privateKey) |
|
227 | |||
228 | /** |
||
229 | * @param Buffer $msg32 |
||
230 | * @param PrivateKeyInterface $privateKey |
||
231 | * @param RbgInterface|null $rbg |
||
232 | * @return CompactSignatureInterface |
||
233 | */ |
||
234 | 18 | public function signCompact(Buffer $msg32, PrivateKeyInterface $privateKey, RbgInterface $rbg = null) |
|
239 | } |
||
240 |
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.