Skip to main content

TACEO:Proof CoCircom

To make it easy to seamlessly integrate TACEO:Proof into your applications, we implemented client libraries for different languages. You can find the client libraries and example clients in the proof-client repository. There you will find installation instructions and example circuits.

The JavaScript clients use WebAssembly generated with wasm-pack and therefore need different packages for different targets. Currently we support nodejs and bundler with their respective npm packages @taceo/proof-client-node and @taceo/proof-client-bundler.

  • Installation: Install the package for your target using your favorite package manager

    npm install @taceo/proof-client-node
  • Setup: Create the API client configuration

    const configParams: ConfigurationParameters = {
    basePath: "https://proof.taceo.network",
    }
    const configuration = new Configuration(configParams)
    const jobInstance = new JobApi(configuration );
    const nodeInstance = new NodeApi(configuration );
  • Witness Extension + Prove Job:

    With a full prove job, the input is secret-shared, encrypted, and distributed to the designated nodes for processing. The workflow does not require a precomputed extended witness; instead, the witness extension is generated during the job execution, which is then followed by proof generation. This approach eliminates the need to upload potentially large witnesses.

    const nodes = await nodeInstance.randomNodeProviders();
    const blueprintId = "54f9ee38-0160-44e2-a1d8-08d1b6771cbf";
    const voucher = null; // only required for Restricted blueprints
    const publicInputs = ["public_input_1", "public_input_2"];
    const input = JSON.parse(fs.readFileSync("input.json").toString());
    const jobId = await CoCircom.scheduleFullJob(
    jobInstance,
    nodes,
    blueprintId,
    voucher,
    "Bn254",
    publicInputs,
    input
    );
  • Multiple Inputs Witness Extension + Prove Job:

    This job supports multiple inputs from different users without revealing inputs to each other. Once all inputs for the job are present, it is sent to designated nodes, which then execute the job. Additionally, an optional deadline can be set to limit the amount of time that can pass before all inputs must be present. Inputs can be dynamically added to an already created job. The input data is secret-shared, encrypted, and collected until the job gets scheduled. This approach enables more flexible workflows and computational processes.

    const nodes = await nodeInstance.randomNodeProviders();
    const blueprintId = "54f9ee38-0160-44e2-a1d8-08d1b6771cbf";
    const voucher = null; // only required for Restricted blueprints
    const deadline = new Date(Date.now() + 3600 * 1000); // 1 hour from now
    const jobId = await CoCircom.scheduleFullMultipleInputsJob(
    jobInstance,
    nodes,
    blueprintId,
    voucher,
    deadline
    );
    // multiple users can now add inputs to this job given the jobId and the selected nodes
    const publicInputs = ["public_input_1", "public_input_2"];
    const input = JSON.parse(fs.readFileSync("input.json").toString());
    await CoCircom.addJobInputs(jobInstance, nodes, jobId, "Bn254", publicInputs, input);
  • Prove Job:

    A proof job can be scheduled using either the Rep3 or Shamir Secret Sharing scheme. The process involves taking a witness, secret-sharing it, encrypting these shares, and distributing them to the designated nodes for execution.

    const nodes = await nodeInstance.randomNodeProviders();
    const blueprintId = "54f9ee38-0160-44e2-a1d8-08d1b6771cbf";
    const mpcProtocol = "Rep3"; // specify the MPC protocol to use (Rep3 or Shamir)
    const voucher = null; // only required for restricted blueprints
    const numPubInputs = 2;
    const witness = new Uint8Array(fs.readFileSync(inputPath));
    const jobId = await CoCircom.scheduleProveJob(
    jobInstance,
    nodes,
    blueprintId,
    mpcProtocol,
    voucher,
    "Bn254",
    numPubInputs,
    witness
    );
  • Fetch the job Results:

    The results of a job execution can be retrieved via a WebSocket connection. Once the results are ready, the server sends a message containing the proof, public inputs, and signatures of the computing nodes. If any party encounters an error, an error message is returned instead. The received proof and public inputs are deserialized into Groth16Proof and PublicSignal types as defined by snarkjs.

    const wsUrl = "wss://proof.taceo.network/api/v1/reports/subs";
    const jobId = "9c2814d7-25d3-4de5-b61f-0a6e3bacbe99";
    const { proof, public_inputs, signatures } = await CoCircom.fetchJobResult(wsUrl, jobId);
    fs.writeFileSync("proof.json", JSON.stringify(proof));
    fs.writeFileSync("public.json", JSON.stringify(public_inputs));

After completing these steps, you will have two files named proof.json and public.json, containing the Circom Groth16 proof and public inputs.

You can now use snarkjs to verify the proof

snarkjs groth16 verify verification_key.json public.json proof.json