import { EncryptionVersion, IRequestTracer } from '../../../api';
import * as openpgp from 'openpgp';
import { Key, SerializedKeyPair } from 'openpgp';
import { IBaseCoin, KeychainsTriplet } from '../../baseCoin';
import { BitGoBase } from '../../bitgoBase';
import { Keychain, WebauthnKeyEncryptionInfo } from '../../keychain';
import { IWallet } from '../../wallet';
import { MpcUtils } from '../mpcUtils';
import { BitgoHeldBackupKeyShare, CommitmentShareRecord, CreateBitGoKeychainParamsBase, CreateKeychainParamsBase, CustomCommitmentGeneratingFunction, CustomEddsaMPCv2SigningRound1GeneratingFunction, CustomEddsaMPCv2SigningRound2GeneratingFunction, CustomEddsaMPCv2SigningRound3GeneratingFunction, CustomGShareGeneratingFunction, CustomKShareGeneratingFunction, CustomMPCv2SigningRound1GeneratingFunction, CustomMPCv2SigningRound2GeneratingFunction, CustomMPCv2SigningRound3GeneratingFunction, CustomMuDeltaShareGeneratingFunction, CustomPaillierModulusGetterFunction, CustomRShareGeneratingFunction, CustomSShareGeneratingFunction, EncryptedSignerShareRecord, IntentOptionsForMessage, IntentOptionsForTypedData, ITssUtils, PrebuildTransactionWithIntentOptions, RequestType, SignatureShareRecord, TSSParams, TSSParamsForMessage, TssSignTxRequestParamsWithPrv, TxRequest, TxRequestVersion } from './baseTypes';
import { GShare, SignShare } from '../../../account-lib/mpc/tss';
/**
 * BaseTssUtil class which different signature schemes have to extend
 */
