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