

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/Ed25519VerificationKey2018.ts
const VERIFICATION_METHOD_TYPE_ED25519_VERIFICATION_KEY_2018 = "Ed25519VerificationKey2018";
/**
* Get a Ed25519VerificationKey2018 verification method.
*/
function getEd25519VerificationKey2018({ publicJwk, id, controller }) {
	return new require_VerificationMethod.VerificationMethod({
		id,
		type: VERIFICATION_METHOD_TYPE_ED25519_VERIFICATION_KEY_2018,
		controller,
		publicKeyBase58: require_TypedArrayEncoder.TypedArrayEncoder.toBase58(publicJwk.publicKey.publicKey)
	});
}
/**
* Check whether a verification method is a Ed25519VerificationKey2018 verification method.
*/
function isEd25519VerificationKey2018(verificationMethod) {
	return verificationMethod.type === VERIFICATION_METHOD_TYPE_ED25519_VERIFICATION_KEY_2018;
}
/**
* Get a key from a Ed25519VerificationKey2018 verification method.
*/
/**
* Get a public jwk from a Ed25519VerificationKey2018 verification method.
*/
function getPublicJwkFromEd25519VerificationKey2018(verificationMethod) {
	if (!verificationMethod.publicKeyBase58) throw new require_CredoError.CredoError("verification method is missing publicKeyBase58");
	return require_PublicJwk.PublicJwk.fromPublicKey({
		kty: "OKP",
		crv: "Ed25519",
		publicKey: require_TypedArrayEncoder.TypedArrayEncoder.fromBase58(verificationMethod.publicKeyBase58)
	});
}

//#endregion
exports.VERIFICATION_METHOD_TYPE_ED25519_VERIFICATION_KEY_2018 = VERIFICATION_METHOD_TYPE_ED25519_VERIFICATION_KEY_2018;
exports.getEd25519VerificationKey2018 = getEd25519VerificationKey2018;
exports.getPublicJwkFromEd25519VerificationKey2018 = getPublicJwkFromEd25519VerificationKey2018;
exports.isEd25519VerificationKey2018 = isEd25519VerificationKey2018;