MCPcopy Create free account
hub / github.com/WICG/webpackage / checkIsValidKey

Function checkIsValidKey

js/sign/src/utils/utils.ts:110–123  ·  view source on GitHub ↗
(
  expectedKeyType: crypto.KeyObjectType,
  key: KeyObject
)

Source from the content-addressed store, hash-verified

108
109// Throws an error if the key is not a valid Ed25519 or ECDSA P-256 key of the specified type.
110export 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
125export function verifySignature(
126 data: Uint8Array,

Callers 2

constructorMethod · 0.90

Calls 1

Tested by

no test coverage detected