( expectedKeyType: crypto.KeyObjectType, key: KeyObject )
| 108 | |
| 109 | // Throws an error if the key is not a valid Ed25519 or ECDSA P-256 key of the specified type. |
| 110 | export function checkIsValidKey( |
| 111 | expectedKeyType: crypto.KeyObjectType, |
| 112 | key: KeyObject |
| 113 | ) { |
| 114 | if (key.type !== expectedKeyType) { |
| 115 | throw new Error( |
| 116 | `Expected key type to be ${expectedKeyType}, but it was "${key.type}".` |
| 117 | ); |
| 118 | } |
| 119 | |
| 120 | if (!isAsymmetricKeyTypeSupported(key)) { |
| 121 | throw new Error(`Expected either "Ed25519" or "ECDSA P-256" key.`); |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | export function verifySignature( |
| 126 | data: Uint8Array, |
no test coverage detected