export default class BaseTssUtils<KeyShare> extends MpcUtils implements ITssUtils<KeyShare> {
    private _wallet?;
    protected bitgoPublicGpgKey: openpgp.Key;
    protected bitgoMPCv2PublicGpgKey: openpgp.Key | undefined;
    protected bitgoEddsaMpcv2PublicGpgKey: openpgp.Key | undefined;
    constructor(bitgo: BitGoBase, baseCoin: IBaseCoin, wallet?: IWallet);
    get wallet(): IWallet;
    protected setBitgoGpgPubKey(bitgo: any): Promise<void>;
    pickBitgoPubGpgKeyForSigning(isMpcv2: boolean, reqId?: IRequestTracer, enterpriseId?: string, isEddsaMpcv2?: boolean): Promise<openpgp.Key>;
    getBitgoPublicGpgKey(): Promise<openpgp.Key>;
    getBitgoMpcv2PublicGpgKey(): Promise<openpgp.Key>;
    getBitgoEddsaMpcv2PublicGpgKey(): Promise<openpgp.Key>;
    createBitgoHeldBackupKeyShare(userGpgKey: SerializedKeyPair<string>, enterprise: string | undefined): Promise<BitgoHeldBackupKeyShare>;
    finalizeBitgoHeldBackupKeyShare(keyId: string, commonKeychain: string, userKeyShare: KeyShare, bitgoKeychain: Keychain, userGpgKey: SerializedKeyPair<string>, backupGpgKey: Key): Promise<BitgoHeldBackupKeyShare>;
    createUserKeychain(params: CreateKeychainParamsBase): Promise<Keychain>;
    createBackupKeychain(params: CreateKeychainParamsBase): Promise<Keychain>;
    createBitgoKeychain(params: CreateBitGoKeychainParamsBase): Promise<Keychain>;
    createKeychains(params: {
        passphrase: string;
        enterprise?: string | undefined;
        originalPasscodeEncryptionCode?: string | undefined;
        isThirdPartyBackup?: boolean;
        webauthnInfo?: WebauthnKeyEncryptionInfo;
        encryptionVersion?: EncryptionVersion;
    }): Promise<KeychainsTriplet>;
    signTxRequest(params: TssSignTxRequestParamsWithPrv): Promise<TxRequest>;
    signTxRequestForMessage(params: TSSParamsForMessage): Promise<TxRequest>;
    /**
     * Signs a transaction using TSS for EdDSA and through utilization of custom share generators
     *
     * @param {string | TxRequest} txRequest - transaction request with unsigned transaction
     * @param {CustomRShareGeneratingFunction} externalSignerRShareGenerator a function that creates R shares in the EdDSA TSS flow
     * @param {CustomGShareGeneratingFunction} externalSignerGShareGenerator a function that creates G shares in the EdDSA TSS flow
     * @returns {Promise<TxRequest>} - a signed tx request
     */
    signEddsaTssUsingExternalSigner(txRequest: string | TxRequest, externalSignerCommitmentGenerator: CustomCommitmentGeneratingFunction, externalSignerRShareGenerator: CustomRShareGeneratingFunction, externalSignerGShareGenerator: CustomGShareGeneratingFunction): Promise<TxRequest>;
    /**
     * Signs a transaction using TSS for ECDSA and through utilization of custom share generators
     *
     * @param {params: TSSParams | TSSParamsForMessage} params - params object that represents parameters to sign a transaction or a message.
     * @param {RequestType} requestType - the type of the request to sign (transaction or message).
     * @param {CustomPaillierModulusGetterFunction} externalSignerPaillierModulusGetter a function that creates Paillier Modulus shares in the ECDSA TSS flow.
     * @param {CustomKShareGeneratingFunction} externalSignerKShareGenerator a function that creates K shares in the ECDSA TSS flow.
     * @param {CustomMuDeltaShareGeneratingFunction} externalSignerMuDeltaShareGenerator a function that creates Mu and Delta shares in the ECDSA TSS flow.
     * @param {CustomSShareGeneratingFunction} externalSignerSShareGenerator a function that creates S shares in the ECDSA TSS flow.
     */
    signEcdsaTssUsingExternalSigner(params: TSSParams | TSSParamsForMessage, requestType: RequestType, externalSignerPaillierModulusGetter: CustomPaillierModulusGetterFunction, externalSignerKShareGenerator: CustomKShareGeneratingFunction, externalSignerMuDeltaShareGenerator: CustomMuDeltaShareGeneratingFunction, externalSignerSShareGenerator: CustomSShareGeneratingFunction): Promise<TxRequest>;
    /**
     * Signs a transaction using TSS MPCv2 for ECDSA and through utilization of custom share generators
     *
     * @param {TSSParams | TSSParamsForMessage} params - params object that represents parameters to sign a transaction or a message.
     * @param {CustomMPCv2SigningRound1GeneratingFunction} externalSignerMPCv2SigningRound1Generator - a function that creates MPCv2 Round 1 shares in the ECDSA TSS MPCv2 flow.
     * @param {CustomMPCv2SigningRound2GeneratingFunction} externalSignerMPCv2SigningRound2Generator - a function that creates MPCv2 Round 2 shares in the ECDSA TSS MPCv2 flow.
     * @param {CustomMPCv2SigningRound3GeneratingFunction} externalSignerMPCv2SigningRound3Generator - a function that creates MPCv2 Round 3 shares in the ECDSA TSS MPCv2 flow.
     * @param {RequestType} requestType - the type of the request to sign (transaction or message).
     * @returns {Promise<TxRequest>} - a signed tx request
     */
    signEcdsaMPCv2TssUsingExternalSigner(params: TSSParams | TSSParamsForMessage, externalSignerMPCv2SigningRound1Generator: CustomMPCv2SigningRound1GeneratingFunction, externalSignerMPCv2SigningRound2Generator: CustomMPCv2SigningRound2GeneratingFunction, externalSignerMPCv2SigningRound3Generator: CustomMPCv2SigningRound3GeneratingFunction, requestType?: RequestType): Promise<TxRequest>;
    signEddsaMPCv2TssUsingExternalSigner(params: TSSParams | TSSParamsForMessage, externalSignerEddsaMPCv2SigningRound1Generator: CustomEddsaMPCv2SigningRound1GeneratingFunction, externalSignerEddsaMPCv2SigningRound2Generator: CustomEddsaMPCv2SigningRound2GeneratingFunction, externalSignerEddsaMPCv2SigningRound3Generator: CustomEddsaMPCv2SigningRound3GeneratingFunction, requestType?: RequestType): Promise<TxRequest>;
    /**
     * Create an Commitment (User to BitGo) share from an unsigned transaction and private user signing material
     * EDDSA only
     *
     * @param {Object} params - params object
     * @param {TxRequest} params.txRequest - transaction request with unsigned transaction
     * @param {string} params.prv - user signing material
     * @param {string} params.walletPassphrase - wallet passphrase
     *
     * @returns {Promise<{ userToBitgoCommitment: CommitmentShareRecor, encryptedSignerShare: EncryptedSignerShareRecord }>} - Commitment Share and the Encrypted Signer Share to BitGo
     */
    createCommitmentShareFromTxRequest(params: {
        txRequest: TxRequest;
        prv: string;
        walletPassphrase: string;
        bitgoGpgPubKey: string;
    }): Promise<{
        userToBitgoCommitment: CommitmentShareRecord;
        encryptedSignerShare: EncryptedSignerShareRecord;
        encryptedUserToBitgoRShare: EncryptedSignerShareRecord;
    }>;
    /**
     * Create an R (User to BitGo) share from an unsigned transaction and private user signing material
     *
     * @param {Object} params - params object
     * @param {TxRequest} params.txRequest - transaction request with unsigned transaction
     * @param {string} params.prv - user signing material
     * @param {string} [params.walletPassphrase] - wallet passphrase
     * @param {EncryptedSignerShareRecord} [params.encryptedUserToBitgoRShare] - encrypted user to bitgo R share generated in the commitment phase
     * @returns {Promise<{ rShare: SignShare }>} - R Share to BitGo
     */
    createRShareFromTxRequest(params: {
        txRequest: TxRequest;
        walletPassphrase: string;
        encryptedUserToBitgoRShare: EncryptedSignerShareRecord;
    }): Promise<{
        rShare: SignShare;
    }>;
    /**
     * Create a G (User to BitGo) share from an unsigned transaction and private user signing material
     *
     * @param {Object} params - params object
     * @param {TxRequest} params.txRequest - transaction request with unsigned transaction
     * @param {string} params.prv - user signing material
     * @param {SignatureShareRecord} params.bitgoToUserRShare - BitGo to User R Share
     * @param {SignShare} params.userToBitgoRShare - User to BitGo R Share
     * @param {CommitmentShareRecord} params.bitgoToUserCommitment - BitGo to User Commitment
     * @returns {Promise<GShare>} - GShare from User to BitGo
     */
    createGShareFromTxRequest(params: {
        txRequest: TxRequest;
        prv: string;
        bitgoToUserRShare: SignatureShareRecord;
        userToBitgoRShare: SignShare;
        bitgoToUserCommitment: CommitmentShareRecord;
    }): Promise<GShare>;
    /**
     * Builds a tx request from params and verify it
     *
     * @param {PrebuildTransactionWithIntentOptions} params - parameters to build the tx
     * @param {TxRequestVersion} apiVersion lite or full
     * @param {boolean} preview boolean indicating if this is to preview a tx request, which will not initiate policy checks or pending approvals
     * @returns {Promise<TxRequest>} - a built tx request
     */
    prebuildTxWithIntent(params: PrebuildTransactionWithIntentOptions, apiVersion?: TxRequestVersion, preview?: boolean): Promise<TxRequest>;
    /**
     * Create a tx request from params for message signing
     * @deprecated Use createSignMessageRequest instead
     *
     * @param params
     * @param apiVersion
     * @param preview
     */
    createTxRequestWithIntentForMessageSigning(params: IntentOptionsForMessage, apiVersion?: TxRequestVersion, preview?: boolean): Promise<TxRequest>;
    /**
     * Create a sign message request
     *
     * @param params - the parameters for the sign message request
     * @param apiVersion - the API version to use, defaults to 'full'
     */
    buildSignMessageRequest(params: IntentOptionsForMessage, apiVersion?: TxRequestVersion): Promise<TxRequest>;
    /**
     * Create a tx request from params for type data signing
     *
     * @param params
     * @param apiVersion
     * @param preview
     */
    createTxRequestWithIntentForTypedDataSigning(params: IntentOptionsForTypedData, apiVersion?: TxRequestVersion, preview?: boolean): Promise<TxRequest>;
    /**
     * Calls Bitgo API to create tx request.
     *
     * @private
     */
    private createTxRequestBase;
    /**
     * Calls Bitgo API to create msg request.
     *
     * @private
     */
    private buildSignMessageRequestBase;
    /**
     * Call delete signature shares for a txRequest, the endpoint delete the signatures and return them
     *
     * @param {string} txRequestId tx id reference to delete signature shares
     * @param {IRequestTracer} reqId - the request tracer request id
     * @returns {SignatureShareRecord[]}
     */
    deleteSignatureShares(txRequestId: string, reqId?: IRequestTracer): Promise<SignatureShareRecord[]>;
    /**
     * Initialize the send procedure once Bitgo has the User To Bitgo GShare
     *
     * @param {String} txRequestId - the txRequest Id
     * @param {IRequestTracer} reqId - the request tracer request id
     * @returns {Promise<any>}
     */
    sendTxRequest(txRequestId: string, reqId?: IRequestTracer): Promise<any>;
    /**
     * Delete signature shares, get the tx request without them from the db and sign it to finally send it.
     *
     * Note : This can be performed in order to reach latest network conditions required on pending approval flow.
     *
     * @param {String} txRequestId - the txRequest Id to make the requests.
     * @param {String} decryptedPrv - decrypted prv to sign the tx request.
     * @param {RequestTracer} reqId id tracer.
     * @returns {Promise<any>}
     */
    recreateTxRequest(txRequestId: string, decryptedPrv: string, reqId: IRequestTracer): Promise<TxRequest>;
    /**
     * Gets the latest Tx Request by id
     *
     * @param {String} txRequestId - the txRequest Id
     * @param {IRequestTracer} reqId - request tracer request id
     * @returns {Promise<TxRequest>}
     */
    getTxRequest(txRequestId: string, reqId?: IRequestTracer): Promise<TxRequest>;
    /**
     * It gets the appropriate BitGo GPG public keys for key creation based on a
     * combination of coin and the feature flags on the user and their enterprise if set.
     * Returns both the default MPCv2 key and the EdDSA-specific MPCv2 key (if present).
     * @param enterpriseId - enterprise under which user wants to create the wallet
     * @param isMPCv2 - true to get the MPCv2 GPG public key, defaults to false
     * @param reqId - request tracer request id
     */
    getBitgoGpgPubkeyBasedOnFeatureFlags(enterpriseId: string | undefined, isMPCv2?: boolean, reqId?: IRequestTracer): Promise<{
        mpcv2PublicKey: Key;
        eddsaMpcv2PublicKey: Key | undefined;
    }>;
    /**
     * Returns supported TxRequest versions for this wallet
     * @deprecated Whenever needed, use apiVersion 'full' for TSS wallets
     */
    supportedTxRequestVersions(): TxRequestVersion[];
    /**
     * Returns true if the txRequest is using apiVersion == full and is pending approval
     * @param txRequest
     * @returns boolean
     */
    isPendingApprovalTxRequestFull(txRequest: TxRequest): boolean;
    /**
     * Get the signable hex, derivation path, and serialized tx hex from a full single-transaction request.
     * @param {TxRequest} txRequest - the transaction request object
     * @returns {{ signableHex: string; derivationPath: string; serializedTxHex: string | undefined }} - the signable hex, derivation path, and serialized tx hex
     */
    protected getSignableHexAndDerivationPath(txRequest: TxRequest, missingTransactionsMessage?: string): {
        signableHex: string;
        derivationPath: string;
        serializedTxHex: string | undefined;
    };
    /**
     * Gets the BitGo and user GPG keys from the BitGo public GPG key and the encrypted user GPG private key.
     * @param {string} bitgoPublicGpgKey - the BitGo public GPG key
     * @param {string} encryptedUserGpgPrvKey - the encrypted user GPG private key
     * @param {string} walletPassphrase - the wallet passphrase
     * @param {string} adata - the additional data to validate the GPG keys
     * @param {string} userGpgKeyDomainSeparator - the domain separator expected in the encrypted GPG key adata
     * @returns {Promise<{ bitgoGpgKey: openpgp.Key; userGpgPrvKey: openpgp.PrivateKey }>} - the BitGo and user GPG keys
     */
    protected getBitgoAndUserGpgKeys(bitgoPublicGpgKey: string, encryptedUserGpgPrvKey: string, walletPassphrase: string, adata: string, userGpgKeyDomainSeparator: string): Promise<{
        bitgoGpgKey: openpgp.Key;
        userGpgPrvKey: openpgp.PrivateKey;
    }>;
    /**
     * Validates encryption additional authenticated data against the ciphertext envelope.
     * @param adata string
     * @param cyphertext string
     * @param roundDomainSeparator string
     * @throws {Error} if the adata or cyphertext is invalid
     */
    protected validateAdata(adata: string, cyphertext: string, roundDomainSeparator: string): void;
}
//# sourceMappingURL=baseTSSUtils.d.ts.map