

const require_CredoError = require('../../../../error/CredoError.js');
require('../../../../error/index.js');
const require_PublicJwk = require('../../../kms/jwk/PublicJwk.js');
require('../../../kms/index.js');

//#region src/modules/dids/domain/verificationMethod/Multikey.ts
const VERIFICATION_METHOD_TYPE_MULTIKEY = "Multikey";
/**
* Get a Multikey verification method.
*/
function getMultikey({ did, publicJwk, verificationMethodId }) {
	if (!verificationMethodId) verificationMethodId = `${did}#${publicJwk.fingerprint}`;
	return {
		id: verificationMethodId,
		type: VERIFICATION_METHOD_TYPE_MULTIKEY,
		controller: did,
		publicKeyMultibase: publicJwk.fingerprint
	};
}
/**
* Check whether a verification method is a Multikey verification method.
*/
function isMultikey(verificationMethod) {
	return verificationMethod.type === VERIFICATION_METHOD_TYPE_MULTIKEY;
}
/**
* Get a public jwk from a Multikey verification method.
*/
function getPublicJwkFromMultikey(verificationMethod) {
	if (!verificationMethod.publicKeyMultibase) throw new require_CredoError.CredoError(`Missing publicKeyMultibase on verification method with type ${VERIFICATION_METHOD_TYPE_MULTIKEY}`);
	return require_PublicJwk.PublicJwk.fromFingerprint(verificationMethod.publicKeyMultibase);
}

//#endregion
exports.VERIFICATION_METHOD_TYPE_MULTIKEY = VERIFICATION_METHOD_TYPE_MULTIKEY;
exports.getMultikey = getMultikey;
exports.getPublicJwkFromMultikey = getPublicJwkFromMultikey;
exports.isMultikey = isMultikey;