# Circuit Compilation

Given that the majority of a circuit's use is driven by SnarkJS, the section on Circuit compilation in the context of the Circom language is very short. You should continue in the SnarkJS Circuit Generation section.

### Minimum Circuit Artifacts

Using the `circom` binary installed to your machine, you can generate various artifacts of your circuits. We will show the bare minimum used in BattleZips' board proof:

```
circom zk/circuits/board.circom -o zk/ --r1cs --wasm
```

`circom zk/circuits/board.circom` targets the circom file to compile from the top level of the BattleZips directory. This command has three consequences:

* A 'Rank-1 Constraint System' representing the circuit will be written to `board.r1cs`
* The 'witness calculator' used with the `.zkey` to generate proofs given inputs, written to `board_js/board.wasm`
* Both of these files will be written to the folder `zk` in the top level BattleZips directory

The .r1cs file will be further used by SnarkJS to create the circuit's zkey.&#x20;

We choose to generate our witness calculator in WebAssembly since this is the most portable version of the witness calculator we can generate. It can be used both by servers/ your IDE as well as being served to a client in a browser. If you are building something like a rollup that will only sit on a backend server, you can gain increased efficiency in witness calculation by compiling to C++ instead of WebAssembly.

TODO: LINK TO SNARKJS


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://battlezips.gitbook.io/battlezips/development/circom-language/circuit-compilation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
