| Total Complexity | 6 |
| Total Lines | 67 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php declare(strict_types=1); |
||
| 7 | final class Keypair |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * Secret key |
||
| 11 | * |
||
| 12 | * @var string |
||
| 13 | */ |
||
| 14 | private $secretKey; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * Public Key |
||
| 18 | * |
||
| 19 | * @var string |
||
| 20 | */ |
||
| 21 | private $publicKey; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * Constructor |
||
| 25 | * |
||
| 26 | * @param string $secret |
||
| 27 | * @param string $public |
||
| 28 | */ |
||
| 29 | public function __construct(string $secretKey, string $publicKey) |
||
| 30 | { |
||
| 31 | if (\strlen($secretKey) % 16 !== 0) { |
||
| 32 | throw new InvalidArgumentException(sprintf("Secret key should be a multiple of %d bytes.", 16)); |
||
| 33 | } |
||
| 34 | |||
| 35 | $this->secretKey = $secretKey; |
||
| 36 | |||
| 37 | if (\strlen($publicKey) % 4 !== 0) { |
||
| 38 | throw new InvalidArgumentException(sprintf("Public key should be a multiple of %d bytes.", 4)); |
||
| 39 | } |
||
| 40 | |||
| 41 | $this->publicKey = $publicKey; |
||
| 42 | } |
||
| 43 | |||
| 44 | /** |
||
| 45 | * Returns the public key |
||
| 46 | * |
||
| 47 | * @return string|null |
||
| 48 | */ |
||
| 49 | public function getPublicKey() :? string |
||
| 50 | { |
||
| 51 | return $this->publicKey; |
||
| 52 | } |
||
| 53 | |||
| 54 | /** |
||
| 55 | * Returns the secret key |
||
| 56 | * |
||
| 57 | * @return string|null |
||
| 58 | */ |
||
| 59 | public function getSecretKey() :? string |
||
| 60 | { |
||
| 61 | return $this->secretKey; |
||
| 62 | } |
||
| 63 | |||
| 64 | /** |
||
| 65 | * Returns the sodium keypair |
||
| 66 | * |
||
| 67 | * @return string |
||
| 68 | */ |
||
| 69 | public function getSodiumKeypair() |
||
| 74 | ); |
||
| 75 | } |
||
| 76 | } |
||
| 77 |