

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/EcdsaSecp256k1VerificationKey2019.ts
const VERIFICATION_METHOD_TYPE_ECDSA_SECP256K1_VERIFICATION_KEY_2019 = "EcdsaSecp256k1VerificationKey2019";
/**
* Get a EcdsaSecp256k1VerificationKey2019 verification method.
*/
function getEcdsaSecp256k1VerificationKey2019({ publicJwk, id, controller }) {
	return new require_VerificationMethod.VerificationMethod({
		id,
		type: VERIFICATION_METHOD_TYPE_ECDSA_SECP256K1_VERIFICATION_KEY_2019,
		controller,
		publicKeyBase58: require_TypedArrayEncoder.TypedArrayEncoder.toBase58(publicJwk.publicKey.publicKey)
	});
}
/**
* Check whether a verification method is a EcdsaSecp256k1VerificationKey2019 verification method.
*/
function isEcdsaSecp256k1VerificationKey2019(verificationMethod) {
	return verificationMethod.type === VERIFICATION_METHOD_TYPE_ECDSA_SECP256K1_VERIFICATION_KEY_2019;
}
/**
* Get a public jwk from a EcdsaSecp256k1VerificationKey2019 verification method.
*/
function getPublicJwkFromEcdsaSecp256k1VerificationKey2019(verificationMethod) {
	if (!verificationMethod.publicKeyBase58) throw new require_CredoError.CredoError("verification method is missing publicKeyBase58");
	return require_PublicJwk.PublicJwk.fromPublicKey({
		kty: "EC",
		crv: "secp256k1",
		publicKey: require_TypedArrayEncoder.TypedArrayEncoder.fromBase58(verificationMethod.publicKeyBase58)
	});
}

//#endregion
exports.VERIFICATION_METHOD_TYPE_ECDSA_SECP256K1_VERIFICATION_KEY_2019 = VERIFICATION_METHOD_TYPE_ECDSA_SECP256K1_VERIFICATION_KEY_2019;
exports.getEcdsaSecp256k1VerificationKey2019 = getEcdsaSecp256k1VerificationKey2019;
exports.getPublicJwkFromEcdsaSecp256k1VerificationKey2019 = getPublicJwkFromEcdsaSecp256k1VerificationKey2019;
exports.isEcdsaSecp256k1VerificationKey2019 = isEcdsaSecp256k1VerificationKey2019;