1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* The MIT License (MIT) |
7
|
|
|
* |
8
|
|
|
* Copyright (c) 2014-2019 Spomky-Labs |
9
|
|
|
* |
10
|
|
|
* This software may be modified and distributed under the terms |
11
|
|
|
* of the MIT license. See the LICENSE file for details. |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace Jose\Component\Core\Util\Ecc; |
15
|
|
|
|
16
|
|
|
use GMP; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* ********************************************************************* |
20
|
|
|
* Copyright (C) 2012 Matyas Danter. |
21
|
|
|
* |
22
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining |
23
|
|
|
* a copy of this software and associated documentation files (the "Software"), |
24
|
|
|
* to deal in the Software without restriction, including without limitation |
25
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense, |
26
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the |
27
|
|
|
* Software is furnished to do so, subject to the following conditions: |
28
|
|
|
* |
29
|
|
|
* The above copyright notice and this permission notice shall be included |
30
|
|
|
* in all copies or substantial portions of the Software. |
31
|
|
|
* |
32
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
33
|
|
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
34
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
35
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES |
36
|
|
|
* OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
37
|
|
|
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
38
|
|
|
* OTHER DEALINGS IN THE SOFTWARE. |
39
|
|
|
* *********************************************************************** |
40
|
|
|
*/ |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @internal |
44
|
|
|
*/ |
45
|
|
|
class PrivateKey |
46
|
|
|
{ |
47
|
|
|
/** |
48
|
|
|
* @var GMP |
49
|
|
|
*/ |
50
|
|
|
private $secret; |
51
|
|
|
|
52
|
|
|
private function __construct(GMP $secret) |
53
|
|
|
{ |
54
|
|
|
$this->secret = $secret; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
public static function create(GMP $secret): self |
58
|
|
|
{ |
59
|
|
|
return new self($secret); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
public function getSecret(): GMP |
63
|
|
|
{ |
64
|
|
|
return $this->secret; |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
|