@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
41 lines (40 loc) • 1.78 kB
JavaScript
import { CredoError } from "../../../../error/CredoError.mjs";
import "../../../../error/index.mjs";
import { TypedArrayEncoder } from "../../../../utils/TypedArrayEncoder.mjs";
import "../../../../utils/index.mjs";
import { PublicJwk } from "../../../kms/jwk/PublicJwk.mjs";
import "../../../kms/index.mjs";
import { VerificationMethod } from "./VerificationMethod.mjs";
//#region src/modules/dids/domain/verificationMethod/X25519KeyAgreementKey2019.ts
const VERIFICATION_METHOD_TYPE_X25519_KEY_AGREEMENT_KEY_2019 = "X25519KeyAgreementKey2019";
/**
* Get a X25519KeyAgreementKey2019 verification method.
*/
function getX25519KeyAgreementKey2019({ publicJwk, id, controller }) {
return new VerificationMethod({
id,
type: VERIFICATION_METHOD_TYPE_X25519_KEY_AGREEMENT_KEY_2019,
controller,
publicKeyBase58: TypedArrayEncoder.toBase58(publicJwk.publicKey.publicKey)
});
}
/**
* Check whether a verification method is a X25519KeyAgreementKey2019 verification method.
*/
function isX25519KeyAgreementKey2019(verificationMethod) {
return verificationMethod.type === VERIFICATION_METHOD_TYPE_X25519_KEY_AGREEMENT_KEY_2019;
}
/**
* Get a key from a X25519KeyAgreementKey2019 verification method.
*/
function getPublicJwkFrommX25519KeyAgreementKey2019(verificationMethod) {
if (!verificationMethod.publicKeyBase58) throw new CredoError("verification method is missing publicKeyBase58");
return PublicJwk.fromPublicKey({
kty: "OKP",
crv: "X25519",
publicKey: TypedArrayEncoder.fromBase58(verificationMethod.publicKeyBase58)
});
}
//#endregion
export { VERIFICATION_METHOD_TYPE_X25519_KEY_AGREEMENT_KEY_2019, getPublicJwkFrommX25519KeyAgreementKey2019, getX25519KeyAgreementKey2019, isX25519KeyAgreementKey2019 };
//# sourceMappingURL=X25519KeyAgreementKey2019.mjs.map