"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
    var ownKeys = function(o) {
        ownKeys = Object.getOwnPropertyNames || function (o) {
            var ar = [];
            for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
            return ar;
        };
        return ownKeys(o);
    };
    return function (mod) {
        if (mod && mod.__esModule) return mod;
        var result = {};
        if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
        __setModuleDefault(result, mod);
        return result;
    };
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.BaseEddsaUtils = void 0;
const bs58 = __importStar(require("bs58"));
const baseTSSUtils_1 = __importDefault(require("../baseTSSUtils"));
class BaseEddsaUtils extends baseTSSUtils_1.default {
    constructor(bitgo, baseCoin, wallet) {
        super(bitgo, baseCoin, wallet);
        this.setBitgoGpgPubKey(bitgo);
    }
    /**
     * Get the commonPub portion of an EdDSA commonKeychain.
     *
     * Keychains are 128 hex chars: 32-byte public key + 32-byte chaincode.
     *
     * @param {string} commonKeychain
     * @returns {string} base58-encoded public key
     */
    static getPublicKeyFromCommonKeychain(commonKeychain) {
        if (commonKeychain.length !== 128) {
            throw new Error(`Invalid commonKeychain length, expected 128, got ${commonKeychain.length}`);
        }
        const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