1 | <?php |
||
18 | class PrivateKeyFactory |
||
19 | { |
||
20 | /** |
||
21 | * @var bool |
||
22 | */ |
||
23 | private $compressed; |
||
24 | |||
25 | /** |
||
26 | * @var PrivateKeySerializerInterface |
||
27 | */ |
||
28 | private $privSerializer; |
||
29 | |||
30 | /** |
||
31 | * @var WifPrivateKeySerializer |
||
32 | */ |
||
33 | private $wifSerializer; |
||
34 | |||
35 | /** |
||
36 | * PrivateKeyFactory constructor. |
||
37 | * @param bool $compressed |
||
38 | * @param EcAdapterInterface $ecAdapter |
||
39 | */ |
||
40 | 151 | public function __construct(bool $compressed, EcAdapterInterface $ecAdapter = null) |
|
47 | |||
48 | /** |
||
49 | * @param EcAdapterInterface|null $ecAdapter |
||
50 | * @return PrivateKeyFactory |
||
51 | */ |
||
52 | 33 | public static function uncompressed(EcAdapterInterface $ecAdapter = null): PrivateKeyFactory |
|
56 | |||
57 | /** |
||
58 | * @param EcAdapterInterface|null $ecAdapter |
||
59 | * @return PrivateKeyFactory |
||
60 | */ |
||
61 | 102 | public static function compressed(EcAdapterInterface $ecAdapter = null): PrivateKeyFactory |
|
65 | |||
66 | /** |
||
67 | * @return bool |
||
68 | */ |
||
69 | 2 | public function isCompressed(): bool |
|
73 | |||
74 | /** |
||
75 | * @param Random $random |
||
76 | * @return PrivateKeyInterface |
||
77 | * @throws \BitWasp\Bitcoin\Exceptions\RandomBytesFailure |
||
78 | */ |
||
79 | 15 | public function generate(Random $random): PrivateKeyInterface |
|
85 | |||
86 | /** |
||
87 | * @param string $hex |
||
88 | * @return PrivateKeyInterface |
||
89 | * @throws \Exception |
||
90 | */ |
||
91 | 47 | public function fromHex(string $hex): PrivateKeyInterface |
|
95 | |||
96 | /** |
||
97 | * @param BufferInterface $buffer |
||
98 | * @return PrivateKeyInterface |
||
99 | */ |
||
100 | 108 | public function fromBuffer(BufferInterface $buffer): PrivateKeyInterface |
|
107 | |||
108 | /** |
||
109 | * @param string $wif |
||
110 | * @param NetworkInterface $network |
||
111 | * @return PrivateKeyInterface |
||
112 | * @throws \BitWasp\Bitcoin\Exceptions\Base58ChecksumFailure |
||
113 | * @throws \BitWasp\Bitcoin\Exceptions\InvalidPrivateKey |
||
114 | * @throws \Exception |
||
115 | */ |
||
116 | 8 | public function fromWif(string $wif, NetworkInterface $network = null): PrivateKeyInterface |
|
120 | } |
||
121 |