"use strict";
// AUTOGENERATED FILE - DO NOT EDIT
Object.defineProperty(exports, "__esModule", { value: true });
exports.toCircuitComputeVkResponse = toCircuitComputeVkResponse;
exports.toCircuitInput = toCircuitInput;
exports.toProofSystemSettings = toProofSystemSettings;
exports.toCircuitProve = toCircuitProve;
exports.toCircuitInputNoVK = toCircuitInputNoVK;
exports.toCircuitComputeVk = toCircuitComputeVk;
exports.toCircuitStats = toCircuitStats;
exports.toCircuitVerify = toCircuitVerify;
exports.toChonkComputeVk = toChonkComputeVk;
exports.toChonkStart = toChonkStart;
exports.toChonkLoad = toChonkLoad;
exports.toChonkAccumulate = toChonkAccumulate;
exports.toChonkProve = toChonkProve;
exports.toGoblinProof = toGoblinProof;
exports.toChonkProof = toChonkProof;
exports.toChonkVerify = toChonkVerify;
exports.toVkAsFields = toVkAsFields;
exports.toMegaVkAsFields = toMegaVkAsFields;
exports.toCircuitWriteSolidityVerifier = toCircuitWriteSolidityVerifier;
exports.toChonkCheckPrecomputedVk = toChonkCheckPrecomputedVk;
exports.toChonkStats = toChonkStats;
exports.toPoseidon2Hash = toPoseidon2Hash;
exports.toPoseidon2Permutation = toPoseidon2Permutation;
exports.toPedersenCommit = toPedersenCommit;
exports.toPedersenHash = toPedersenHash;
exports.toPedersenHashBuffer = toPedersenHashBuffer;
exports.toBlake2s = toBlake2s;
exports.toBlake2sToField = toBlake2sToField;
exports.toAesEncrypt = toAesEncrypt;
exports.toAesDecrypt = toAesDecrypt;
exports.toGrumpkinPoint = toGrumpkinPoint;
exports.toGrumpkinMul = toGrumpkinMul;
exports.toGrumpkinAdd = toGrumpkinAdd;
exports.toGrumpkinBatchMul = toGrumpkinBatchMul;
exports.toGrumpkinGetRandomFr = toGrumpkinGetRandomFr;
exports.toGrumpkinReduce512 = toGrumpkinReduce512;
exports.toSecp256k1Point = toSecp256k1Point;
exports.toSecp256k1Mul = toSecp256k1Mul;
exports.toSecp256k1GetRandomFr = toSecp256k1GetRandomFr;
exports.toSecp256k1Reduce512 = toSecp256k1Reduce512;
exports.toBn254FrSqrt = toBn254FrSqrt;
exports.toBn254FqSqrt = toBn254FqSqrt;
exports.toBn254G1Point = toBn254G1Point;
exports.toBn254G1Mul = toBn254G1Mul;
exports.toBn254G2Point = toBn254G2Point;
exports.toBn254G2Mul = toBn254G2Mul;
exports.toBn254G1IsOnCurve = toBn254G1IsOnCurve;
exports.toBn254G1FromCompressed = toBn254G1FromCompressed;
exports.toSchnorrComputePublicKey = toSchnorrComputePublicKey;
exports.toSchnorrConstructSignature = toSchnorrConstructSignature;
exports.toSchnorrVerifySignature = toSchnorrVerifySignature;
exports.toEcdsaSecp256k1ComputePublicKey = toEcdsaSecp256k1ComputePublicKey;
exports.toEcdsaSecp256r1ComputePublicKey = toEcdsaSecp256r1ComputePublicKey;
exports.toEcdsaSecp256k1ConstructSignature = toEcdsaSecp256k1ConstructSignature;
exports.toEcdsaSecp256r1ConstructSignature = toEcdsaSecp256r1ConstructSignature;
exports.toEcdsaSecp256k1RecoverPublicKey = toEcdsaSecp256k1RecoverPublicKey;
exports.toEcdsaSecp256r1RecoverPublicKey = toEcdsaSecp256r1RecoverPublicKey;
exports.toEcdsaSecp256k1VerifySignature = toEcdsaSecp256k1VerifySignature;
exports.toSecp256r1Point = toSecp256r1Point;
exports.toEcdsaSecp256r1VerifySignature = toEcdsaSecp256r1VerifySignature;
exports.toSrsInitSrs = toSrsInitSrs;
exports.toSrsInitGrumpkinSrs = toSrsInitGrumpkinSrs;
exports.toShutdown = toShutdown;
exports.toErrorResponse = toErrorResponse;
exports.toCircuitProveResponse = toCircuitProveResponse;
exports.toCircuitInfoResponse = toCircuitInfoResponse;
exports.toCircuitVerifyResponse = toCircuitVerifyResponse;
exports.toChonkComputeVkResponse = toChonkComputeVkResponse;
exports.toChonkStartResponse = toChonkStartResponse;
exports.toChonkLoadResponse = toChonkLoadResponse;
exports.toChonkAccumulateResponse = toChonkAccumulateResponse;
exports.toChonkProveResponse = toChonkProveResponse;
exports.toChonkVerifyResponse = toChonkVerifyResponse;
exports.toVkAsFieldsResponse = toVkAsFieldsResponse;
exports.toMegaVkAsFieldsResponse = toMegaVkAsFieldsResponse;
exports.toCircuitWriteSolidityVerifierResponse = toCircuitWriteSolidityVerifierResponse;
exports.toChonkCheckPrecomputedVkResponse = toChonkCheckPrecomputedVkResponse;
exports.toChonkStatsResponse = toChonkStatsResponse;
exports.toPoseidon2HashResponse = toPoseidon2HashResponse;
exports.toPoseidon2PermutationResponse = toPoseidon2PermutationResponse;
exports.toPedersenCommitResponse = toPedersenCommitResponse;
exports.toPedersenHashResponse = toPedersenHashResponse;
exports.toPedersenHashBufferResponse = toPedersenHashBufferResponse;
exports.toBlake2sResponse = toBlake2sResponse;
exports.toBlake2sToFieldResponse = toBlake2sToFieldResponse;
exports.toAesEncryptResponse = toAesEncryptResponse;
exports.toAesDecryptResponse = toAesDecryptResponse;
exports.toGrumpkinMulResponse = toGrumpkinMulResponse;
exports.toGrumpkinAddResponse = toGrumpkinAddResponse;
exports.toGrumpkinBatchMulResponse = toGrumpkinBatchMulResponse;
exports.toGrumpkinGetRandomFrResponse = toGrumpkinGetRandomFrResponse;
exports.toGrumpkinReduce512Response = toGrumpkinReduce512Response;
exports.toSecp256k1MulResponse = toSecp256k1MulResponse;
exports.toSecp256k1GetRandomFrResponse = toSecp256k1GetRandomFrResponse;
exports.toSecp256k1Reduce512Response = toSecp256k1Reduce512Response;
exports.toBn254FrSqrtResponse = toBn254FrSqrtResponse;
exports.toBn254FqSqrtResponse = toBn254FqSqrtResponse;
exports.toBn254G1MulResponse = toBn254G1MulResponse;
exports.toBn254G2MulResponse = toBn254G2MulResponse;
exports.toBn254G1IsOnCurveResponse = toBn254G1IsOnCurveResponse;
exports.toBn254G1FromCompressedResponse = toBn254G1FromCompressedResponse;
exports.toSchnorrComputePublicKeyResponse = toSchnorrComputePublicKeyResponse;
exports.toSchnorrConstructSignatureResponse = toSchnorrConstructSignatureResponse;
exports.toSchnorrVerifySignatureResponse = toSchnorrVerifySignatureResponse;
exports.toEcdsaSecp256k1ComputePublicKeyResponse = toEcdsaSecp256k1ComputePublicKeyResponse;
exports.toEcdsaSecp256r1ComputePublicKeyResponse = toEcdsaSecp256r1ComputePublicKeyResponse;
exports.toEcdsaSecp256k1ConstructSignatureResponse = toEcdsaSecp256k1ConstructSignatureResponse;
exports.toEcdsaSecp256r1ConstructSignatureResponse = toEcdsaSecp256r1ConstructSignatureResponse;
exports.toEcdsaSecp256k1RecoverPublicKeyResponse = toEcdsaSecp256k1RecoverPublicKeyResponse;
exports.toEcdsaSecp256r1RecoverPublicKeyResponse = toEcdsaSecp256r1RecoverPublicKeyResponse;
exports.toEcdsaSecp256k1VerifySignatureResponse = toEcdsaSecp256k1VerifySignatureResponse;
exports.toEcdsaSecp256r1VerifySignatureResponse = toEcdsaSecp256r1VerifySignatureResponse;
exports.toSrsInitSrsResponse = toSrsInitSrsResponse;
exports.toSrsInitGrumpkinSrsResponse = toSrsInitGrumpkinSrsResponse;
exports.toShutdownResponse = toShutdownResponse;
exports.fromCircuitComputeVkResponse = fromCircuitComputeVkResponse;
exports.fromCircuitInput = fromCircuitInput;
exports.fromProofSystemSettings = fromProofSystemSettings;
exports.fromCircuitProve = fromCircuitProve;
exports.fromCircuitInputNoVK = fromCircuitInputNoVK;
exports.fromCircuitComputeVk = fromCircuitComputeVk;
exports.fromCircuitStats = fromCircuitStats;
exports.fromCircuitVerify = fromCircuitVerify;
exports.fromChonkComputeVk = fromChonkComputeVk;
exports.fromChonkStart = fromChonkStart;
exports.fromChonkLoad = fromChonkLoad;
exports.fromChonkAccumulate = fromChonkAccumulate;
exports.fromChonkProve = fromChonkProve;
exports.fromGoblinProof = fromGoblinProof;
exports.fromChonkProof = fromChonkProof;
exports.fromChonkVerify = fromChonkVerify;
exports.fromVkAsFields = fromVkAsFields;
exports.fromMegaVkAsFields = fromMegaVkAsFields;
exports.fromCircuitWriteSolidityVerifier = fromCircuitWriteSolidityVerifier;
exports.fromChonkCheckPrecomputedVk = fromChonkCheckPrecomputedVk;
exports.fromChonkStats = fromChonkStats;
exports.fromPoseidon2Hash = fromPoseidon2Hash;
exports.fromPoseidon2Permutation = fromPoseidon2Permutation;
exports.fromPedersenCommit = fromPedersenCommit;
exports.fromPedersenHash = fromPedersenHash;
exports.fromPedersenHashBuffer = fromPedersenHashBuffer;
exports.fromBlake2s = fromBlake2s;
exports.fromBlake2sToField = fromBlake2sToField;
exports.fromAesEncrypt = fromAesEncrypt;
exports.fromAesDecrypt = fromAesDecrypt;
exports.fromGrumpkinPoint = fromGrumpkinPoint;
exports.fromGrumpkinMul = fromGrumpkinMul;
exports.fromGrumpkinAdd = fromGrumpkinAdd;
exports.fromGrumpkinBatchMul = fromGrumpkinBatchMul;
exports.fromGrumpkinGetRandomFr = fromGrumpkinGetRandomFr;
exports.fromGrumpkinReduce512 = fromGrumpkinReduce512;
exports.fromSecp256k1Point = fromSecp256k1Point;
exports.fromSecp256k1Mul = fromSecp256k1Mul;
exports.fromSecp256k1GetRandomFr = fromSecp256k1GetRandomFr;
exports.fromSecp256k1Reduce512 = fromSecp256k1Reduce512;
exports.fromBn254FrSqrt = fromBn254FrSqrt;
exports.fromBn254FqSqrt = fromBn254FqSqrt;
exports.fromBn254G1Point = fromBn254G1Point;
exports.fromBn254G1Mul = fromBn254G1Mul;
exports.fromBn254G2Point = fromBn254G2Point;
exports.fromBn254G2Mul = fromBn254G2Mul;
exports.fromBn254G1IsOnCurve = fromBn254G1IsOnCurve;
exports.fromBn254G1FromCompressed = fromBn254G1FromCompressed;
exports.fromSchnorrComputePublicKey = fromSchnorrComputePublicKey;
exports.fromSchnorrConstructSignature = fromSchnorrConstructSignature;
exports.fromSchnorrVerifySignature = fromSchnorrVerifySignature;
exports.fromEcdsaSecp256k1ComputePublicKey = fromEcdsaSecp256k1ComputePublicKey;
exports.fromEcdsaSecp256r1ComputePublicKey = fromEcdsaSecp256r1ComputePublicKey;
exports.fromEcdsaSecp256k1ConstructSignature = fromEcdsaSecp256k1ConstructSignature;
exports.fromEcdsaSecp256r1ConstructSignature = fromEcdsaSecp256r1ConstructSignature;
exports.fromEcdsaSecp256k1RecoverPublicKey = fromEcdsaSecp256k1RecoverPublicKey;
exports.fromEcdsaSecp256r1RecoverPublicKey = fromEcdsaSecp256r1RecoverPublicKey;
exports.fromEcdsaSecp256k1VerifySignature = fromEcdsaSecp256k1VerifySignature;
exports.fromSecp256r1Point = fromSecp256r1Point;
exports.fromEcdsaSecp256r1VerifySignature = fromEcdsaSecp256r1VerifySignature;
exports.fromSrsInitSrs = fromSrsInitSrs;
exports.fromSrsInitGrumpkinSrs = fromSrsInitGrumpkinSrs;
exports.fromShutdown = fromShutdown;
exports.fromErrorResponse = fromErrorResponse;
exports.fromCircuitProveResponse = fromCircuitProveResponse;
exports.fromCircuitInfoResponse = fromCircuitInfoResponse;
exports.fromCircuitVerifyResponse = fromCircuitVerifyResponse;
exports.fromChonkComputeVkResponse = fromChonkComputeVkResponse;
exports.fromChonkStartResponse = fromChonkStartResponse;
exports.fromChonkLoadResponse = fromChonkLoadResponse;
exports.fromChonkAccumulateResponse = fromChonkAccumulateResponse;
exports.fromChonkProveResponse = fromChonkProveResponse;
exports.fromChonkVerifyResponse = fromChonkVerifyResponse;
exports.fromVkAsFieldsResponse = fromVkAsFieldsResponse;
exports.fromMegaVkAsFieldsResponse = fromMegaVkAsFieldsResponse;
exports.fromCircuitWriteSolidityVerifierResponse = fromCircuitWriteSolidityVerifierResponse;
exports.fromChonkCheckPrecomputedVkResponse = fromChonkCheckPrecomputedVkResponse;
exports.fromChonkStatsResponse = fromChonkStatsResponse;
exports.fromPoseidon2HashResponse = fromPoseidon2HashResponse;
exports.fromPoseidon2PermutationResponse = fromPoseidon2PermutationResponse;
exports.fromPedersenCommitResponse = fromPedersenCommitResponse;
exports.fromPedersenHashResponse = fromPedersenHashResponse;
exports.fromPedersenHashBufferResponse = fromPedersenHashBufferResponse;
exports.fromBlake2sResponse = fromBlake2sResponse;
exports.fromBlake2sToFieldResponse = fromBlake2sToFieldResponse;
exports.fromAesEncryptResponse = fromAesEncryptResponse;
exports.fromAesDecryptResponse = fromAesDecryptResponse;
exports.fromGrumpkinMulResponse = fromGrumpkinMulResponse;
exports.fromGrumpkinAddResponse = fromGrumpkinAddResponse;
exports.fromGrumpkinBatchMulResponse = fromGrumpkinBatchMulResponse;
exports.fromGrumpkinGetRandomFrResponse = fromGrumpkinGetRandomFrResponse;
exports.fromGrumpkinReduce512Response = fromGrumpkinReduce512Response;
exports.fromSecp256k1MulResponse = fromSecp256k1MulResponse;
exports.fromSecp256k1GetRandomFrResponse = fromSecp256k1GetRandomFrResponse;
exports.fromSecp256k1Reduce512Response = fromSecp256k1Reduce512Response;
exports.fromBn254FrSqrtResponse = fromBn254FrSqrtResponse;
exports.fromBn254FqSqrtResponse = fromBn254FqSqrtResponse;
exports.fromBn254G1MulResponse = fromBn254G1MulResponse;
exports.fromBn254G2MulResponse = fromBn254G2MulResponse;
exports.fromBn254G1IsOnCurveResponse = fromBn254G1IsOnCurveResponse;
exports.fromBn254G1FromCompressedResponse = fromBn254G1FromCompressedResponse;
exports.fromSchnorrComputePublicKeyResponse = fromSchnorrComputePublicKeyResponse;
exports.fromSchnorrConstructSignatureResponse = fromSchnorrConstructSignatureResponse;
exports.fromSchnorrVerifySignatureResponse = fromSchnorrVerifySignatureResponse;
exports.fromEcdsaSecp256k1ComputePublicKeyResponse = fromEcdsaSecp256k1ComputePublicKeyResponse;
exports.fromEcdsaSecp256r1ComputePublicKeyResponse = fromEcdsaSecp256r1ComputePublicKeyResponse;
exports.fromEcdsaSecp256k1ConstructSignatureResponse = fromEcdsaSecp256k1ConstructSignatureResponse;
exports.fromEcdsaSecp256r1ConstructSignatureResponse = fromEcdsaSecp256r1ConstructSignatureResponse;
exports.fromEcdsaSecp256k1RecoverPublicKeyResponse = fromEcdsaSecp256k1RecoverPublicKeyResponse;
exports.fromEcdsaSecp256r1RecoverPublicKeyResponse = fromEcdsaSecp256r1RecoverPublicKeyResponse;
exports.fromEcdsaSecp256k1VerifySignatureResponse = fromEcdsaSecp256k1VerifySignatureResponse;
exports.fromEcdsaSecp256r1VerifySignatureResponse = fromEcdsaSecp256r1VerifySignatureResponse;
exports.fromSrsInitSrsResponse = fromSrsInitSrsResponse;
exports.fromSrsInitGrumpkinSrsResponse = fromSrsInitGrumpkinSrsResponse;
exports.fromShutdownResponse = fromShutdownResponse;
// Conversion functions (exported)
function toCircuitComputeVkResponse(o) {
    if (o.bytes === undefined) {
        throw new Error("Expected bytes in CircuitComputeVkResponse deserialization");
    }
    if (o.fields === undefined) {
        throw new Error("Expected fields in CircuitComputeVkResponse deserialization");
    }
    if (o.hash === undefined) {
        throw new Error("Expected hash in CircuitComputeVkResponse deserialization");
    }
    ;
    return {
        bytes: o.bytes,
        fields: o.fields,
        hash: o.hash,
    };
}
function toCircuitInput(o) {
    if (o.name === undefined) {
        throw new Error("Expected name in CircuitInput deserialization");
    }
    if (o.bytecode === undefined) {
        throw new Error("Expected bytecode in CircuitInput deserialization");
    }
    if (o.verification_key === undefined) {
        throw new Error("Expected verification_key in CircuitInput deserialization");
    }
    ;
    return {
        name: o.name,
        bytecode: o.bytecode,
        verificationKey: o.verification_key,
    };
}
function toProofSystemSettings(o) {
    if (o.ipa_accumulation === undefined) {
        throw new Error("Expected ipa_accumulation in ProofSystemSettings deserialization");
    }
    if (o.oracle_hash_type === undefined) {
        throw new Error("Expected oracle_hash_type in ProofSystemSettings deserialization");
    }
    if (o.disable_zk === undefined) {
        throw new Error("Expected disable_zk in ProofSystemSettings deserialization");
    }
    if (o.optimized_solidity_verifier === undefined) {
        throw new Error("Expected optimized_solidity_verifier in ProofSystemSettings deserialization");
    }
    ;
    return {
        ipaAccumulation: o.ipa_accumulation,
        oracleHashType: o.oracle_hash_type,
        disableZk: o.disable_zk,
        optimizedSolidityVerifier: o.optimized_solidity_verifier,
    };
}
function toCircuitProve(o) {
    if (o.circuit === undefined) {
        throw new Error("Expected circuit in CircuitProve deserialization");
    }
    if (o.witness === undefined) {
        throw new Error("Expected witness in CircuitProve deserialization");
    }
    if (o.settings === undefined) {
        throw new Error("Expected settings in CircuitProve deserialization");
    }
    ;
    return {
        circuit: toCircuitInput(o.circuit),
        witness: o.witness,
        settings: toProofSystemSettings(o.settings),
    };
}
function toCircuitInputNoVK(o) {
    if (o.name === undefined) {
        throw new Error("Expected name in CircuitInputNoVK deserialization");
    }
    if (o.bytecode === undefined) {
        throw new Error("Expected bytecode in CircuitInputNoVK deserialization");
    }
    ;
    return {
        name: o.name,
        bytecode: o.bytecode,
    };
}
function toCircuitComputeVk(o) {
    if (o.circuit === undefined) {
        throw new Error("Expected circuit in CircuitComputeVk deserialization");
    }
    if (o.settings === undefined) {
        throw new Error("Expected settings in CircuitComputeVk deserialization");
    }
    ;
    return {
        circuit: toCircuitInputNoVK(o.circuit),
        settings: toProofSystemSettings(o.settings),
    };
}
function toCircuitStats(o) {
    if (o.circuit === undefined) {
        throw new Error("Expected circuit in CircuitStats deserialization");
    }
    if (o.include_gates_per_opcode === undefined) {
        throw new Error("Expected include_gates_per_opcode in CircuitStats deserialization");
    }
    if (o.settings === undefined) {
        throw new Error("Expected settings in CircuitStats deserialization");
    }
    ;
    return {
        circuit: toCircuitInput(o.circuit),
        includeGatesPerOpcode: o.include_gates_per_opcode,
        settings: toProofSystemSettings(o.settings),
    };
}
function toCircuitVerify(o) {
    if (o.verification_key === undefined) {
        throw new Error("Expected verification_key in CircuitVerify deserialization");
    }
    if (o.public_inputs === undefined) {
        throw new Error("Expected public_inputs in CircuitVerify deserialization");
    }
    if (o.proof === undefined) {
        throw new Error("Expected proof in CircuitVerify deserialization");
    }
    if (o.settings === undefined) {
        throw new Error("Expected settings in CircuitVerify deserialization");
    }
    ;
    return {
        verificationKey: o.verification_key,
        publicInputs: o.public_inputs,
        proof: o.proof,
        settings: toProofSystemSettings(o.settings),
    };
}
function toChonkComputeVk(o) {
    if (o.circuit === undefined) {
        throw new Error("Expected circuit in ChonkComputeVk deserialization");
    }
    ;
    return {
        circuit: toCircuitInputNoVK(o.circuit),
    };
}
function toChonkStart(o) {
    if (o.num_circuits === undefined) {
        throw new Error("Expected num_circuits in ChonkStart deserialization");
    }
    ;
    return {
        numCircuits: o.num_circuits,
    };
}
function toChonkLoad(o) {
    if (o.circuit === undefined) {
        throw new Error("Expected circuit in ChonkLoad deserialization");
    }
    ;
    return {
        circuit: toCircuitInput(o.circuit),
    };
}
function toChonkAccumulate(o) {
    if (o.witness === undefined) {
        throw new Error("Expected witness in ChonkAccumulate deserialization");
    }
    ;
    return {
        witness: o.witness,
    };
}
function toChonkProve(o) {
    return {};
}
function toGoblinProof(o) {
    if (o.merge_proof === undefined) {
        throw new Error("Expected merge_proof in GoblinProof deserialization");
    }
    if (o.eccvm_proof === undefined) {
        throw new Error("Expected eccvm_proof in GoblinProof deserialization");
    }
    if (o.ipa_proof === undefined) {
        throw new Error("Expected ipa_proof in GoblinProof deserialization");
    }
    if (o.translator_proof === undefined) {
        throw new Error("Expected translator_proof in GoblinProof deserialization");
    }
    ;
    return {
        mergeProof: o.merge_proof,
        eccvmProof: o.eccvm_proof,
        ipaProof: o.ipa_proof,
        translatorProof: o.translator_proof,
    };
}
function toChonkProof(o) {
    if (o.mega_proof === undefined) {
        throw new Error("Expected mega_proof in ChonkProof deserialization");
    }
    if (o.goblin_proof === undefined) {
        throw new Error("Expected goblin_proof in ChonkProof deserialization");
    }
    ;
    return {
        megaProof: o.mega_proof,
        goblinProof: toGoblinProof(o.goblin_proof),
    };
}
function toChonkVerify(o) {
    if (o.proof === undefined) {
        throw new Error("Expected proof in ChonkVerify deserialization");
    }
    if (o.vk === undefined) {
        throw new Error("Expected vk in ChonkVerify deserialization");
    }
    ;
    return {
        proof: toChonkProof(o.proof),
        vk: o.vk,
    };
}
function toVkAsFields(o) {
    if (o.verification_key === undefined) {
        throw new Error("Expected verification_key in VkAsFields deserialization");
    }
    ;
    return {
        verificationKey: o.verification_key,
    };
}
function toMegaVkAsFields(o) {
    if (o.verification_key === undefined) {
        throw new Error("Expected verification_key in MegaVkAsFields deserialization");
    }
    ;
    return {
        verificationKey: o.verification_key,
    };
}
function toCircuitWriteSolidityVerifier(o) {
    if (o.verification_key === undefined) {
        throw new Error("Expected verification_key in CircuitWriteSolidityVerifier deserialization");
    }
    if (o.settings === undefined) {
        throw new Error("Expected settings in CircuitWriteSolidityVerifier deserialization");
    }
    ;
    return {
        verificationKey: o.verification_key,
        settings: toProofSystemSettings(o.settings),
    };
}
function toChonkCheckPrecomputedVk(o) {
    if (o.circuit === undefined) {
        throw new Error("Expected circuit in ChonkCheckPrecomputedVk deserialization");
    }
    ;
    return {
        circuit: toCircuitInput(o.circuit),
    };
}
function toChonkStats(o) {
    if (o.circuit === undefined) {
        throw new Error("Expected circuit in ChonkStats deserialization");
    }
    if (o.include_gates_per_opcode === undefined) {
        throw new Error("Expected include_gates_per_opcode in ChonkStats deserialization");
    }
    ;
    return {
        circuit: toCircuitInputNoVK(o.circuit),
        includeGatesPerOpcode: o.include_gates_per_opcode,
    };
}
function toPoseidon2Hash(o) {
    if (o.inputs === undefined) {
        throw new Error("Expected inputs in Poseidon2Hash deserialization");
    }
    ;
    return {
        inputs: o.inputs,
    };
}
function toPoseidon2Permutation(o) {
    if (o.inputs === undefined) {
        throw new Error("Expected inputs in Poseidon2Permutation deserialization");
    }
    ;
    return {
        inputs: o.inputs,
    };
}
function toPedersenCommit(o) {
    if (o.inputs === undefined) {
        throw new Error("Expected inputs in PedersenCommit deserialization");
    }
    if (o.hash_index === undefined) {
        throw new Error("Expected hash_index in PedersenCommit deserialization");
    }
    ;
    return {
        inputs: o.inputs,
        hashIndex: o.hash_index,
    };
}
function toPedersenHash(o) {
    if (o.inputs === undefined) {
        throw new Error("Expected inputs in PedersenHash deserialization");
    }
    if (o.hash_index === undefined) {
        throw new Error("Expected hash_index in PedersenHash deserialization");
    }
    ;
    return {
        inputs: o.inputs,
        hashIndex: o.hash_index,
    };
}
function toPedersenHashBuffer(o) {
    if (o.input === undefined) {
        throw new Error("Expected input in PedersenHashBuffer deserialization");
    }
    if (o.hash_index === undefined) {
        throw new Error("Expected hash_index in PedersenHashBuffer deserialization");
    }
    ;
    return {
        input: o.input,
        hashIndex: o.hash_index,
    };
}
function toBlake2s(o) {
    if (o.data === undefined) {
        throw new Error("Expected data in Blake2s deserialization");
    }
    ;
    return {
        data: o.data,
    };
}
function toBlake2sToField(o) {
    if (o.data === undefined) {
        throw new Error("Expected data in Blake2sToField deserialization");
    }
    ;
    return {
        data: o.data,
    };
}
function toAesEncrypt(o) {
    if (o.plaintext === undefined) {
        throw new Error("Expected plaintext in AesEncrypt deserialization");
    }
    if (o.iv === undefined) {
        throw new Error("Expected iv in AesEncrypt deserialization");
    }
    if (o.key === undefined) {
        throw new Error("Expected key in AesEncrypt deserialization");
    }
    if (o.length === undefined) {
        throw new Error("Expected length in AesEncrypt deserialization");
    }
    ;
    return {
        plaintext: o.plaintext,
        iv: o.iv,
        key: o.key,
        length: o.length,
    };
}
function toAesDecrypt(o) {
    if (o.ciphertext === undefined) {
        throw new Error("Expected ciphertext in AesDecrypt deserialization");
    }
    if (o.iv === undefined) {
        throw new Error("Expected iv in AesDecrypt deserialization");
    }
    if (o.key === undefined) {
        throw new Error("Expected key in AesDecrypt deserialization");
    }
    if (o.length === undefined) {
        throw new Error("Expected length in AesDecrypt deserialization");
    }
    ;
    return {
        ciphertext: o.ciphertext,
        iv: o.iv,
        key: o.key,
        length: o.length,
    };
}
function toGrumpkinPoint(o) {
    if (o.x === undefined) {
        throw new Error("Expected x in GrumpkinPoint deserialization");
    }
    if (o.y === undefined) {
        throw new Error("Expected y in GrumpkinPoint deserialization");
    }
    ;
    return {
        x: o.x,
        y: o.y,
    };
}
function toGrumpkinMul(o) {
    if (o.point === undefined) {
        throw new Error("Expected point in GrumpkinMul deserialization");
    }
    if (o.scalar === undefined) {
        throw new Error("Expected scalar in GrumpkinMul deserialization");
    }
    ;
    return {
        point: toGrumpkinPoint(o.point),
        scalar: o.scalar,
    };
}
function toGrumpkinAdd(o) {
    if (o.point_a === undefined) {
        throw new Error("Expected point_a in GrumpkinAdd deserialization");
    }
    if (o.point_b === undefined) {
        throw new Error("Expected point_b in GrumpkinAdd deserialization");
    }
    ;
    return {
        pointA: toGrumpkinPoint(o.point_a),
        pointB: toGrumpkinPoint(o.point_b),
    };
}
function toGrumpkinBatchMul(o) {
    if (o.points === undefined) {
        throw new Error("Expected points in GrumpkinBatchMul deserialization");
    }
    if (o.scalar === undefined) {
        throw new Error("Expected scalar in GrumpkinBatchMul deserialization");
    }
    ;
    return {
        points: o.points.map((v) => toGrumpkinPoint(v)),
        scalar: o.scalar,
    };
}
function toGrumpkinGetRandomFr(o) {
    if (o.dummy === undefined) {
        throw new Error("Expected dummy in GrumpkinGetRandomFr deserialization");
    }
    ;
    return {
        dummy: o.dummy,
    };
}
function toGrumpkinReduce512(o) {
    if (o.input === undefined) {
        throw new Error("Expected input in GrumpkinReduce512 deserialization");
    }
    ;
    return {
        input: o.input,
    };
}
function toSecp256k1Point(o) {
    if (o.x === undefined) {
        throw new Error("Expected x in Secp256k1Point deserialization");
    }
    if (o.y === undefined) {
        throw new Error("Expected y in Secp256k1Point deserialization");
    }
    ;
    return {
        x: o.x,
        y: o.y,
    };
}
function toSecp256k1Mul(o) {
    if (o.point === undefined) {
        throw new Error("Expected point in Secp256k1Mul deserialization");
    }
    if (o.scalar === undefined) {
        throw new Error("Expected scalar in Secp256k1Mul deserialization");
    }
    ;
    return {
        point: toSecp256k1Point(o.point),
        scalar: o.scalar,
    };
}
function toSecp256k1GetRandomFr(o) {
    if (o.dummy === undefined) {
        throw new Error("Expected dummy in Secp256k1GetRandomFr deserialization");
    }
    ;
    return {
        dummy: o.dummy,
    };
}
function toSecp256k1Reduce512(o) {
    if (o.input === undefined) {
        throw new Error("Expected input in Secp256k1Reduce512 deserialization");
    }
    ;
    return {
        input: o.input,
    };
}
function toBn254FrSqrt(o) {
    if (o.input === undefined) {
        throw new Error("Expected input in Bn254FrSqrt deserialization");
    }
    ;
    return {
        input: o.input,
    };
}
function toBn254FqSqrt(o) {
    if (o.input === undefined) {
        throw new Error("Expected input in Bn254FqSqrt deserialization");
    }
    ;
    return {
        input: o.input,
    };
}
function toBn254G1Point(o) {
    if (o.x === undefined) {
        throw new Error("Expected x in Bn254G1Point deserialization");
    }
    if (o.y === undefined) {
        throw new Error("Expected y in Bn254G1Point deserialization");
    }
    ;
    return {
        x: o.x,
        y: o.y,
    };
}
function toBn254G1Mul(o) {
    if (o.point === undefined) {
        throw new Error("Expected point in Bn254G1Mul deserialization");
    }
    if (o.scalar === undefined) {
        throw new Error("Expected scalar in Bn254G1Mul deserialization");
    }
    ;
    return {
        point: toBn254G1Point(o.point),
        scalar: o.scalar,
    };
}
function toBn254G2Point(o) {
    if (o.x === undefined) {
        throw new Error("Expected x in Bn254G2Point deserialization");
    }
    if (o.y === undefined) {
        throw new Error("Expected y in Bn254G2Point deserialization");
    }
    ;
    return {
        x: o.x,
        y: o.y,
    };
}
function toBn254G2Mul(o) {
    if (o.point === undefined) {
        throw new Error("Expected point in Bn254G2Mul deserialization");
    }
    if (o.scalar === undefined) {
        throw new Error("Expected scalar in Bn254G2Mul deserialization");
    }
    ;
    return {
        point: toBn254G2Point(o.point),
        scalar: o.scalar,
    };
}
function toBn254G1IsOnCurve(o) {
    if (o.point === undefined) {
        throw new Error("Expected point in Bn254G1IsOnCurve deserialization");
    }
    ;
    return {
        point: toBn254G1Point(o.point),
    };
}
function toBn254G1FromCompressed(o) {
    if (o.compressed === undefined) {
        throw new Error("Expected compressed in Bn254G1FromCompressed deserialization");
    }
    ;
    return {
        compressed: o.compressed,
    };
}
function toSchnorrComputePublicKey(o) {
    if (o.private_key === undefined) {
        throw new Error("Expected private_key in SchnorrComputePublicKey deserialization");
    }
    ;
    return {
        privateKey: o.private_key,
    };
}
function toSchnorrConstructSignature(o) {
    if (o.message === undefined) {
        throw new Error("Expected message in SchnorrConstructSignature deserialization");
    }
    if (o.private_key === undefined) {
        throw new Error("Expected private_key in SchnorrConstructSignature deserialization");
    }
    ;
    return {
        message: o.message,
        privateKey: o.private_key,
    };
}
function toSchnorrVerifySignature(o) {
    if (o.message === undefined) {
        throw new Error("Expected message in SchnorrVerifySignature deserialization");
    }
    if (o.public_key === undefined) {
        throw new Error("Expected public_key in SchnorrVerifySignature deserialization");
    }
    if (o.s === undefined) {
        throw new Error("Expected s in SchnorrVerifySignature deserialization");
    }
    if (o.e === undefined) {
        throw new Error("Expected e in SchnorrVerifySignature deserialization");
    }
    ;
    return {
        message: o.message,
        publicKey: toGrumpkinPoint(o.public_key),
        s: o.s,
        e: o.e,
    };
}
function toEcdsaSecp256k1ComputePublicKey(o) {
    if (o.private_key === undefined) {
        throw new Error("Expected private_key in EcdsaSecp256k1ComputePublicKey deserialization");
    }
    ;
    return {
        privateKey: o.private_key,
    };
}
function toEcdsaSecp256r1ComputePublicKey(o) {
    if (o.private_key === undefined) {
        throw new Error("Expected private_key in EcdsaSecp256r1ComputePublicKey deserialization");
    }
    ;
    return {
        privateKey: o.private_key,
    };
}
function toEcdsaSecp256k1ConstructSignature(o) {
    if (o.message === undefined) {
        throw new Error("Expected message in EcdsaSecp256k1ConstructSignature deserialization");
    }
    if (o.private_key === undefined) {
        throw new Error("Expected private_key in EcdsaSecp256k1ConstructSignature deserialization");
    }
    ;
    return {
        message: o.message,
        privateKey: o.private_key,
    };
}
function toEcdsaSecp256r1ConstructSignature(o) {
    if (o.message === undefined) {
        throw new Error("Expected message in EcdsaSecp256r1ConstructSignature deserialization");
    }
    if (o.private_key === undefined) {
        throw new Error("Expected private_key in EcdsaSecp256r1ConstructSignature deserialization");
    }
    ;
    return {
        message: o.message,
        privateKey: o.private_key,
    };
}
function toEcdsaSecp256k1RecoverPublicKey(o) {
    if (o.message === undefined) {
        throw new Error("Expected message in EcdsaSecp256k1RecoverPublicKey deserialization");
    }
    if (o.r === undefined) {
        throw new Error("Expected r in EcdsaSecp256k1RecoverPublicKey deserialization");
    }
    if (o.s === undefined) {
        throw new Error("Expected s in EcdsaSecp256k1RecoverPublicKey deserialization");
    }
    if (o.v === undefined) {
        throw new Error("Expected v in EcdsaSecp256k1RecoverPublicKey deserialization");
    }
    ;
    return {
        message: o.message,
        r: o.r,
        s: o.s,
        v: o.v,
    };
}
function toEcdsaSecp256r1RecoverPublicKey(o) {
    if (o.message === undefined) {
        throw new Error("Expected message in EcdsaSecp256r1RecoverPublicKey deserialization");
    }
    if (o.r === undefined) {
        throw new Error("Expected r in EcdsaSecp256r1RecoverPublicKey deserialization");
    }
    if (o.s === undefined) {
        throw new Error("Expected s in EcdsaSecp256r1RecoverPublicKey deserialization");
    }
    if (o.v === undefined) {
        throw new Error("Expected v in EcdsaSecp256r1RecoverPublicKey deserialization");
    }
    ;
    return {
        message: o.message,
        r: o.r,
        s: o.s,
        v: o.v,
    };
}
function toEcdsaSecp256k1VerifySignature(o) {
    if (o.message === undefined) {
        throw new Error("Expected message in EcdsaSecp256k1VerifySignature deserialization");
    }
    if (o.public_key === undefined) {
        throw new Error("Expected public_key in EcdsaSecp256k1VerifySignature deserialization");
    }
    if (o.r === undefined) {
        throw new Error("Expected r in EcdsaSecp256k1VerifySignature deserialization");
    }
    if (o.s === undefined) {
        throw new Error("Expected s in EcdsaSecp256k1VerifySignature deserialization");
    }
    if (o.v === undefined) {
        throw new Error("Expected v in EcdsaSecp256k1VerifySignature deserialization");
    }
    ;
    return {
        message: o.message,
        publicKey: toSecp256k1Point(o.public_key),
        r: o.r,
        s: o.s,
        v: o.v,
    };
}
function toSecp256r1Point(o) {
    if (o.x === undefined) {
        throw new Error("Expected x in Secp256r1Point deserialization");
    }
    if (o.y === undefined) {
        throw new Error("Expected y in Secp256r1Point deserialization");
    }
    ;
    return {
        x: o.x,
        y: o.y,
    };
}
function toEcdsaSecp256r1VerifySignature(o) {
    if (o.message === undefined) {
        throw new Error("Expected message in EcdsaSecp256r1VerifySignature deserialization");
    }
    if (o.public_key === undefined) {
        throw new Error("Expected public_key in EcdsaSecp256r1VerifySignature deserialization");
    }
    if (o.r === undefined) {
        throw new Error("Expected r in EcdsaSecp256r1VerifySignature deserialization");
    }
    if (o.s === undefined) {
        throw new Error("Expected s in EcdsaSecp256r1VerifySignature deserialization");
    }
    if (o.v === undefined) {
        throw new Error("Expected v in EcdsaSecp256r1VerifySignature deserialization");
    }
    ;
    return {
        message: o.message,
        publicKey: toSecp256r1Point(o.public_key),
        r: o.r,
        s: o.s,
        v: o.v,
    };
}
function toSrsInitSrs(o) {
    if (o.points_buf === undefined) {
        throw new Error("Expected points_buf in SrsInitSrs deserialization");
    }
    if (o.num_points === undefined) {
        throw new Error("Expected num_points in SrsInitSrs deserialization");
    }
    if (o.g2_point === undefined) {
        throw new Error("Expected g2_point in SrsInitSrs deserialization");
    }
    ;
    return {
        pointsBuf: o.points_buf,
        numPoints: o.num_points,
        g2Point: o.g2_point,
    };
}
function toSrsInitGrumpkinSrs(o) {
    if (o.points_buf === undefined) {
        throw new Error("Expected points_buf in SrsInitGrumpkinSrs deserialization");
    }
    if (o.num_points === undefined) {
        throw new Error("Expected num_points in SrsInitGrumpkinSrs deserialization");
    }
    ;
    return {
        pointsBuf: o.points_buf,
        numPoints: o.num_points,
    };
}
function toShutdown(o) {
    return {};
}
function toErrorResponse(o) {
    if (o.message === undefined) {
        throw new Error("Expected message in ErrorResponse deserialization");
    }
    ;
    return {
        message: o.message,
    };
}
function toCircuitProveResponse(o) {
    if (o.public_inputs === undefined) {
        throw new Error("Expected public_inputs in CircuitProveResponse deserialization");
    }
    if (o.proof === undefined) {
        throw new Error("Expected proof in CircuitProveResponse deserialization");
    }
    if (o.vk === undefined) {
        throw new Error("Expected vk in CircuitProveResponse deserialization");
    }
    ;
    return {
        publicInputs: o.public_inputs,
        proof: o.proof,
        vk: toCircuitComputeVkResponse(o.vk),
    };
}
function toCircuitInfoResponse(o) {
    if (o.num_gates === undefined) {
        throw new Error("Expected num_gates in CircuitInfoResponse deserialization");
    }
    if (o.num_gates_dyadic === undefined) {
        throw new Error("Expected num_gates_dyadic in CircuitInfoResponse deserialization");
    }
    if (o.num_acir_opcodes === undefined) {
        throw new Error("Expected num_acir_opcodes in CircuitInfoResponse deserialization");
    }
    if (o.gates_per_opcode === undefined) {
        throw new Error("Expected gates_per_opcode in CircuitInfoResponse deserialization");
    }
    ;
    return {
        numGates: o.num_gates,
        numGatesDyadic: o.num_gates_dyadic,
        numAcirOpcodes: o.num_acir_opcodes,
        gatesPerOpcode: o.gates_per_opcode,
    };
}
function toCircuitVerifyResponse(o) {
    if (o.verified === undefined) {
        throw new Error("Expected verified in CircuitVerifyResponse deserialization");
    }
    ;
    return {
        verified: o.verified,
    };
}
function toChonkComputeVkResponse(o) {
    if (o.bytes === undefined) {
        throw new Error("Expected bytes in ChonkComputeVkResponse deserialization");
    }
    if (o.fields === undefined) {
        throw new Error("Expected fields in ChonkComputeVkResponse deserialization");
    }
    ;
    return {
        bytes: o.bytes,
        fields: o.fields,
    };
}
function toChonkStartResponse(o) {
    return {};
}
function toChonkLoadResponse(o) {
    return {};
}
function toChonkAccumulateResponse(o) {
    return {};
}
function toChonkProveResponse(o) {
    if (o.proof === undefined) {
        throw new Error("Expected proof in ChonkProveResponse deserialization");
    }
    ;
    return {
        proof: toChonkProof(o.proof),
    };
}
function toChonkVerifyResponse(o) {
    if (o.valid === undefined) {
        throw new Error("Expected valid in ChonkVerifyResponse deserialization");
    }
    ;
    return {
        valid: o.valid,
    };
}
function toVkAsFieldsResponse(o) {
    if (o.fields === undefined) {
        throw new Error("Expected fields in VkAsFieldsResponse deserialization");
    }
    ;
    return {
        fields: o.fields,
    };
}
function toMegaVkAsFieldsResponse(o) {
    if (o.fields === undefined) {
        throw new Error("Expected fields in MegaVkAsFieldsResponse deserialization");
    }
    ;
    return {
        fields: o.fields,
    };
}
function toCircuitWriteSolidityVerifierResponse(o) {
    if (o.solidity_code === undefined) {
        throw new Error("Expected solidity_code in CircuitWriteSolidityVerifierResponse deserialization");
    }
    ;
    return {
        solidityCode: o.solidity_code,
    };
}
function toChonkCheckPrecomputedVkResponse(o) {
    if (o.valid === undefined) {
        throw new Error("Expected valid in ChonkCheckPrecomputedVkResponse deserialization");
    }
    if (o.actual_vk === undefined) {
        throw new Error("Expected actual_vk in ChonkCheckPrecomputedVkResponse deserialization");
    }
    ;
    return {
        valid: o.valid,
        actualVk: o.actual_vk,
    };
}
function toChonkStatsResponse(o) {
    if (o.acir_opcodes === undefined) {
        throw new Error("Expected acir_opcodes in ChonkStatsResponse deserialization");
    }
    if (o.circuit_size === undefined) {
        throw new Error("Expected circuit_size in ChonkStatsResponse deserialization");
    }
    if (o.gates_per_opcode === undefined) {
        throw new Error("Expected gates_per_opcode in ChonkStatsResponse deserialization");
    }
    ;
    return {
        acirOpcodes: o.acir_opcodes,
        circuitSize: o.circuit_size,
        gatesPerOpcode: o.gates_per_opcode,
    };
}
function toPoseidon2HashResponse(o) {
    if (o.hash === undefined) {
        throw new Error("Expected hash in Poseidon2HashResponse deserialization");
    }
    ;
    return {
        hash: o.hash,
    };
}
function toPoseidon2PermutationResponse(o) {
    if (o.outputs === undefined) {
        throw new Error("Expected outputs in Poseidon2PermutationResponse deserialization");
    }
    ;
    return {
        outputs: o.outputs,
    };
}
function toPedersenCommitResponse(o) {
    if (o.point === undefined) {
        throw new Error("Expected point in PedersenCommitResponse deserialization");
    }
    ;
    return {
        point: toGrumpkinPoint(o.point),
    };
}
function toPedersenHashResponse(o) {
    if (o.hash === undefined) {
        throw new Error("Expected hash in PedersenHashResponse deserialization");
    }
    ;
    return {
        hash: o.hash,
    };
}
function toPedersenHashBufferResponse(o) {
    if (o.hash === undefined) {
        throw new Error("Expected hash in PedersenHashBufferResponse deserialization");
    }
    ;
    return {
        hash: o.hash,
    };
}
function toBlake2sResponse(o) {
    if (o.hash === undefined) {
        throw new Error("Expected hash in Blake2sResponse deserialization");
    }
    ;
    return {
        hash: o.hash,
    };
}
function toBlake2sToFieldResponse(o) {
    if (o.field === undefined) {
        throw new Error("Expected field in Blake2sToFieldResponse deserialization");
    }
    ;
    return {
        field: o.field,
    };
}
function toAesEncryptResponse(o) {
    if (o.ciphertext === undefined) {
        throw new Error("Expected ciphertext in AesEncryptResponse deserialization");
    }
    ;
    return {
        ciphertext: o.ciphertext,
    };
}
function toAesDecryptResponse(o) {
    if (o.plaintext === undefined) {
        throw new Error("Expected plaintext in AesDecryptResponse deserialization");
    }
    ;
    return {
        plaintext: o.plaintext,
    };
}
function toGrumpkinMulResponse(o) {
    if (o.point === undefined) {
        throw new Error("Expected point in GrumpkinMulResponse deserialization");
    }
    ;
    return {
        point: toGrumpkinPoint(o.point),
    };
}
function toGrumpkinAddResponse(o) {
    if (o.point === undefined) {
        throw new Error("Expected point in GrumpkinAddResponse deserialization");
    }
    ;
    return {
        point: toGrumpkinPoint(o.point),
    };
}
function toGrumpkinBatchMulResponse(o) {
    if (o.points === undefined) {
        throw new Error("Expected points in GrumpkinBatchMulResponse deserialization");
    }
    ;
    return {
        points: o.points.map((v) => toGrumpkinPoint(v)),
    };
}
function toGrumpkinGetRandomFrResponse(o) {
    if (o.value === undefined) {
        throw new Error("Expected value in GrumpkinGetRandomFrResponse deserialization");
    }
    ;
    return {
        value: o.value,
    };
}
function toGrumpkinReduce512Response(o) {
    if (o.value === undefined) {
        throw new Error("Expected value in GrumpkinReduce512Response deserialization");
    }
    ;
    return {
        value: o.value,
    };
}
function toSecp256k1MulResponse(o) {
    if (o.point === undefined) {
        throw new Error("Expected point in Secp256k1MulResponse deserialization");
    }
    ;
    return {
        point: toSecp256k1Point(o.point),
    };
}
function toSecp256k1GetRandomFrResponse(o) {
    if (o.value === undefined) {
        throw new Error("Expected value in Secp256k1GetRandomFrResponse deserialization");
    }
    ;
    return {
        value: o.value,
    };
}
function toSecp256k1Reduce512Response(o) {
    if (o.value === undefined) {
        throw new Error("Expected value in Secp256k1Reduce512Response deserialization");
    }
    ;
    return {
        value: o.value,
    };
}
function toBn254FrSqrtResponse(o) {
    if (o.is_square_root === undefined) {
        throw new Error("Expected is_square_root in Bn254FrSqrtResponse deserialization");
    }
    if (o.value === undefined) {
        throw new Error("Expected value in Bn254FrSqrtResponse deserialization");
    }
    ;
    return {
        isSquareRoot: o.is_square_root,
        value: o.value,
    };
}
function toBn254FqSqrtResponse(o) {
    if (o.is_square_root === undefined) {
        throw new Error("Expected is_square_root in Bn254FqSqrtResponse deserialization");
    }
    if (o.value === undefined) {
        throw new Error("Expected value in Bn254FqSqrtResponse deserialization");
    }
    ;
    return {
        isSquareRoot: o.is_square_root,
        value: o.value,
    };
}
function toBn254G1MulResponse(o) {
    if (o.point === undefined) {
        throw new Error("Expected point in Bn254G1MulResponse deserialization");
    }
    ;
    return {
        point: toBn254G1Point(o.point),
    };
}
function toBn254G2MulResponse(o) {
    if (o.point === undefined) {
        throw new Error("Expected point in Bn254G2MulResponse deserialization");
    }
    ;
    return {
        point: toBn254G2Point(o.point),
    };
}
function toBn254G1IsOnCurveResponse(o) {
    if (o.is_on_curve === undefined) {
        throw new Error("Expected is_on_curve in Bn254G1IsOnCurveResponse deserialization");
    }
    ;
    return {
        isOnCurve: o.is_on_curve,
    };
}
function toBn254G1FromCompressedResponse(o) {
    if (o.point === undefined) {
        throw new Error("Expected point in Bn254G1FromCompressedResponse deserialization");
    }
    ;
    return {
        point: toBn254G1Point(o.point),
    };
}
function toSchnorrComputePublicKeyResponse(o) {
    if (o.public_key === undefined) {
        throw new Error("Expected public_key in SchnorrComputePublicKeyResponse deserialization");
    }
    ;
    return {
        publicKey: toGrumpkinPoint(o.public_key),
    };
}
function toSchnorrConstructSignatureResponse(o) {
    if (o.s === undefined) {
        throw new Error("Expected s in SchnorrConstructSignatureResponse deserialization");
    }
    if (o.e === undefined) {
        throw new Error("Expected e in SchnorrConstructSignatureResponse deserialization");
    }
    ;
    return {
        s: o.s,
        e: o.e,
    };
}
function toSchnorrVerifySignatureResponse(o) {
    if (o.verified === undefined) {
        throw new Error("Expected verified in SchnorrVerifySignatureResponse deserialization");
    }
    ;
    return {
        verified: o.verified,
    };
}
function toEcdsaSecp256k1ComputePublicKeyResponse(o) {
    if (o.public_key === undefined) {
        throw new Error("Expected public_key in EcdsaSecp256k1ComputePublicKeyResponse deserialization");
    }
    ;
    return {
        publicKey: toSecp256k1Point(o.public_key),
    };
}
function toEcdsaSecp256r1ComputePublicKeyResponse(o) {
    if (o.public_key === undefined) {
        throw new Error("Expected public_key in EcdsaSecp256r1ComputePublicKeyResponse deserialization");
    }
    ;
    return {
        publicKey: toSecp256r1Point(o.public_key),
    };
}
function toEcdsaSecp256k1ConstructSignatureResponse(o) {
    if (o.r === undefined) {
        throw new Error("Expected r in EcdsaSecp256k1ConstructSignatureResponse deserialization");
    }
    if (o.s === undefined) {
        throw new Error("Expected s in EcdsaSecp256k1ConstructSignatureResponse deserialization");
    }
    if (o.v === undefined) {
        throw new Error("Expected v in EcdsaSecp256k1ConstructSignatureResponse deserialization");
    }
    ;
    return {
        r: o.r,
        s: o.s,
        v: o.v,
    };
}
function toEcdsaSecp256r1ConstructSignatureResponse(o) {
    if (o.r === undefined) {
        throw new Error("Expected r in EcdsaSecp256r1ConstructSignatureResponse deserialization");
    }
    if (o.s === undefined) {
        throw new Error("Expected s in EcdsaSecp256r1ConstructSignatureResponse deserialization");
    }
    if (o.v === undefined) {
        throw new Error("Expected v in EcdsaSecp256r1ConstructSignatureResponse deserialization");
    }
    ;
    return {
        r: o.r,
        s: o.s,
        v: o.v,
    };
}
function toEcdsaSecp256k1RecoverPublicKeyResponse(o) {
    if (o.public_key === undefined) {
        throw new Error("Expected public_key in EcdsaSecp256k1RecoverPublicKeyResponse deserialization");
    }
    ;
    return {
        publicKey: toSecp256k1Point(o.public_key),
    };
}
function toEcdsaSecp256r1RecoverPublicKeyResponse(o) {
    if (o.public_key === undefined) {
        throw new Error("Expected public_key in EcdsaSecp256r1RecoverPublicKeyResponse deserialization");
    }
    ;
    return {
        publicKey: toSecp256r1Point(o.public_key),
    };
}
function toEcdsaSecp256k1VerifySignatureResponse(o) {
    if (o.verified === undefined) {
        throw new Error("Expected verified in EcdsaSecp256k1VerifySignatureResponse deserialization");
    }
    ;
    return {
        verified: o.verified,
    };
}
function toEcdsaSecp256r1VerifySignatureResponse(o) {
    if (o.verified === undefined) {
        throw new Error("Expected verified in EcdsaSecp256r1VerifySignatureResponse deserialization");
    }
    ;
    return {
        verified: o.verified,
    };
}
function toSrsInitSrsResponse(o) {
    if (o.dummy === undefined) {
        throw new Error("Expected dummy in SrsInitSrsResponse deserialization");
    }
    ;
    return {
        dummy: o.dummy,
    };
}
function toSrsInitGrumpkinSrsResponse(o) {
    if (o.dummy === undefined) {
        throw new Error("Expected dummy in SrsInitGrumpkinSrsResponse deserialization");
    }
    ;
    return {
        dummy: o.dummy,
    };
}
function toShutdownResponse(o) {
    return {};
}
function fromCircuitComputeVkResponse(o) {
    if (o.bytes === undefined) {
        throw new Error("Expected bytes in CircuitComputeVkResponse serialization");
    }
    if (o.fields === undefined) {
        throw new Error("Expected fields in CircuitComputeVkResponse serialization");
    }
    if (o.hash === undefined) {
        throw new Error("Expected hash in CircuitComputeVkResponse serialization");
    }
    ;
    return {
        bytes: o.bytes,
        fields: o.fields,
        hash: o.hash,
    };
}
function fromCircuitInput(o) {
    if (o.name === undefined) {
        throw new Error("Expected name in CircuitInput serialization");
    }
    if (o.bytecode === undefined) {
        throw new Error("Expected bytecode in CircuitInput serialization");
    }
    if (o.verificationKey === undefined) {
        throw new Error("Expected verificationKey in CircuitInput serialization");
    }
    ;
    return {
        name: o.name,
        bytecode: o.bytecode,
        verification_key: o.verificationKey,
    };
}
function fromProofSystemSettings(o) {
    if (o.ipaAccumulation === undefined) {
        throw new Error("Expected ipaAccumulation in ProofSystemSettings serialization");
    }
    if (o.oracleHashType === undefined) {
        throw new Error("Expected oracleHashType in ProofSystemSettings serialization");
    }
    if (o.disableZk === undefined) {
        throw new Error("Expected disableZk in ProofSystemSettings serialization");
    }
    if (o.optimizedSolidityVerifier === undefined) {
        throw new Error("Expected optimizedSolidityVerifier in ProofSystemSettings serialization");
    }
    ;
    return {
        ipa_accumulation: o.ipaAccumulation,
        oracle_hash_type: o.oracleHashType,
        disable_zk: o.disableZk,
        optimized_solidity_verifier: o.optimizedSolidityVerifier,
    };
}
function fromCircuitProve(o) {
    if (o.circuit === undefined) {
        throw new Error("Expected circuit in CircuitProve serialization");
    }
    if (o.witness === undefined) {
        throw new Error("Expected witness in CircuitProve serialization");
    }
    if (o.settings === undefined) {
        throw new Error("Expected settings in CircuitProve serialization");
    }
    ;
    return {
        circuit: fromCircuitInput(o.circuit),
        witness: o.witness,
        settings: fromProofSystemSettings(o.settings),
    };
}
function fromCircuitInputNoVK(o) {
    if (o.name === undefined) {
        throw new Error("Expected name in CircuitInputNoVK serialization");
    }
    if (o.bytecode === undefined) {
        throw new Error("Expected bytecode in CircuitInputNoVK serialization");
    }
    ;
    return {
        name: o.name,
        bytecode: o.bytecode,
    };
}
function fromCircuitComputeVk(o) {
    if (o.circuit === undefined) {
        throw new Error("Expected circuit in CircuitComputeVk serialization");
    }
    if (o.settings === undefined) {
        throw new Error("Expected settings in CircuitComputeVk serialization");
    }
    ;
    return {
        circuit: fromCircuitInputNoVK(o.circuit),
        settings: fromProofSystemSettings(o.settings),
    };
}
function fromCircuitStats(o) {
    if (o.circuit === undefined) {
        throw new Error("Expected circuit in CircuitStats serialization");
    }
    if (o.includeGatesPerOpcode === undefined) {
        throw new Error("Expected includeGatesPerOpcode in CircuitStats serialization");
    }
    if (o.settings === undefined) {
        throw new Error("Expected settings in CircuitStats serialization");
    }
    ;
    return {
        circuit: fromCircuitInput(o.circuit),
        include_gates_per_opcode: o.includeGatesPerOpcode,
        settings: fromProofSystemSettings(o.settings),
    };
}
function fromCircuitVerify(o) {
    if (o.verificationKey === undefined) {
        throw new Error("Expected verificationKey in CircuitVerify serialization");
    }
    if (o.publicInputs === undefined) {
        throw new Error("Expected publicInputs in CircuitVerify serialization");
    }
    if (o.proof === undefined) {
        throw new Error("Expected proof in CircuitVerify serialization");
    }
    if (o.settings === undefined) {
        throw new Error("Expected settings in CircuitVerify serialization");
    }
    ;
    return {
        verification_key: o.verificationKey,
        public_inputs: o.publicInputs,
        proof: o.proof,
        settings: fromProofSystemSettings(o.settings),
    };
}
function fromChonkComputeVk(o) {
    if (o.circuit === undefined) {
        throw new Error("Expected circuit in ChonkComputeVk serialization");
    }
    ;
    return {
        circuit: fromCircuitInputNoVK(o.circuit),
    };
}
function fromChonkStart(o) {
    if (o.numCircuits === undefined) {
        throw new Error("Expected numCircuits in ChonkStart serialization");
    }
    ;
    return {
        num_circuits: o.numCircuits,
    };
}
function fromChonkLoad(o) {
    if (o.circuit === undefined) {
        throw new Error("Expected circuit in ChonkLoad serialization");
    }
    ;
    return {
        circuit: fromCircuitInput(o.circuit),
    };
}
function fromChonkAccumulate(o) {
    if (o.witness === undefined) {
        throw new Error("Expected witness in ChonkAccumulate serialization");
    }
    ;
    return {
        witness: o.witness,
    };
}
function fromChonkProve(o) {
    return {};
}
function fromGoblinProof(o) {
    if (o.mergeProof === undefined) {
        throw new Error("Expected mergeProof in GoblinProof serialization");
    }
    if (o.eccvmProof === undefined) {
        throw new Error("Expected eccvmProof in GoblinProof serialization");
    }
    if (o.ipaProof === undefined) {
        throw new Error("Expected ipaProof in GoblinProof serialization");
    }
    if (o.translatorProof === undefined) {
        throw new Error("Expected translatorProof in GoblinProof serialization");
    }
    ;
    return {
        merge_proof: o.mergeProof,
        eccvm_proof: o.eccvmProof,
        ipa_proof: o.ipaProof,
        translator_proof: o.translatorProof,
    };
}
function fromChonkProof(o) {
    if (o.megaProof === undefined) {
        throw new Error("Expected megaProof in ChonkProof serialization");
    }
    if (o.goblinProof === undefined) {
        throw new Error("Expected goblinProof in ChonkProof serialization");
    }
    ;
    return {
        mega_proof: o.megaProof,
        goblin_proof: fromGoblinProof(o.goblinProof),
    };
}
function fromChonkVerify(o) {
    if (o.proof === undefined) {
        throw new Error("Expected proof in ChonkVerify serialization");
    }
    if (o.vk === undefined) {
        throw new Error("Expected vk in ChonkVerify serialization");
    }
    ;
    return {
        proof: fromChonkProof(o.proof),
        vk: o.vk,
    };
}
function fromVkAsFields(o) {
    if (o.verificationKey === undefined) {
        throw new Error("Expected verificationKey in VkAsFields serialization");
    }
    ;
    return {
        verification_key: o.verificationKey,
    };
}
function fromMegaVkAsFields(o) {
    if (o.verificationKey === undefined) {
        throw new Error("Expected verificationKey in MegaVkAsFields serialization");
    }
    ;
    return {
        verification_key: o.verificationKey,
    };
}
function fromCircuitWriteSolidityVerifier(o) {
    if (o.verificationKey === undefined) {
        throw new Error("Expected verificationKey in CircuitWriteSolidityVerifier serialization");
    }
    if (o.settings === undefined) {
        throw new Error("Expected settings in CircuitWriteSolidityVerifier serialization");
    }
    ;
    return {
        verification_key: o.verificationKey,
        settings: fromProofSystemSettings(o.settings),
    };
}
function fromChonkCheckPrecomputedVk(o) {
    if (o.circuit === undefined) {
        throw new Error("Expected circuit in ChonkCheckPrecomputedVk serialization");
    }
    ;
    return {
        circuit: fromCircuitInput(o.circuit),
    };
}
function fromChonkStats(o) {
    if (o.circuit === undefined) {
        throw new Error("Expected circuit in ChonkStats serialization");
    }
    if (o.includeGatesPerOpcode === undefined) {
        throw new Error("Expected includeGatesPerOpcode in ChonkStats serialization");
    }
    ;
    return {
        circuit: fromCircuitInputNoVK(o.circuit),
        include_gates_per_opcode: o.includeGatesPerOpcode,
    };
}
function fromPoseidon2Hash(o) {
    if (o.inputs === undefined) {
        throw new Error("Expected inputs in Poseidon2Hash serialization");
    }
    ;
    return {
        inputs: o.inputs,
    };
}
function fromPoseidon2Permutation(o) {
    if (o.inputs === undefined) {
        throw new Error("Expected inputs in Poseidon2Permutation serialization");
    }
    ;
    return {
        inputs: o.inputs,
    };
}
function fromPedersenCommit(o) {
    if (o.inputs === undefined) {
        throw new Error("Expected inputs in PedersenCommit serialization");
    }
    if (o.hashIndex === undefined) {
        throw new Error("Expected hashIndex in PedersenCommit serialization");
    }
    ;
    return {
        inputs: o.inputs,
        hash_index: o.hashIndex,
    };
}
function fromPedersenHash(o) {
    if (o.inputs === undefined) {
        throw new Error("Expected inputs in PedersenHash serialization");
    }
    if (o.hashIndex === undefined) {
        throw new Error("Expected hashIndex in PedersenHash serialization");
    }
    ;
    return {
        inputs: o.inputs,
        hash_index: o.hashIndex,
    };
}
function fromPedersenHashBuffer(o) {
    if (o.input === undefined) {
        throw new Error("Expected input in PedersenHashBuffer serialization");
    }
    if (o.hashIndex === undefined) {
        throw new Error("Expected hashIndex in PedersenHashBuffer serialization");
    }
    ;
    return {
        input: o.input,
        hash_index: o.hashIndex,
    };
}
function fromBlake2s(o) {
    if (o.data === undefined) {
        throw new Error("Expected data in Blake2s serialization");
    }
    ;
    return {
        data: o.data,
    };
}
function fromBlake2sToField(o) {
    if (o.data === undefined) {
        throw new Error("Expected data in Blake2sToField serialization");
    }
    ;
    return {
        data: o.data,
    };
}
function fromAesEncrypt(o) {
    if (o.plaintext === undefined) {
        throw new Error("Expected plaintext in AesEncrypt serialization");
    }
    if (o.iv === undefined) {
        throw new Error("Expected iv in AesEncrypt serialization");
    }
    if (o.key === undefined) {
        throw new Error("Expected key in AesEncrypt serialization");
    }
    if (o.length === undefined) {
        throw new Error("Expected length in AesEncrypt serialization");
    }
    ;
    return {
        plaintext: o.plaintext,
        iv: o.iv,
        key: o.key,
        length: o.length,
    };
}
function fromAesDecrypt(o) {
    if (o.ciphertext === undefined) {
        throw new Error("Expected ciphertext in AesDecrypt serialization");
    }
    if (o.iv === undefined) {
        throw new Error("Expected iv in AesDecrypt serialization");
    }
    if (o.key === undefined) {
        throw new Error("Expected key in AesDecrypt serialization");
    }
    if (o.length === undefined) {
        throw new Error("Expected length in AesDecrypt serialization");
    }
    ;
    return {
        ciphertext: o.ciphertext,
        iv: o.iv,
        key: o.key,
        length: o.length,
    };
}
function fromGrumpkinPoint(o) {
    if (o.x === undefined) {
        throw new Error("Expected x in GrumpkinPoint serialization");
    }
    if (o.y === undefined) {
        throw new Error("Expected y in GrumpkinPoint serialization");
    }
    ;
    return {
        x: o.x,
        y: o.y,
    };
}
function fromGrumpkinMul(o) {
    if (o.point === undefined) {
        throw new Error("Expected point in GrumpkinMul serialization");
    }
    if (o.scalar === undefined) {
        throw new Error("Expected scalar in GrumpkinMul serialization");
    }
    ;
    return {
        point: fromGrumpkinPoint(o.point),
        scalar: o.scalar,
    };
}
function fromGrumpkinAdd(o) {
    if (o.pointA === undefined) {
        throw new Error("Expected pointA in GrumpkinAdd serialization");
    }
    if (o.pointB === undefined) {
        throw new Error("Expected pointB in GrumpkinAdd serialization");
    }
    ;
    return {
        point_a: fromGrumpkinPoint(o.pointA),
        point_b: fromGrumpkinPoint(o.pointB),
    };
}
function fromGrumpkinBatchMul(o) {
    if (o.points === undefined) {
        throw new Error("Expected points in GrumpkinBatchMul serialization");
    }
    if (o.scalar === undefined) {
        throw new Error("Expected scalar in GrumpkinBatchMul serialization");
    }
    ;
    return {
        points: o.points.map((v) => fromGrumpkinPoint(v)),
        scalar: o.scalar,
    };
}
function fromGrumpkinGetRandomFr(o) {
    if (o.dummy === undefined) {
        throw new Error("Expected dummy in GrumpkinGetRandomFr serialization");
    }
    ;
    return {
        dummy: o.dummy,
    };
}
function fromGrumpkinReduce512(o) {
    if (o.input === undefined) {
        throw new Error("Expected input in GrumpkinReduce512 serialization");
    }
    ;
    return {
        input: o.input,
    };
}
function fromSecp256k1Point(o) {
    if (o.x === undefined) {
        throw new Error("Expected x in Secp256k1Point serialization");
    }
    if (o.y === undefined) {
        throw new Error("Expected y in Secp256k1Point serialization");
    }
    ;
    return {
        x: o.x,
        y: o.y,
    };
}
function fromSecp256k1Mul(o) {
    if (o.point === undefined) {
        throw new Error("Expected point in Secp256k1Mul serialization");
    }
    if (o.scalar === undefined) {
        throw new Error("Expected scalar in Secp256k1Mul serialization");
    }
    ;
    return {
        point: fromSecp256k1Point(o.point),
        scalar: o.scalar,
    };
}
function fromSecp256k1GetRandomFr(o) {
    if (o.dummy === undefined) {
        throw new Error("Expected dummy in Secp256k1GetRandomFr serialization");
    }
    ;
    return {
        dummy: o.dummy,
    };
}
function fromSecp256k1Reduce512(o) {
    if (o.input === undefined) {
        throw new Error("Expected input in Secp256k1Reduce512 serialization");
    }
    ;
    return {
        input: o.input,
    };
}
function fromBn254FrSqrt(o) {
    if (o.input === undefined) {
        throw new Error("Expected input in Bn254FrSqrt serialization");
    }
    ;
    return {
        input: o.input,
    };
}
function fromBn254FqSqrt(o) {
    if (o.input === undefined) {
        throw new Error("Expected input in Bn254FqSqrt serialization");
    }
    ;
    return {
        input: o.input,
    };
}
function fromBn254G1Point(o) {
    if (o.x === undefined) {
        throw new Error("Expected x in Bn254G1Point serialization");
    }
    if (o.y === undefined) {
        throw new Error("Expected y in Bn254G1Point serialization");
    }
    ;
    return {
        x: o.x,
        y: o.y,
    };
}
function fromBn254G1Mul(o) {
    if (o.point === undefined) {
        throw new Error("Expected point in Bn254G1Mul serialization");
    }
    if (o.scalar === undefined) {
        throw new Error("Expected scalar in Bn254G1Mul serialization");
    }
    ;
    return {
        point: fromBn254G1Point(o.point),
        scalar: o.scalar,
    };
}
function fromBn254G2Point(o) {
    if (o.x === undefined) {
        throw new Error("Expected x in Bn254G2Point serialization");
    }
    if (o.y === undefined) {
        throw new Error("Expected y in Bn254G2Point serialization");
    }
    ;
    return {
        x: o.x,
        y: o.y,
    };
}
function fromBn254G2Mul(o) {
    if (o.point === undefined) {
        throw new Error("Expected point in Bn254G2Mul serialization");
    }
    if (o.scalar === undefined) {
        throw new Error("Expected scalar in Bn254G2Mul serialization");
    }
    ;
    return {
        point: fromBn254G2Point(o.point),
        scalar: o.scalar,
    };
}
function fromBn254G1IsOnCurve(o) {
    if (o.point === undefined) {
        throw new Error("Expected point in Bn254G1IsOnCurve serialization");
    }
    ;
    return {
        point: fromBn254G1Point(o.point),
    };
}
function fromBn254G1FromCompressed(o) {
    if (o.compressed === undefined) {
        throw new Error("Expected compressed in Bn254G1FromCompressed serialization");
    }
    ;
    return {
        compressed: o.compressed,
    };
}
function fromSchnorrComputePublicKey(o) {
    if (o.privateKey === undefined) {
        throw new Error("Expected privateKey in SchnorrComputePublicKey serialization");
    }
    ;
    return {
        private_key: o.privateKey,
    };
}
function fromSchnorrConstructSignature(o) {
    if (o.message === undefined) {
        throw new Error("Expected message in SchnorrConstructSignature serialization");
    }
    if (o.privateKey === undefined) {
        throw new Error("Expected privateKey in SchnorrConstructSignature serialization");
    }
    ;
    return {
        message: o.message,
        private_key: o.privateKey,
    };
}
function fromSchnorrVerifySignature(o) {
    if (o.message === undefined) {
        throw new Error("Expected message in SchnorrVerifySignature serialization");
    }
    if (o.publicKey === undefined) {
        throw new Error("Expected publicKey in SchnorrVerifySignature serialization");
    }
    if (o.s === undefined) {
        throw new Error("Expected s in SchnorrVerifySignature serialization");
    }
    if (o.e === undefined) {
        throw new Error("Expected e in SchnorrVerifySignature serialization");
    }
    ;
    return {
        message: o.message,
        public_key: fromGrumpkinPoint(o.publicKey),
        s: o.s,
        e: o.e,
    };
}
function fromEcdsaSecp256k1ComputePublicKey(o) {
    if (o.privateKey === undefined) {
        throw new Error("Expected privateKey in EcdsaSecp256k1ComputePublicKey serialization");
    }
    ;
    return {
        private_key: o.privateKey,
    };
}
function fromEcdsaSecp256r1ComputePublicKey(o) {
    if (o.privateKey === undefined) {
        throw new Error("Expected privateKey in EcdsaSecp256r1ComputePublicKey serialization");
    }
    ;
    return {
        private_key: o.privateKey,
    };
}
function fromEcdsaSecp256k1ConstructSignature(o) {
    if (o.message === undefined) {
        throw new Error("Expected message in EcdsaSecp256k1ConstructSignature serialization");
    }
    if (o.privateKey === undefined) {
        throw new Error("Expected privateKey in EcdsaSecp256k1ConstructSignature serialization");
    }
    ;
    return {
        message: o.message,
        private_key: o.privateKey,
    };
}
function fromEcdsaSecp256r1ConstructSignature(o) {
    if (o.message === undefined) {
        throw new Error("Expected message in EcdsaSecp256r1ConstructSignature serialization");
    }
    if (o.privateKey === undefined) {
        throw new Error("Expected privateKey in EcdsaSecp256r1ConstructSignature serialization");
    }
    ;
    return {
        message: o.message,
        private_key: o.privateKey,
    };
}
function fromEcdsaSecp256k1RecoverPublicKey(o) {
    if (o.message === undefined) {
        throw new Error("Expected message in EcdsaSecp256k1RecoverPublicKey serialization");
    }
    if (o.r === undefined) {
        throw new Error("Expected r in EcdsaSecp256k1RecoverPublicKey serialization");
    }
    if (o.s === undefined) {
        throw new Error("Expected s in EcdsaSecp256k1RecoverPublicKey serialization");
    }
    if (o.v === undefined) {
        throw new Error("Expected v in EcdsaSecp256k1RecoverPublicKey serialization");
    }
    ;
    return {
        message: o.message,
        r: o.r,
        s: o.s,
        v: o.v,
    };
}
function fromEcdsaSecp256r1RecoverPublicKey(o) {
    if (o.message === undefined) {
        throw new Error("Expected message in EcdsaSecp256r1RecoverPublicKey serialization");
    }
    if (o.r === undefined) {
        throw new Error("Expected r in EcdsaSecp256r1RecoverPublicKey serialization");
    }
    if (o.s === undefined) {
        throw new Error("Expected s in EcdsaSecp256r1RecoverPublicKey serialization");
    }
    if (o.v === undefined) {
        throw new Error("Expected v in EcdsaSecp256r1RecoverPublicKey serialization");
    }
    ;
    return {
        message: o.message,
        r: o.r,
        s: o.s,
        v: o.v,
    };
}
function fromEcdsaSecp256k1VerifySignature(o) {
    if (o.message === undefined) {
        throw new Error("Expected message in EcdsaSecp256k1VerifySignature serialization");
    }
    if (o.publicKey === undefined) {
        throw new Error("Expected publicKey in EcdsaSecp256k1VerifySignature serialization");
    }
    if (o.r === undefined) {
        throw new Error("Expected r in EcdsaSecp256k1VerifySignature serialization");
    }
    if (o.s === undefined) {
        throw new Error("Expected s in EcdsaSecp256k1VerifySignature serialization");
    }
    if (o.v === undefined) {
        throw new Error("Expected v in EcdsaSecp256k1VerifySignature serialization");
    }
    ;
    return {
        message: o.message,
        public_key: fromSecp256k1Point(o.publicKey),
        r: o.r,
        s: o.s,
        v: o.v,
    };
}
function fromSecp256r1Point(o) {
    if (o.x === undefined) {
        throw new Error("Expected x in Secp256r1Point serialization");
    }
    if (o.y === undefined) {
        throw new Error("Expected y in Secp256r1Point serialization");
    }
    ;
    return {
        x: o.x,
        y: o.y,
    };
}
function fromEcdsaSecp256r1VerifySignature(o) {
    if (o.message === undefined) {
        throw new Error("Expected message in EcdsaSecp256r1VerifySignature serialization");
    }
    if (o.publicKey === undefined) {
        throw new Error("Expected publicKey in EcdsaSecp256r1VerifySignature serialization");
    }
    if (o.r === undefined) {
        throw new Error("Expected r in EcdsaSecp256r1VerifySignature serialization");
    }
    if (o.s === undefined) {
        throw new Error("Expected s in EcdsaSecp256r1VerifySignature serialization");
    }
    if (o.v === undefined) {
        throw new Error("Expected v in EcdsaSecp256r1VerifySignature serialization");
    }
    ;
    return {
        message: o.message,
        public_key: fromSecp256r1Point(o.publicKey),
        r: o.r,
        s: o.s,
        v: o.v,
    };
}
function fromSrsInitSrs(o) {
    if (o.pointsBuf === undefined) {
        throw new Error("Expected pointsBuf in SrsInitSrs serialization");
    }
    if (o.numPoints === undefined) {
        throw new Error("Expected numPoints in SrsInitSrs serialization");
    }
    if (o.g2Point === undefined) {
        throw new Error("Expected g2Point in SrsInitSrs serialization");
    }
    ;
    return {
        points_buf: o.pointsBuf,
        num_points: o.numPoints,
        g2_point: o.g2Point,
    };
}
function fromSrsInitGrumpkinSrs(o) {
    if (o.pointsBuf === undefined) {
        throw new Error("Expected pointsBuf in SrsInitGrumpkinSrs serialization");
    }
    if (o.numPoints === undefined) {
        throw new Error("Expected numPoints in SrsInitGrumpkinSrs serialization");
    }
    ;
    return {
        points_buf: o.pointsBuf,
        num_points: o.numPoints,
    };
}
function fromShutdown(o) {
    return {};
}
function fromErrorResponse(o) {
    if (o.message === undefined) {
        throw new Error("Expected message in ErrorResponse serialization");
    }
    ;
    return {
        message: o.message,
    };
}
function fromCircuitProveResponse(o) {
    if (o.publicInputs === undefined) {
        throw new Error("Expected publicInputs in CircuitProveResponse serialization");
    }
    if (o.proof === undefined) {
        throw new Error("Expected proof in CircuitProveResponse serialization");
    }
    if (o.vk === undefined) {
        throw new Error("Expected vk in CircuitProveResponse serialization");
    }
    ;
    return {
        public_inputs: o.publicInputs,
        proof: o.proof,
        vk: fromCircuitComputeVkResponse(o.vk),
    };
}
function fromCircuitInfoResponse(o) {
    if (o.numGates === undefined) {
        throw new Error("Expected numGates in CircuitInfoResponse serialization");
    }
    if (o.numGatesDyadic === undefined) {
        throw new Error("Expected numGatesDyadic in CircuitInfoResponse serialization");
    }
    if (o.numAcirOpcodes === undefined) {
        throw new Error("Expected numAcirOpcodes in CircuitInfoResponse serialization");
    }
    if (o.gatesPerOpcode === undefined) {
        throw new Error("Expected gatesPerOpcode in CircuitInfoResponse serialization");
    }
    ;
    return {
        num_gates: o.numGates,
        num_gates_dyadic: o.numGatesDyadic,
        num_acir_opcodes: o.numAcirOpcodes,
        gates_per_opcode: o.gatesPerOpcode,
    };
}
function fromCircuitVerifyResponse(o) {
    if (o.verified === undefined) {
        throw new Error("Expected verified in CircuitVerifyResponse serialization");
    }
    ;
    return {
        verified: o.verified,
    };
}
function fromChonkComputeVkResponse(o) {
    if (o.bytes === undefined) {
        throw new Error("Expected bytes in ChonkComputeVkResponse serialization");
    }
    if (o.fields === undefined) {
        throw new Error("Expected fields in ChonkComputeVkResponse serialization");
    }
    ;
    return {
        bytes: o.bytes,
        fields: o.fields,
    };
}
function fromChonkStartResponse(o) {
    return {};
}
function fromChonkLoadResponse(o) {
    return {};
}
function fromChonkAccumulateResponse(o) {
    return {};
}
function fromChonkProveResponse(o) {
    if (o.proof === undefined) {
        throw new Error("Expected proof in ChonkProveResponse serialization");
    }
    ;
    return {
        proof: fromChonkProof(o.proof),
    };
}
function fromChonkVerifyResponse(o) {
    if (o.valid === undefined) {
        throw new Error("Expected valid in ChonkVerifyResponse serialization");
    }
    ;
    return {
        valid: o.valid,
    };
}
function fromVkAsFieldsResponse(o) {
    if (o.fields === undefined) {
        throw new Error("Expected fields in VkAsFieldsResponse serialization");
    }
    ;
    return {
        fields: o.fields,
    };
}
function fromMegaVkAsFieldsResponse(o) {
    if (o.fields === undefined) {
        throw new Error("Expected fields in MegaVkAsFieldsResponse serialization");
    }
    ;
    return {
        fields: o.fields,
    };
}
function fromCircuitWriteSolidityVerifierResponse(o) {
    if (o.solidityCode === undefined) {
        throw new Error("Expected solidityCode in CircuitWriteSolidityVerifierResponse serialization");
    }
    ;
    return {
        solidity_code: o.solidityCode,
    };
}
function fromChonkCheckPrecomputedVkResponse(o) {
    if (o.valid === undefined) {
        throw new Error("Expected valid in ChonkCheckPrecomputedVkResponse serialization");
    }
    if (o.actualVk === undefined) {
        throw new Error("Expected actualVk in ChonkCheckPrecomputedVkResponse serialization");
    }
    ;
    return {
        valid: o.valid,
        actual_vk: o.actualVk,
    };
}
function fromChonkStatsResponse(o) {
    if (o.acirOpcodes === undefined) {
        throw new Error("Expected acirOpcodes in ChonkStatsResponse serialization");
    }
    if (o.circuitSize === undefined) {
        throw new Error("Expected circuitSize in ChonkStatsResponse serialization");
    }
    if (o.gatesPerOpcode === undefined) {
        throw new Error("Expected gatesPerOpcode in ChonkStatsResponse serialization");
    }
    ;
    return {
        acir_opcodes: o.acirOpcodes,
        circuit_size: o.circuitSize,
        gates_per_opcode: o.gatesPerOpcode,
    };
}
function fromPoseidon2HashResponse(o) {
    if (o.hash === undefined) {
        throw new Error("Expected hash in Poseidon2HashResponse serialization");
    }
    ;
    return {
        hash: o.hash,
    };
}
function fromPoseidon2PermutationResponse(o) {
    if (o.outputs === undefined) {
        throw new Error("Expected outputs in Poseidon2PermutationResponse serialization");
    }
    ;
    return {
        outputs: o.outputs,
    };
}
function fromPedersenCommitResponse(o) {
    if (o.point === undefined) {
        throw new Error("Expected point in PedersenCommitResponse serialization");
    }
    ;
    return {
        point: fromGrumpkinPoint(o.point),
    };
}
function fromPedersenHashResponse(o) {
    if (o.hash === undefined) {
        throw new Error("Expected hash in PedersenHashResponse serialization");
    }
    ;
    return {
        hash: o.hash,
    };
}
function fromPedersenHashBufferResponse(o) {
    if (o.hash === undefined) {
        throw new Error("Expected hash in PedersenHashBufferResponse serialization");
    }
    ;
    return {
        hash: o.hash,
    };
}
function fromBlake2sResponse(o) {
    if (o.hash === undefined) {
        throw new Error("Expected hash in Blake2sResponse serialization");
    }
    ;
    return {
        hash: o.hash,
    };
}
function fromBlake2sToFieldResponse(o) {
    if (o.field === undefined) {
        throw new Error("Expected field in Blake2sToFieldResponse serialization");
    }
    ;
    return {
        field: o.field,
    };
}
function fromAesEncryptResponse(o) {
    if (o.ciphertext === undefined) {
        throw new Error("Expected ciphertext in AesEncryptResponse serialization");
    }
    ;
    return {
        ciphertext: o.ciphertext,
    };
}
function fromAesDecryptResponse(o) {
    if (o.plaintext === undefined) {
        throw new Error("Expected plaintext in AesDecryptResponse serialization");
    }
    ;
    return {
        plaintext: o.plaintext,
    };
}
function fromGrumpkinMulResponse(o) {
    if (o.point === undefined) {
        throw new Error("Expected point in GrumpkinMulResponse serialization");
    }
    ;
    return {
        point: fromGrumpkinPoint(o.point),
    };
}
function fromGrumpkinAddResponse(o) {
    if (o.point === undefined) {
        throw new Error("Expected point in GrumpkinAddResponse serialization");
    }
    ;
    return {
        point: fromGrumpkinPoint(o.point),
    };
}
function fromGrumpkinBatchMulResponse(o) {
    if (o.points === undefined) {
        throw new Error("Expected points in GrumpkinBatchMulResponse serialization");
    }
    ;
    return {
        points: o.points.map((v) => fromGrumpkinPoint(v)),
    };
}
function fromGrumpkinGetRandomFrResponse(o) {
    if (o.value === undefined) {
        throw new Error("Expected value in GrumpkinGetRandomFrResponse serialization");
    }
    ;
    return {
        value: o.value,
    };
}
function fromGrumpkinReduce512Response(o) {
    if (o.value === undefined) {
        throw new Error("Expected value in GrumpkinReduce512Response serialization");
    }
    ;
    return {
        value: o.value,
    };
}
function fromSecp256k1MulResponse(o) {
    if (o.point === undefined) {
        throw new Error("Expected point in Secp256k1MulResponse serialization");
    }
    ;
    return {
        point: fromSecp256k1Point(o.point),
    };
}
function fromSecp256k1GetRandomFrResponse(o) {
    if (o.value === undefined) {
        throw new Error("Expected value in Secp256k1GetRandomFrResponse serialization");
    }
    ;
    return {
        value: o.value,
    };
}
function fromSecp256k1Reduce512Response(o) {
    if (o.value === undefined) {
        throw new Error("Expected value in Secp256k1Reduce512Response serialization");
    }
    ;
    return {
        value: o.value,
    };
}
function fromBn254FrSqrtResponse(o) {
    if (o.isSquareRoot === undefined) {
        throw new Error("Expected isSquareRoot in Bn254FrSqrtResponse serialization");
    }
    if (o.value === undefined) {
        throw new Error("Expected value in Bn254FrSqrtResponse serialization");
    }
    ;
    return {
        is_square_root: o.isSquareRoot,
        value: o.value,
    };
}
function fromBn254FqSqrtResponse(o) {
    if (o.isSquareRoot === undefined) {
        throw new Error("Expected isSquareRoot in Bn254FqSqrtResponse serialization");
    }
    if (o.value === undefined) {
        throw new Error("Expected value in Bn254FqSqrtResponse serialization");
    }
    ;
    return {
        is_square_root: o.isSquareRoot,
        value: o.value,
    };
}
function fromBn254G1MulResponse(o) {
    if (o.point === undefined) {
        throw new Error("Expected point in Bn254G1MulResponse serialization");
    }
    ;
    return {
        point: fromBn254G1Point(o.point),
    };
}
function fromBn254G2MulResponse(o) {
    if (o.point === undefined) {
        throw new Error("Expected point in Bn254G2MulResponse serialization");
    }
    ;
    return {
        point: fromBn254G2Point(o.point),
    };
}
function fromBn254G1IsOnCurveResponse(o) {
    if (o.isOnCurve === undefined) {
        throw new Error("Expected isOnCurve in Bn254G1IsOnCurveResponse serialization");
    }
    ;
    return {
        is_on_curve: o.isOnCurve,
    };
}
function fromBn254G1FromCompressedResponse(o) {
    if (o.point === undefined) {
        throw new Error("Expected point in Bn254G1FromCompressedResponse serialization");
    }
    ;
    return {
        point: fromBn254G1Point(o.point),
    };
}
function fromSchnorrComputePublicKeyResponse(o) {
    if (o.publicKey === undefined) {
        throw new Error("Expected publicKey in SchnorrComputePublicKeyResponse serialization");
    }
    ;
    return {
        public_key: fromGrumpkinPoint(o.publicKey),
    };
}
function fromSchnorrConstructSignatureResponse(o) {
    if (o.s === undefined) {
        throw new Error("Expected s in SchnorrConstructSignatureResponse serialization");
    }
    if (o.e === undefined) {
        throw new Error("Expected e in SchnorrConstructSignatureResponse serialization");
    }
    ;
    return {
        s: o.s,
        e: o.e,
    };
}
function fromSchnorrVerifySignatureResponse(o) {
    if (o.verified === undefined) {
        throw new Error("Expected verified in SchnorrVerifySignatureResponse serialization");
    }
    ;
    return {
        verified: o.verified,
    };
}
function fromEcdsaSecp256k1ComputePublicKeyResponse(o) {
    if (o.publicKey === undefined) {
        throw new Error("Expected publicKey in EcdsaSecp256k1ComputePublicKeyResponse serialization");
    }
    ;
    return {
        public_key: fromSecp256k1Point(o.publicKey),
    };
}
function fromEcdsaSecp256r1ComputePublicKeyResponse(o) {
    if (o.publicKey === undefined) {
        throw new Error("Expected publicKey in EcdsaSecp256r1ComputePublicKeyResponse serialization");
    }
    ;
    return {
        public_key: fromSecp256r1Point(o.publicKey),
    };
}
function fromEcdsaSecp256k1ConstructSignatureResponse(o) {
    if (o.r === undefined) {
        throw new Error("Expected r in EcdsaSecp256k1ConstructSignatureResponse serialization");
    }
    if (o.s === undefined) {
        throw new Error("Expected s in EcdsaSecp256k1ConstructSignatureResponse serialization");
    }
    if (o.v === undefined) {
        throw new Error("Expected v in EcdsaSecp256k1ConstructSignatureResponse serialization");
    }
    ;
    return {
        r: o.r,
        s: o.s,
        v: o.v,
    };
}
function fromEcdsaSecp256r1ConstructSignatureResponse(o) {
    if (o.r === undefined) {
        throw new Error("Expected r in EcdsaSecp256r1ConstructSignatureResponse serialization");
    }
    if (o.s === undefined) {
        throw new Error("Expected s in EcdsaSecp256r1ConstructSignatureResponse serialization");
    }
    if (o.v === undefined) {
        throw new Error("Expected v in EcdsaSecp256r1ConstructSignatureResponse serialization");
    }
    ;
    return {
        r: o.r,
        s: o.s,
        v: o.v,
    };
}
function fromEcdsaSecp256k1RecoverPublicKeyResponse(o) {
    if (o.publicKey === undefined) {
        throw new Error("Expected publicKey in EcdsaSecp256k1RecoverPublicKeyResponse serialization");
    }
    ;
    return {
        public_key: fromSecp256k1Point(o.publicKey),
    };
}
function fromEcdsaSecp256r1RecoverPublicKeyResponse(o) {
    if (o.publicKey === undefined) {
        throw new Error("Expected publicKey in EcdsaSecp256r1RecoverPublicKeyResponse serialization");
    }
    ;
    return {
        public_key: fromSecp256r1Point(o.publicKey),
    };
}
function fromEcdsaSecp256k1VerifySignatureResponse(o) {
    if (o.verified === undefined) {
        throw new Error("Expected verified in EcdsaSecp256k1VerifySignatureResponse serialization");
    }
    ;
    return {
        verified: o.verified,
    };
}
function fromEcdsaSecp256r1VerifySignatureResponse(o) {
    if (o.verified === undefined) {
        throw new Error("Expected verified in EcdsaSecp256r1VerifySignatureResponse serialization");
    }
    ;
    return {
        verified: o.verified,
    };
}
function fromSrsInitSrsResponse(o) {
    if (o.dummy === undefined) {
        throw new Error("Expected dummy in SrsInitSrsResponse serialization");
    }
    ;
    return {
        dummy: o.dummy,
    };
}
function fromSrsInitGrumpkinSrsResponse(o) {
    if (o.dummy === undefined) {
        throw new Error("Expected dummy in SrsInitGrumpkinSrsResponse serialization");
    }
    ;
    return {
        dummy: o.dummy,
    };
}
function fromShutdownResponse(o) {
    return {};
}
//# sourceMappingURL=data:application/json;base64, 