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