1 | <?php |
||
18 | class EcAdapter implements EcAdapterInterface |
||
19 | { |
||
20 | /** |
||
21 | * @var Math |
||
22 | */ |
||
23 | private $math; |
||
24 | |||
25 | /** |
||
26 | * @var \GMP |
||
27 | */ |
||
28 | private $order; |
||
29 | |||
30 | /** |
||
31 | * @var GeneratorPoint |
||
32 | */ |
||
33 | private $generator; |
||
34 | |||
35 | /** |
||
36 | * @var resource |
||
37 | */ |
||
38 | private $context; |
||
39 | |||
40 | /** |
||
41 | * @param Math $math |
||
42 | * @param GeneratorPoint $generator |
||
43 | * @param resource $secp256k1_context_t |
||
44 | */ |
||
45 | 2 | public function __construct(Math $math, GeneratorPoint $generator, $secp256k1_context_t) |
|
56 | |||
57 | /** |
||
58 | * @return Math |
||
59 | */ |
||
60 | 1294 | public function getMath(): Math |
|
64 | |||
65 | /** |
||
66 | * @return \GMP |
||
67 | */ |
||
68 | 7 | public function getOrder(): \GMP |
|
72 | |||
73 | /** |
||
74 | * @return GeneratorPoint |
||
75 | */ |
||
76 | 5 | public function getGenerator() |
|
80 | |||
81 | /** |
||
82 | * @param BufferInterface $privateKey |
||
83 | * @return bool |
||
84 | */ |
||
85 | 82 | public function validatePrivateKey(BufferInterface $privateKey): bool |
|
89 | |||
90 | /** |
||
91 | * @param \GMP $element |
||
92 | * @param bool $half |
||
93 | * @return bool |
||
94 | */ |
||
95 | 4 | public function validateSignatureElement(\GMP $element, bool $half = false): bool |
|
105 | |||
106 | /** |
||
107 | * @param \GMP $int |
||
108 | * @param bool $compressed |
||
109 | * @return PrivateKeyInterface |
||
110 | */ |
||
111 | 76 | public function getPrivateKey(\GMP $int, bool $compressed = false): PrivateKeyInterface |
|
115 | |||
116 | /** |
||
117 | * @return resource |
||
118 | */ |
||
119 | 335 | public function getContext() |
|
123 | |||
124 | /** |
||
125 | * @param BufferInterface $msg32 |
||
126 | * @param CompactSignature $compactSig |
||
127 | * @return PublicKey |
||
128 | */ |
||
129 | 6 | private function doRecover(BufferInterface $msg32, CompactSignature $compactSig): PublicKey |
|
141 | |||
142 | /** |
||
143 | * @param BufferInterface $msg32 |
||
144 | * @param CompactSignatureInterface $compactSig |
||
145 | * @return PublicKeyInterface |
||
146 | */ |
||
147 | 6 | public function recover(BufferInterface $msg32, CompactSignatureInterface $compactSig): PublicKeyInterface |
|
152 | } |
||
153 |