public static function fromJWK(JWK $jwk, Header $header) { $alg = JWA::deriveAlgorithmName($header, $jwk); if (!array_key_exists($alg, self::MAP_ALGO_TO_CLASS)) { throw new \UnexpectedValueException("Unsupported algorithm '{$alg}'."); } $cls = self::MAP_ALGO_TO_CLASS[$alg]; if ($jwk->has(...ECPrivateKeyJWK::MANAGED_PARAMS)) { return $cls::fromPrivateKey(ECPrivateKeyJWK::fromJWK($jwk)); } return $cls::fromPublicKey(ECPublicKeyJWK::fromJWK($jwk)); }