|
1
|
|
|
<?php |
|
2
|
|
|
declare(strict_types=1); |
|
3
|
|
|
|
|
4
|
|
|
namespace Mdanter\Ecc\Crypto\Signature; |
|
5
|
|
|
|
|
6
|
|
|
/** |
|
7
|
|
|
* ********************************************************************* |
|
8
|
|
|
* Copyright (C) 2012 Matyas Danter |
|
9
|
|
|
* |
|
10
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining |
|
11
|
|
|
* a copy of this software and associated documentation files (the "Software"), |
|
12
|
|
|
* to deal in the Software without restriction, including without limitation |
|
13
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense, |
|
14
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the |
|
15
|
|
|
* Software is furnished to do so, subject to the following conditions: |
|
16
|
|
|
* |
|
17
|
|
|
* The above copyright notice and this permission notice shall be included |
|
18
|
|
|
* in all copies or substantial portions of the Software. |
|
19
|
|
|
* |
|
20
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
|
21
|
|
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
22
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
|
23
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES |
|
24
|
|
|
* OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
|
25
|
|
|
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
|
26
|
|
|
* OTHER DEALINGS IN THE SOFTWARE. |
|
27
|
|
|
* *********************************************************************** |
|
28
|
|
|
*/ |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* Plain Old PHP Object that stores the signature r,s for ECDSA |
|
32
|
|
|
*/ |
|
33
|
|
|
class Signature implements SignatureInterface |
|
34
|
|
|
{ |
|
35
|
|
|
/** |
|
36
|
|
|
* @var \GMP |
|
37
|
|
|
*/ |
|
38
|
|
|
private $r; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* |
|
42
|
|
|
* @var \GMP |
|
43
|
|
|
*/ |
|
44
|
|
|
private $s; |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Initialize a new instance with values |
|
48
|
|
|
* |
|
49
|
|
|
* @param \GMP $r |
|
50
|
|
|
* @param \GMP $s |
|
51
|
|
|
*/ |
|
52
|
|
|
public function __construct(\GMP $r, \GMP $s) |
|
53
|
|
|
{ |
|
54
|
|
|
$this->r = $r; |
|
55
|
|
|
$this->s = $s; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* {@inheritDoc} |
|
60
|
|
|
* @see \Mdanter\Ecc\Crypto\Signature\SignatureInterface::getR() |
|
61
|
|
|
*/ |
|
62
|
|
|
public function getR(): \GMP |
|
63
|
|
|
{ |
|
64
|
|
|
return $this->r; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* {@inheritDoc} |
|
69
|
|
|
* @see \Mdanter\Ecc\Crypto\Signature\SignatureInterface::getS() |
|
70
|
|
|
*/ |
|
71
|
|
|
public function getS(): \GMP |
|
72
|
|
|
{ |
|
73
|
|
|
return $this->s; |
|
74
|
|
|
} |
|
75
|
|
|
} |
|
76
|
|
|
|