Conditions | 5 |
Paths | 5 |
Total Lines | 21 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
27 | public function create(string $seed_bin = null):CryptoKeypairInterface{ |
||
28 | |||
29 | if($seed_bin !== null && strlen($seed_bin) !== SODIUM_CRYPTO_SIGN_SEEDBYTES){ |
||
30 | throw new CryptoException('invalid seed length'); |
||
31 | } |
||
32 | |||
33 | $keypair = $seed_bin |
||
34 | ? sodium_crypto_sign_seed_keypair($seed_bin) |
||
35 | : sodium_crypto_sign_keypair(); |
||
36 | |||
37 | $this->keypair = $keypair; |
||
38 | $this->secret = sodium_crypto_sign_secretkey($keypair); |
||
39 | $this->public = sodium_crypto_sign_publickey($keypair); |
||
40 | |||
41 | sodium_memzero($keypair); |
||
42 | |||
43 | if($seed_bin !== null){ |
||
44 | sodium_memzero($seed_bin); |
||
45 | } |
||
46 | |||
47 | return $this; |
||
48 | } |
||
51 |