| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Cose\Algorithm\Signature\EdDSA; |
| 6 | |
| 7 | use Cose\Key\Key; |
| 8 | |
| 9 | final class Ed256 extends EdDSA |
| 10 | { |
| 11 | public const ID = -260; |
| 12 | |
| 13 | public static function create(): self |
| 14 | { |
| 15 | return new self(); |
| 16 | } |
| 17 | |
| 18 | public static function identifier(): int |
| 19 | { |
| 20 | return self::ID; |
| 21 | } |
| 22 | |
| 23 | public function sign(string $data, Key $key): string |
| 24 | { |
| 25 | $hashedData = hash('sha256', $data, true); |
| 26 | |
| 27 | return parent::sign($hashedData, $key); |
| 28 | } |
| 29 | |
| 30 | public function verify(string $data, Key $key, string $signature): bool |
| 31 | { |
| 32 | $hashedData = hash('sha256', $data, true); |
| 33 | |
| 34 | return parent::verify($hashedData, $key, $signature); |
| 35 | } |
| 36 | } |