@credo-ts/core
Version:
<p align="center"> <br /> <img alt="Credo Logo" src="https://github.com/openwallet-foundation/credo-ts/blob/c7886cb8377ceb8ee4efe8d264211e561a75072d/images/credo-logo.png" height="250px" /> </p> <h1 align="center"><b>Credo - Core</b></h1
20 lines (19 loc) • 892 B
JavaScript
import { TypedArrayEncoder } from "../../utils/TypedArrayEncoder.mjs";
import "../../utils/index.mjs";
import { KeyManagementError } from "./error/KeyManagementError.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 compressedPublicKey = publicJwk.compressedPublicKey;
if (compressedPublicKey) return TypedArrayEncoder.toBase58(compressedPublicKey.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 explicit key ids were added.");
return TypedArrayEncoder.toBase58(publicKey.publicKey);
}
//#endregion
export { legacyKeyIdFromPublicJwk };
//# sourceMappingURL=legacy.mjs.map