

const require_CredoError = require('../../../../error/CredoError.js');
require('../../../../error/index.js');
const require_TypedArrayEncoder = require('../../../../utils/TypedArrayEncoder.js');
require('../../../../utils/index.js');
const require_PublicJwk = require('../../../kms/jwk/PublicJwk.js');
require('../../../kms/index.js');
const require_VerificationMethod = require('./VerificationMethod.js');

//#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 require_VerificationMethod.VerificationMethod({
		id,
		type: VERIFICATION_METHOD_TYPE_X25519_KEY_AGREEMENT_KEY_2019,
		controller,
		publicKeyBase58: require_TypedArrayEncoder.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 require_CredoError.CredoError("verification method is missing publicKeyBase58");
	return require_PublicJwk.PublicJwk.fromPublicKey({
		kty: "OKP",
		crv: "X25519",
		publicKey: require_TypedArrayEncoder.TypedArrayEncoder.fromBase58(verificationMethod.publicKeyBase58)
	});
}

//#endregion
exports.VERIFICATION_METHOD_TYPE_X25519_KEY_AGREEMENT_KEY_2019 = VERIFICATION_METHOD_TYPE_X25519_KEY_AGREEMENT_KEY_2019;
exports.getPublicJwkFrommX25519KeyAgreementKey2019 = getPublicJwkFrommX25519KeyAgreementKey2019;
exports.getX25519KeyAgreementKey2019 = getX25519KeyAgreementKey2019;
exports.isX25519KeyAgreementKey2019 = isX25519KeyAgreementKey2019;