// AUTOGENERATED FILE - DO NOT EDIT
import { Decoder, Encoder } from 'msgpackr';
import { BBApiException } from '../../bbapi_exception.js';
import { fromAesDecrypt, fromAesEncrypt, fromBlake2s, fromBlake2sToField, fromBn254FqSqrt, fromBn254FrSqrt, fromBn254G1FromCompressed, fromBn254G1IsOnCurve, fromBn254G1Mul, fromBn254G2Mul, fromChonkAccumulate, fromChonkCheckPrecomputedVk, fromChonkComputeVk, fromChonkLoad, fromChonkProve, fromChonkStart, fromChonkStats, fromChonkVerify, fromCircuitComputeVk, fromCircuitProve, fromCircuitStats, fromCircuitVerify, fromCircuitWriteSolidityVerifier, fromEcdsaSecp256k1ComputePublicKey, fromEcdsaSecp256k1ConstructSignature, fromEcdsaSecp256k1RecoverPublicKey, fromEcdsaSecp256k1VerifySignature, fromEcdsaSecp256r1ComputePublicKey, fromEcdsaSecp256r1ConstructSignature, fromEcdsaSecp256r1RecoverPublicKey, fromEcdsaSecp256r1VerifySignature, fromGrumpkinAdd, fromGrumpkinBatchMul, fromGrumpkinGetRandomFr, fromGrumpkinMul, fromGrumpkinReduce512, fromMegaVkAsFields, fromPedersenCommit, fromPedersenHash, fromPedersenHashBuffer, fromPoseidon2Hash, fromPoseidon2Permutation, fromSchnorrComputePublicKey, fromSchnorrConstructSignature, fromSchnorrVerifySignature, fromSecp256k1GetRandomFr, fromSecp256k1Mul, fromSecp256k1Reduce512, fromShutdown, fromSrsInitGrumpkinSrs, fromSrsInitSrs, fromVkAsFields, toAesDecryptResponse, toAesEncryptResponse, toBlake2sResponse, toBlake2sToFieldResponse, toBn254FqSqrtResponse, toBn254FrSqrtResponse, toBn254G1FromCompressedResponse, toBn254G1IsOnCurveResponse, toBn254G1MulResponse, toBn254G2MulResponse, toChonkAccumulateResponse, toChonkCheckPrecomputedVkResponse, toChonkComputeVkResponse, toChonkLoadResponse, toChonkProveResponse, toChonkStartResponse, toChonkStatsResponse, toChonkVerifyResponse, toCircuitComputeVkResponse, toCircuitInfoResponse, toCircuitProveResponse, toCircuitVerifyResponse, toCircuitWriteSolidityVerifierResponse, toEcdsaSecp256k1ComputePublicKeyResponse, toEcdsaSecp256k1ConstructSignatureResponse, toEcdsaSecp256k1RecoverPublicKeyResponse, toEcdsaSecp256k1VerifySignatureResponse, toEcdsaSecp256r1ComputePublicKeyResponse, toEcdsaSecp256r1ConstructSignatureResponse, toEcdsaSecp256r1RecoverPublicKeyResponse, toEcdsaSecp256r1VerifySignatureResponse, toGrumpkinAddResponse, toGrumpkinBatchMulResponse, toGrumpkinGetRandomFrResponse, toGrumpkinMulResponse, toGrumpkinReduce512Response, toMegaVkAsFieldsResponse, toPedersenCommitResponse, toPedersenHashBufferResponse, toPedersenHashResponse, toPoseidon2HashResponse, toPoseidon2PermutationResponse, toSchnorrComputePublicKeyResponse, toSchnorrConstructSignatureResponse, toSchnorrVerifySignatureResponse, toSecp256k1GetRandomFrResponse, toSecp256k1MulResponse, toSecp256k1Reduce512Response, toShutdownResponse, toSrsInitGrumpkinSrsResponse, toSrsInitSrsResponse, toVkAsFieldsResponse } from './api_types.js';
function msgpackCall(backend, input) {
    const inputBuffer = new Encoder({ useRecords: false }).pack(input);
    const encodedResult = backend.call(inputBuffer);
    return new Decoder({ useRecords: false }).unpack(encodedResult);
}
export class SyncApi {
    backend;
    constructor(backend) {
        this.backend = backend;
    }
    circuitProve(command) {
        const msgpackCommand = fromCircuitProve(command);
        const [variantName, result] = msgpackCall(this.backend, [["CircuitProve", msgpackCommand]]);
        if (variantName === 'ErrorResponse') {
            throw new BBApiException(result.message || 'Unknown error from barretenberg');
        }
        if (variantName !== 'CircuitProveResponse') {
            throw new BBApiException(`Expected variant name 'CircuitProveResponse' but got '${variantName}'`);
        }
        return toCircuitProveResponse(result);
    }
    circuitComputeVk(command) {
        const msgpackCommand = fromCircuitComputeVk(command);
        const [variantName, result] = msgpackCall(this.backend, [["CircuitComputeVk", msgpackCommand]]);
        if (variantName === 'ErrorResponse') {
            throw new BBApiException(result.message || 'Unknown error from barretenberg');
        }
        if (variantName !== 'CircuitComputeVkResponse') {
            throw new BBApiException(`Expected variant name 'CircuitComputeVkResponse' but got '${variantName}'`);
        }
        return toCircuitComputeVkResponse(result);
    }
    circuitStats(command) {
        const msgpackCommand = fromCircuitStats(command);
        const [variantName, result] = msgpackCall(this.backend, [["CircuitStats", msgpackCommand]]);
        if (variantName === 'ErrorResponse') {
            throw new BBApiException(result.message || 'Unknown error from barretenberg');
        }
        if (variantName !== 'CircuitInfoResponse') {
            throw new BBApiException(`Expected variant name 'CircuitInfoResponse' but got '${variantName}'`);
        }
        return toCircuitInfoResponse(result);
    }
    circuitVerify(command) {
        const msgpackCommand = fromCircuitVerify(command);
        const [variantName, result] = msgpackCall(this.backend, [["CircuitVerify", msgpackCommand]]);
        if (variantName === 'ErrorResponse') {
            throw new BBApiException(result.message || 'Unknown error from barretenberg');
        }
        if (variantName !== 'CircuitVerifyResponse') {
            throw new BBApiException(`Expected variant name 'CircuitVerifyResponse' but got '${variantName}'`);
        }
        return toCircuitVerifyResponse(result);
    }
    chonkComputeVk(command) {
        const msgpackCommand = fromChonkComputeVk(command);
        const [variantName, result] = msgpackCall(this.backend, [["ChonkComputeVk", msgpackCommand]]);
        if (variantName === 'ErrorResponse') {
            throw new BBApiException(result.message || 'Unknown error from barretenberg');
        }
        if (variantName !== 'ChonkComputeVkResponse') {
            throw new BBApiException(`Expected variant name 'ChonkComputeVkResponse' but got '${variantName}'`);
        }
        return toChonkComputeVkResponse(result);
    }
    chonkStart(command) {
        const msgpackCommand = fromChonkStart(command);
        const [variantName, result] = msgpackCall(this.backend, [["ChonkStart", msgpackCommand]]);
        if (variantName === 'ErrorResponse') {
            throw new BBApiException(result.message || 'Unknown error from barretenberg');
        }
        if (variantName !== 'ChonkStartResponse') {
            throw new BBApiException(`Expected variant name 'ChonkStartResponse' but got '${variantName}'`);
        }
        return toChonkStartResponse(result);
    }
    chonkLoad(command) {
        const msgpackCommand = fromChonkLoad(command);
        const [variantName, result] = msgpackCall(this.backend, [["ChonkLoad", msgpackCommand]]);
        if (variantName === 'ErrorResponse') {
            throw new BBApiException(result.message || 'Unknown error from barretenberg');
        }
        if (variantName !== 'ChonkLoadResponse') {
            throw new BBApiException(`Expected variant name 'ChonkLoadResponse' but got '${variantName}'`);
        }
        return toChonkLoadResponse(result);
    }
    chonkAccumulate(command) {
        const msgpackCommand = fromChonkAccumulate(command);
        const [variantName, result] = msgpackCall(this.backend, [["ChonkAccumulate", msgpackCommand]]);
        if (variantName === 'ErrorResponse') {
            throw new BBApiException(result.message || 'Unknown error from barretenberg');
        }
        if (variantName !== 'ChonkAccumulateResponse') {
            throw new BBApiException(`Expected variant name 'ChonkAccumulateResponse' but got '${variantName}'`);
        }
        return toChonkAccumulateResponse(result);
    }
    chonkProve(command) {
        const msgpackCommand = fromChonkProve(command);
        const [variantName, result] = msgpackCall(this.backend, [["ChonkProve", msgpackCommand]]);
        if (variantName === 'ErrorResponse') {
            throw new BBApiException(result.message || 'Unknown error from barretenberg');
        }
        if (variantName !== 'ChonkProveResponse') {
            throw new BBApiException(`Expected variant name 'ChonkProveResponse' but got '${variantName}'`);
        }
        return toChonkProveResponse(result);
    }
    chonkVerify(command) {
        const msgpackCommand = fromChonkVerify(command);
        const [variantName, result] = msgpackCall(this.backend, [["ChonkVerify", msgpackCommand]]);
        if (variantName === 'ErrorResponse') {
            throw new BBApiException(result.message || 'Unknown error from barretenberg');
        }
        if (variantName !== 'ChonkVerifyResponse') {
            throw new BBApiException(`Expected variant name 'ChonkVerifyResponse' but got '${variantName}'`);
        }
        return toChonkVerifyResponse(result);
    }
    vkAsFields(command) {
        const msgpackCommand = fromVkAsFields(command);
        const [variantName, result] = msgpackCall(this.backend, [["VkAsFields", msgpackCommand]]);
        if (variantName === 'ErrorResponse') {
            throw new BBApiException(result.message || 'Unknown error from barretenberg');
        }
        if (variantName !== 'VkAsFieldsResponse') {
            throw new BBApiException(`Expected variant name 'VkAsFieldsResponse' but got '${variantName}'`);
        }
        return toVkAsFieldsResponse(result);
    }
    megaVkAsFields(command) {
        const msgpackCommand = fromMegaVkAsFields(command);
        const [variantName, result] = msgpackCall(this.backend, [["MegaVkAsFields", msgpackCommand]]);
        if (variantName === 'ErrorResponse') {
            throw new BBApiException(result.message || 'Unknown error from barretenberg');
        }
        if (variantName !== 'MegaVkAsFieldsResponse') {
            throw new BBApiException(`Expected variant name 'MegaVkAsFieldsResponse' but got '${variantName}'`);
        }
        return toMegaVkAsFieldsResponse(result);
    }
    circuitWriteSolidityVerifier(command) {
        const msgpackCommand = fromCircuitWriteSolidityVerifier(command);
        const [variantName, result] = msgpackCall(this.backend, [["CircuitWriteSolidityVerifier", msgpackCommand]]);
        if (variantName === 'ErrorResponse') {
            throw new BBApiException(result.message || 'Unknown error from barretenberg');
        }
        if (variantName !== 'CircuitWriteSolidityVerifierResponse') {
            throw new BBApiException(`Expected variant name 'CircuitWriteSolidityVerifierResponse' but got '${variantName}'`);
        }
        return toCircuitWriteSolidityVerifierResponse(result);
    }
    chonkCheckPrecomputedVk(command) {
        const msgpackCommand = fromChonkCheckPrecomputedVk(command);
        const [variantName, result] = msgpackCall(this.backend, [["ChonkCheckPrecomputedVk", msgpackCommand]]);
        if (variantName === 'ErrorResponse') {
            throw new BBApiException(result.message || 'Unknown error from barretenberg');
        }
        if (variantName !== 'ChonkCheckPrecomputedVkResponse') {
            throw new BBApiException(`Expected variant name 'ChonkCheckPrecomputedVkResponse' but got '${variantName}'`);
        }
        return toChonkCheckPrecomputedVkResponse(result);
    }
    chonkStats(command) {
        const msgpackCommand = fromChonkStats(command);
        const [variantName, result] = msgpackCall(this.backend, [["ChonkStats", msgpackCommand]]);
        if (variantName === 'ErrorResponse') {
            throw new BBApiException(result.message || 'Unknown error from barretenberg');
        }
        if (variantName !== 'ChonkStatsResponse') {
            throw new BBApiException(`Expected variant name 'ChonkStatsResponse' but got '${variantName}'`);
        }
        return toChonkStatsResponse(result);
    }
    poseidon2Hash(command) {
        const msgpackCommand = fromPoseidon2Hash(command);
        const [variantName, result] = msgpackCall(this.backend, [["Poseidon2Hash", msgpackCommand]]);
        if (variantName === 'ErrorResponse') {
            throw new BBApiException(result.message || 'Unknown error from barretenberg');
        }
        if (variantName !== 'Poseidon2HashResponse') {
            throw new BBApiException(`Expected variant name 'Poseidon2HashResponse' but got '${variantName}'`);
        }
        return toPoseidon2HashResponse(result);
    }
    poseidon2Permutation(command) {
        const msgpackCommand = fromPoseidon2Permutation(command);
        const [variantName, result] = msgpackCall(this.backend, [["Poseidon2Permutation", msgpackCommand]]);
        if (variantName === 'ErrorResponse') {
            throw new BBApiException(result.message || 'Unknown error from barretenberg');
        }
        if (variantName !== 'Poseidon2PermutationResponse') {
            throw new BBApiException(`Expected variant name 'Poseidon2PermutationResponse' but got '${variantName}'`);
        }
        return toPoseidon2PermutationResponse(result);
    }
    pedersenCommit(command) {
        const msgpackCommand = fromPedersenCommit(command);
        const [variantName, result] = msgpackCall(this.backend, [["PedersenCommit", msgpackCommand]]);
        if (variantName === 'ErrorResponse') {
            throw new BBApiException(result.message || 'Unknown error from barretenberg');
        }
        if (variantName !== 'PedersenCommitResponse') {
            throw new BBApiException(`Expected variant name 'PedersenCommitResponse' but got '${variantName}'`);
        }
        return toPedersenCommitResponse(result);
    }
    pedersenHash(command) {
        const msgpackCommand = fromPedersenHash(command);
        const [variantName, result] = msgpackCall(this.backend, [["PedersenHash", msgpackCommand]]);
        if (variantName === 'ErrorResponse') {
            throw new BBApiException(result.message || 'Unknown error from barretenberg');
        }
        if (variantName !== 'PedersenHashResponse') {
            throw new BBApiException(`Expected variant name 'PedersenHashResponse' but got '${variantName}'`);
        }
        return toPedersenHashResponse(result);
    }
    pedersenHashBuffer(command) {
        const msgpackCommand = fromPedersenHashBuffer(command);
        const [variantName, result] = msgpackCall(this.backend, [["PedersenHashBuffer", msgpackCommand]]);
        if (variantName === 'ErrorResponse') {
            throw new BBApiException(result.message || 'Unknown error from barretenberg');
        }
        if (variantName !== 'PedersenHashBufferResponse') {
            throw new BBApiException(`Expected variant name 'PedersenHashBufferResponse' but got '${variantName}'`);
        }
        return toPedersenHashBufferResponse(result);
    }
    blake2s(command) {
        const msgpackCommand = fromBlake2s(command);
        const [variantName, result] = msgpackCall(this.backend, [["Blake2s", msgpackCommand]]);
        if (variantName === 'ErrorResponse') {
            throw new BBApiException(result.message || 'Unknown error from barretenberg');
        }
        if (variantName !== 'Blake2sResponse') {
            throw new BBApiException(`Expected variant name 'Blake2sResponse' but got '${variantName}'`);
        }
        return toBlake2sResponse(result);
    }
    blake2sToField(command) {
        const msgpackCommand = fromBlake2sToField(command);
        const [variantName, result] = msgpackCall(this.backend, [["Blake2sToField", msgpackCommand]]);
        if (variantName === 'ErrorResponse') {
            throw new BBApiException(result.message || 'Unknown error from barretenberg');
        }
        if (variantName !== 'Blake2sToFieldResponse') {
            throw new BBApiException(`Expected variant name 'Blake2sToFieldResponse' but got '${variantName}'`);
        }
        return toBlake2sToFieldResponse(result);
    }
    aesEncrypt(command) {
        const msgpackCommand = fromAesEncrypt(command);
        const [variantName, result] = msgpackCall(this.backend, [["AesEncrypt", msgpackCommand]]);
        if (variantName === 'ErrorResponse') {
            throw new BBApiException(result.message || 'Unknown error from barretenberg');
        }
        if (variantName !== 'AesEncryptResponse') {
            throw new BBApiException(`Expected variant name 'AesEncryptResponse' but got '${variantName}'`);
        }
        return toAesEncryptResponse(result);
    }
    aesDecrypt(command) {
        const msgpackCommand = fromAesDecrypt(command);
        const [variantName, result] = msgpackCall(this.backend, [["AesDecrypt", msgpackCommand]]);
        if (variantName === 'ErrorResponse') {
            throw new BBApiException(result.message || 'Unknown error from barretenberg');
        }
        if (variantName !== 'AesDecryptResponse') {
            throw new BBApiException(`Expected variant name 'AesDecryptResponse' but got '${variantName}'`);
        }
        return toAesDecryptResponse(result);
    }
    grumpkinMul(command) {
        const msgpackCommand = fromGrumpkinMul(command);
        const [variantName, result] = msgpackCall(this.backend, [["GrumpkinMul", msgpackCommand]]);
        if (variantName === 'ErrorResponse') {
            throw new BBApiException(result.message || 'Unknown error from barretenberg');
        }
        if (variantName !== 'GrumpkinMulResponse') {
            throw new BBApiException(`Expected variant name 'GrumpkinMulResponse' but got '${variantName}'`);
        }
        return toGrumpkinMulResponse(result);
    }
    grumpkinAdd(command) {
        const msgpackCommand = fromGrumpkinAdd(command);
        const [variantName, result] = msgpackCall(this.backend, [["GrumpkinAdd", msgpackCommand]]);
        if (variantName === 'ErrorResponse') {
            throw new BBApiException(result.message || 'Unknown error from barretenberg');
        }
        if (variantName !== 'GrumpkinAddResponse') {
            throw new BBApiException(`Expected variant name 'GrumpkinAddResponse' but got '${variantName}'`);
        }
        return toGrumpkinAddResponse(result);
    }
    grumpkinBatchMul(command) {
        const msgpackCommand = fromGrumpkinBatchMul(command);
        const [variantName, result] = msgpackCall(this.backend, [["GrumpkinBatchMul", msgpackCommand]]);
        if (variantName === 'ErrorResponse') {
            throw new BBApiException(result.message || 'Unknown error from barretenberg');
        }
        if (variantName !== 'GrumpkinBatchMulResponse') {
            throw new BBApiException(`Expected variant name 'GrumpkinBatchMulResponse' but got '${variantName}'`);
        }
        return toGrumpkinBatchMulResponse(result);
    }
    grumpkinGetRandomFr(command) {
        const msgpackCommand = fromGrumpkinGetRandomFr(command);
        const [variantName, result] = msgpackCall(this.backend, [["GrumpkinGetRandomFr", msgpackCommand]]);
        if (variantName === 'ErrorResponse') {
            throw new BBApiException(result.message || 'Unknown error from barretenberg');
        }
        if (variantName !== 'GrumpkinGetRandomFrResponse') {
            throw new BBApiException(`Expected variant name 'GrumpkinGetRandomFrResponse' but got '${variantName}'`);
        }
        return toGrumpkinGetRandomFrResponse(result);
    }
    grumpkinReduce512(command) {
        const msgpackCommand = fromGrumpkinReduce512(command);
        const [variantName, result] = msgpackCall(this.backend, [["GrumpkinReduce512", msgpackCommand]]);
        if (variantName === 'ErrorResponse') {
            throw new BBApiException(result.message || 'Unknown error from barretenberg');
        }
        if (variantName !== 'GrumpkinReduce512Response') {
            throw new BBApiException(`Expected variant name 'GrumpkinReduce512Response' but got '${variantName}'`);
        }
        return toGrumpkinReduce512Response(result);
    }
    secp256k1Mul(command) {
        const msgpackCommand = fromSecp256k1Mul(command);
        const [variantName, result] = msgpackCall(this.backend, [["Secp256k1Mul", msgpackCommand]]);
        if (variantName === 'ErrorResponse') {
            throw new BBApiException(result.message || 'Unknown error from barretenberg');
        }
        if (variantName !== 'Secp256k1MulResponse') {
            throw new BBApiException(`Expected variant name 'Secp256k1MulResponse' but got '${variantName}'`);
        }
        return toSecp256k1MulResponse(result);
    }
    secp256k1GetRandomFr(command) {
        const msgpackCommand = fromSecp256k1GetRandomFr(command);
        const [variantName, result] = msgpackCall(this.backend, [["Secp256k1GetRandomFr", msgpackCommand]]);
        if (variantName === 'ErrorResponse') {
            throw new BBApiException(result.message || 'Unknown error from barretenberg');
        }
        if (variantName !== 'Secp256k1GetRandomFrResponse') {
            throw new BBApiException(`Expected variant name 'Secp256k1GetRandomFrResponse' but got '${variantName}'`);
        }
        return toSecp256k1GetRandomFrResponse(result);
    }
    secp256k1Reduce512(command) {
        const msgpackCommand = fromSecp256k1Reduce512(command);
        const [variantName, result] = msgpackCall(this.backend, [["Secp256k1Reduce512", msgpackCommand]]);
        if (variantName === 'ErrorResponse') {
            throw new BBApiException(result.message || 'Unknown error from barretenberg');
        }
        if (variantName !== 'Secp256k1Reduce512Response') {
            throw new BBApiException(`Expected variant name 'Secp256k1Reduce512Response' but got '${variantName}'`);
        }
        return toSecp256k1Reduce512Response(result);
    }
    bn254FrSqrt(command) {
        const msgpackCommand = fromBn254FrSqrt(command);
        const [variantName, result] = msgpackCall(this.backend, [["Bn254FrSqrt", msgpackCommand]]);
        if (variantName === 'ErrorResponse') {
            throw new BBApiException(result.message || 'Unknown error from barretenberg');
        }
        if (variantName !== 'Bn254FrSqrtResponse') {
            throw new BBApiException(`Expected variant name 'Bn254FrSqrtResponse' but got '${variantName}'`);
        }
        return toBn254FrSqrtResponse(result);
    }
    bn254FqSqrt(command) {
        const msgpackCommand = fromBn254FqSqrt(command);
        const [variantName, result] = msgpackCall(this.backend, [["Bn254FqSqrt", msgpackCommand]]);
        if (variantName === 'ErrorResponse') {
            throw new BBApiException(result.message || 'Unknown error from barretenberg');
        }
        if (variantName !== 'Bn254FqSqrtResponse') {
            throw new BBApiException(`Expected variant name 'Bn254FqSqrtResponse' but got '${variantName}'`);
        }
        return toBn254FqSqrtResponse(result);
    }
    bn254G1Mul(command) {
        const msgpackCommand = fromBn254G1Mul(command);
        const [variantName, result] = msgpackCall(this.backend, [["Bn254G1Mul", msgpackCommand]]);
        if (variantName === 'ErrorResponse') {
            throw new BBApiException(result.message || 'Unknown error from barretenberg');
        }
        if (variantName !== 'Bn254G1MulResponse') {
            throw new BBApiException(`Expected variant name 'Bn254G1MulResponse' but got '${variantName}'`);
        }
        return toBn254G1MulResponse(result);
    }
    bn254G2Mul(command) {
        const msgpackCommand = fromBn254G2Mul(command);
        const [variantName, result] = msgpackCall(this.backend, [["Bn254G2Mul", msgpackCommand]]);
        if (variantName === 'ErrorResponse') {
            throw new BBApiException(result.message || 'Unknown error from barretenberg');
        }
        if (variantName !== 'Bn254G2MulResponse') {
            throw new BBApiException(`Expected variant name 'Bn254G2MulResponse' but got '${variantName}'`);
        }
        return toBn254G2MulResponse(result);
    }
    bn254G1IsOnCurve(command) {
        const msgpackCommand = fromBn254G1IsOnCurve(command);
        const [variantName, result] = msgpackCall(this.backend, [["Bn254G1IsOnCurve", msgpackCommand]]);
        if (variantName === 'ErrorResponse') {
            throw new BBApiException(result.message || 'Unknown error from barretenberg');
        }
        if (variantName !== 'Bn254G1IsOnCurveResponse') {
            throw new BBApiException(`Expected variant name 'Bn254G1IsOnCurveResponse' but got '${variantName}'`);
        }
        return toBn254G1IsOnCurveResponse(result);
    }
    bn254G1FromCompressed(command) {
        const msgpackCommand = fromBn254G1FromCompressed(command);
        const [variantName, result] = msgpackCall(this.backend, [["Bn254G1FromCompressed", msgpackCommand]]);
        if (variantName === 'ErrorResponse') {
            throw new BBApiException(result.message || 'Unknown error from barretenberg');
        }
        if (variantName !== 'Bn254G1FromCompressedResponse') {
            throw new BBApiException(`Expected variant name 'Bn254G1FromCompressedResponse' but got '${variantName}'`);
        }
        return toBn254G1FromCompressedResponse(result);
    }
    schnorrComputePublicKey(command) {
        const msgpackCommand = fromSchnorrComputePublicKey(command);
        const [variantName, result] = msgpackCall(this.backend, [["SchnorrComputePublicKey", msgpackCommand]]);
        if (variantName === 'ErrorResponse') {
            throw new BBApiException(result.message || 'Unknown error from barretenberg');
        }
        if (variantName !== 'SchnorrComputePublicKeyResponse') {
            throw new BBApiException(`Expected variant name 'SchnorrComputePublicKeyResponse' but got '${variantName}'`);
        }
        return toSchnorrComputePublicKeyResponse(result);
    }
    schnorrConstructSignature(command) {
        const msgpackCommand = fromSchnorrConstructSignature(command);
        const [variantName, result] = msgpackCall(this.backend, [["SchnorrConstructSignature", msgpackCommand]]);
        if (variantName === 'ErrorResponse') {
            throw new BBApiException(result.message || 'Unknown error from barretenberg');
        }
        if (variantName !== 'SchnorrConstructSignatureResponse') {
            throw new BBApiException(`Expected variant name 'SchnorrConstructSignatureResponse' but got '${variantName}'`);
        }
        return toSchnorrConstructSignatureResponse(result);
    }
    schnorrVerifySignature(command) {
        const msgpackCommand = fromSchnorrVerifySignature(command);
        const [variantName, result] = msgpackCall(this.backend, [["SchnorrVerifySignature", msgpackCommand]]);
        if (variantName === 'ErrorResponse') {
            throw new BBApiException(result.message || 'Unknown error from barretenberg');
        }
        if (variantName !== 'SchnorrVerifySignatureResponse') {
            throw new BBApiException(`Expected variant name 'SchnorrVerifySignatureResponse' but got '${variantName}'`);
        }
        return toSchnorrVerifySignatureResponse(result);
    }
    ecdsaSecp256k1ComputePublicKey(command) {
        const msgpackCommand = fromEcdsaSecp256k1ComputePublicKey(command);
        const [variantName, result] = msgpackCall(this.backend, [["EcdsaSecp256k1ComputePublicKey", msgpackCommand]]);
        if (variantName === 'ErrorResponse') {
            throw new BBApiException(result.message || 'Unknown error from barretenberg');
        }
        if (variantName !== 'EcdsaSecp256k1ComputePublicKeyResponse') {
            throw new BBApiException(`Expected variant name 'EcdsaSecp256k1ComputePublicKeyResponse' but got '${variantName}'`);
        }
        return toEcdsaSecp256k1ComputePublicKeyResponse(result);
    }
    ecdsaSecp256r1ComputePublicKey(command) {
        const msgpackCommand = fromEcdsaSecp256r1ComputePublicKey(command);
        const [variantName, result] = msgpackCall(this.backend, [["EcdsaSecp256r1ComputePublicKey", msgpackCommand]]);
        if (variantName === 'ErrorResponse') {
            throw new BBApiException(result.message || 'Unknown error from barretenberg');
        }
        if (variantName !== 'EcdsaSecp256r1ComputePublicKeyResponse') {
            throw new BBApiException(`Expected variant name 'EcdsaSecp256r1ComputePublicKeyResponse' but got '${variantName}'`);
        }
        return toEcdsaSecp256r1ComputePublicKeyResponse(result);
    }
    ecdsaSecp256k1ConstructSignature(command) {
        const msgpackCommand = fromEcdsaSecp256k1ConstructSignature(command);
        const [variantName, result] = msgpackCall(this.backend, [["EcdsaSecp256k1ConstructSignature", msgpackCommand]]);
        if (variantName === 'ErrorResponse') {
            throw new BBApiException(result.message || 'Unknown error from barretenberg');
        }
        if (variantName !== 'EcdsaSecp256k1ConstructSignatureResponse') {
            throw new BBApiException(`Expected variant name 'EcdsaSecp256k1ConstructSignatureResponse' but got '${variantName}'`);
        }
        return toEcdsaSecp256k1ConstructSignatureResponse(result);
    }
    ecdsaSecp256r1ConstructSignature(command) {
        const msgpackCommand = fromEcdsaSecp256r1ConstructSignature(command);
        const [variantName, result] = msgpackCall(this.backend, [["EcdsaSecp256r1ConstructSignature", msgpackCommand]]);
        if (variantName === 'ErrorResponse') {
            throw new BBApiException(result.message || 'Unknown error from barretenberg');
        }
        if (variantName !== 'EcdsaSecp256r1ConstructSignatureResponse') {
            throw new BBApiException(`Expected variant name 'EcdsaSecp256r1ConstructSignatureResponse' but got '${variantName}'`);
        }
        return toEcdsaSecp256r1ConstructSignatureResponse(result);
    }
    ecdsaSecp256k1RecoverPublicKey(command) {
        const msgpackCommand = fromEcdsaSecp256k1RecoverPublicKey(command);
        const [variantName, result] = msgpackCall(this.backend, [["EcdsaSecp256k1RecoverPublicKey", msgpackCommand]]);
        if (variantName === 'ErrorResponse') {
            throw new BBApiException(result.message || 'Unknown error from barretenberg');
        }
        if (variantName !== 'EcdsaSecp256k1RecoverPublicKeyResponse') {
            throw new BBApiException(`Expected variant name 'EcdsaSecp256k1RecoverPublicKeyResponse' but got '${variantName}'`);
        }
        return toEcdsaSecp256k1RecoverPublicKeyResponse(result);
    }
    ecdsaSecp256r1RecoverPublicKey(command) {
        const msgpackCommand = fromEcdsaSecp256r1RecoverPublicKey(command);
        const [variantName, result] = msgpackCall(this.backend, [["EcdsaSecp256r1RecoverPublicKey", msgpackCommand]]);
        if (variantName === 'ErrorResponse') {
            throw new BBApiException(result.message || 'Unknown error from barretenberg');
        }
        if (variantName !== 'EcdsaSecp256r1RecoverPublicKeyResponse') {
            throw new BBApiException(`Expected variant name 'EcdsaSecp256r1RecoverPublicKeyResponse' but got '${variantName}'`);
        }
        return toEcdsaSecp256r1RecoverPublicKeyResponse(result);
    }
    ecdsaSecp256k1VerifySignature(command) {
        const msgpackCommand = fromEcdsaSecp256k1VerifySignature(command);
        const [variantName, result] = msgpackCall(this.backend, [["EcdsaSecp256k1VerifySignature", msgpackCommand]]);
        if (variantName === 'ErrorResponse') {
            throw new BBApiException(result.message || 'Unknown error from barretenberg');
        }
        if (variantName !== 'EcdsaSecp256k1VerifySignatureResponse') {
            throw new BBApiException(`Expected variant name 'EcdsaSecp256k1VerifySignatureResponse' but got '${variantName}'`);
        }
        return toEcdsaSecp256k1VerifySignatureResponse(result);
    }
    ecdsaSecp256r1VerifySignature(command) {
        const msgpackCommand = fromEcdsaSecp256r1VerifySignature(command);
        const [variantName, result] = msgpackCall(this.backend, [["EcdsaSecp256r1VerifySignature", msgpackCommand]]);
        if (variantName === 'ErrorResponse') {
            throw new BBApiException(result.message || 'Unknown error from barretenberg');
        }
        if (variantName !== 'EcdsaSecp256r1VerifySignatureResponse') {
            throw new BBApiException(`Expected variant name 'EcdsaSecp256r1VerifySignatureResponse' but got '${variantName}'`);
        }
        return toEcdsaSecp256r1VerifySignatureResponse(result);
    }
    srsInitSrs(command) {
        const msgpackCommand = fromSrsInitSrs(command);
        const [variantName, result] = msgpackCall(this.backend, [["SrsInitSrs", msgpackCommand]]);
        if (variantName === 'ErrorResponse') {
            throw new BBApiException(result.message || 'Unknown error from barretenberg');
        }
        if (variantName !== 'SrsInitSrsResponse') {
            throw new BBApiException(`Expected variant name 'SrsInitSrsResponse' but got '${variantName}'`);
        }
        return toSrsInitSrsResponse(result);
    }
    srsInitGrumpkinSrs(command) {
        const msgpackCommand = fromSrsInitGrumpkinSrs(command);
        const [variantName, result] = msgpackCall(this.backend, [["SrsInitGrumpkinSrs", msgpackCommand]]);
        if (variantName === 'ErrorResponse') {
            throw new BBApiException(result.message || 'Unknown error from barretenberg');
        }
        if (variantName !== 'SrsInitGrumpkinSrsResponse') {
            throw new BBApiException(`Expected variant name 'SrsInitGrumpkinSrsResponse' but got '${variantName}'`);
        }
        return toSrsInitGrumpkinSrsResponse(result);
    }
    shutdown(command) {
        const msgpackCommand = fromShutdown(command);
        const [variantName, result] = msgpackCall(this.backend, [["Shutdown", msgpackCommand]]);
        if (variantName === 'ErrorResponse') {
            throw new BBApiException(result.message || 'Unknown error from barretenberg');
        }
        if (variantName !== 'ShutdownResponse') {
            throw new BBApiException(`Expected variant name 'ShutdownResponse' but got '${variantName}'`);
        }
        return toShutdownResponse(result);
    }
    destroy() {
        if (this.backend.destroy)
            this.backend.destroy();
    }
}
//# sourceMappingURL=data:application/json;base64, 