CircomJS
  • Introduction
    • CircomJS
    • Getting Started
  • Circuit Config File
    • Circuit Config File
    • fileName
    • Circuit ID
  • Classes
    • CircomJS
    • Circuit
Powered by GitBook
On this page
  1. Circuit Config File

Circuit ID

PreviousfileNameNextCircomJS

Last updated 2 years ago

To identify every circuit uniquely, users are required to provide a unique cID field for circuits entries inside the build field of the They use this cID to get their respective circuit via the getCircuit() method of .

For example, If we have a circuit by the name multiplication.circom inside our circuit's inputDir , then we would have to declare it in our in the following manner:

circuit.config.json
{
    "projectName": "circom-starter",
    "outputDir":"./out",
    "build": {
        "inputDir": "./circuits",
        "circuits": [
          {
              "cID": "mul",
              "fileName": "multiply.circom",
              "proofType": "groth16",
              "compilationMode": "wasm",
           }
        ]
    }
}

Now, when we want to get this inside the Node JS program, we do the following:

src/index.js
const {CircomJS} = require("@zefi/circomjs")

const main = async() => {
    const circomjs = new CircomJS()
    const circuit =  circomjs.getCircuit("mul")   
    
    await circuit.compile()
}

main()

The following is taking place in the above code:

  • We call the getCircuit(cID) method, where cID = "mul"

  • It returns the respective circuit { throws an error if the circuit with that cID is not present }

  • It builds the circuits { await circuit.compile() }.

We instantiate

CircomJS looks for a circuit that was tagged with a cID of mul inside the {check out section on the file path for the circuit is resolved. }

circuit config file.
CircomJS
circuit config file
Circuit
circuit config file
this
CircomJS