Completed
Push — master ( c57370...c02a5b )
by Charles
03:10
created

Keypair::getPublicKey()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace ncryptf;
4
5
final class Keypair
6
{
7
    /**
8
     * Secret key
9
     *
10
     * @var string
11
     */
12
    private $secretKey;
13
14
    /**
15
     * Public Key
16
     *
17
     * @var string
18
     */
19
    private $publicKey;
20
21
    /**
22
     * Constructor
23
     *
24
     * @param string $secret
25
     * @param string $public
26
     */
27
    public function __construct(string $secretKey, string $publicKey)
28
    {
29
        $this->secretKey = $secretKey;
30
        $this->publicKey = $publicKey;
31
    }
32
33
    /**
34
     * Returns the public key
35
     *
36
     * @return string|null
37
     */
38
    public function getPublicKey() :? string
39
    {
40
        return $this->publicKey;
41
    }
42
43
    /**
44
     * Returns the secret key
45
     *
46
     * @return string|null
47
     */
48
    public function getSecretKey() :? string
49
    {
50
        return $this->secretKey;
51
    }
52
53
    /**
54
     * Returns the sodium keypair
55
     * 
56
     * @return string
57
     */
58
    public function getSodiumKeypair()
59
    {
60
        return \sodium_crypto_box_keypair_from_secretkey_and_publickey(
61
            $this->getSecretKey(),
62
            $this->getPublicKey()
63
        );
64
    }
65
}
66