| Conditions | 2 |
| Paths | 2 |
| Total Lines | 13 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 47 | public function createFromSecret(string $secret_bin):CryptoKeyInterface{ |
||
| 48 | |||
| 49 | if(strlen($secret_bin) !== SODIUM_CRYPTO_BOX_SECRETKEYBYTES){ |
||
| 50 | throw new CryptoException('invalid secret key length'); |
||
| 51 | } |
||
| 52 | |||
| 53 | $this->secret = $secret_bin; |
||
| 54 | $this->public = sodium_crypto_box_publickey_from_secretkey($this->secret); |
||
| 55 | $this->keypair = $this->secret.$this->secret; |
||
| 56 | |||
| 57 | sodium_memzero($secret_bin); |
||
| 58 | |||
| 59 | return $this; |
||
| 60 | } |
||
| 63 |