

import { KeyManagementError } from "./error/KeyManagementError.mjs";
import { TypedArrayEncoder } from "../../utils/TypedArrayEncoder.mjs";
import "../../utils/index.mjs";
import "./jwk/index.mjs";

//#region src/modules/kms/legacy.ts
/**
* Returns the legacy key id based on the public key encoded as base58
*
* This is what was has been used by askar
*/
function legacyKeyIdFromPublicJwk(publicJwk) {
	const compresedPublicKey = publicJwk.compressedPublicKey;
	if (compresedPublicKey) return TypedArrayEncoder.toBase58(compresedPublicKey.publicKey);
	const publicKey = publicJwk.publicKey;
	if (publicKey.kty === "RSA") throw new KeyManagementError("Unable to derive legacy key id from RSA key. Support for RSA keys was only added after explit key ids were added.");
	return TypedArrayEncoder.toBase58(publicKey.publicKey);
}

//#endregion
export { legacyKeyIdFromPublicJwk };
//# sourceMappingURL=legacy.mjs.map