2022-02-23 02:48:51 +00:00
|
|
|
<?php
|
|
|
|
|
2022-06-04 15:31:21 +00:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2022-02-23 02:48:51 +00:00
|
|
|
namespace phpseclib3\Tests\Unit\Crypt\EC;
|
|
|
|
|
|
|
|
use phpseclib3\Common\Functions\Strings;
|
|
|
|
use phpseclib3\Crypt\EC\Curves\Ed448;
|
2022-08-18 13:05:57 +00:00
|
|
|
use phpseclib3\Exception\UnexpectedValueException;
|
2022-02-23 02:48:51 +00:00
|
|
|
|
|
|
|
class Ed448PrivateKey
|
|
|
|
{
|
2022-07-09 02:42:28 +00:00
|
|
|
public static function load($key, ?string $password = null): array
|
2022-02-23 02:48:51 +00:00
|
|
|
{
|
|
|
|
if (!Strings::is_stringable($key)) {
|
2022-08-18 13:05:57 +00:00
|
|
|
throw new UnexpectedValueException('Key should be a string - not a ' . gettype($key));
|
2022-02-23 02:48:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$components = ['curve' => new Ed448()];
|
2022-07-28 14:23:01 +00:00
|
|
|
$arr = $components['curve']->extractSecret($key);
|
|
|
|
$components['dA'] = $arr['dA'];
|
|
|
|
$components['secret'] = $arr['secret'];
|
2022-02-23 02:48:51 +00:00
|
|
|
$components['QA'] = $components['curve']->multiplyPoint($components['curve']->getBasePoint(), $components['dA']);
|
|
|
|
|
|
|
|
return $components;
|
|
|
|
}
|
|
|
|
}
|