BattleZips
  • Awesome Circom
  • 🔬Theory
    • Prerequisite Knowledge
    • Resources
      • White Papers & PDF's
      • Blogs and Writeups
      • Videos
      • Important Entities
      • Communities
    • Proving Schemes
    • Primitives
      • Hash Functions
      • Public Key Cryptosystems
        • Note on L1 key registry → L2 hot key + callback to circuit-optimized hash functions
        • ECDSA & secp256k1
        • EdDSA
      • Merkle Trees
        • What is a Merkle Tree?
        • What is a merkle proof of inclusion?
        • zk-kit
        • Incremental Merkle Trees
        • Sparse Merkle Trees
        • Tree Arity (Binary, Quinary)
      • Semaphore
      • Arithmetic Circuits
  • 🏗️Development
    • Circom Language
      • Installation
      • IDE
      • Signals and Variables
      • Signal Assignment and Constraint Generation
      • Conditional Statements
      • Components and Templates
      • Circuit Compilation
      • Syntax
    • SnarkJS
      • Proving Schemes
      • Powers of Tau
      • ZK Keys
      • Zero Knowledge Proofs
      • On-Chain ZKP
      • Page 2
    • circomlib
      • Basic Math Constraints
      • Multiplexing
      • Hashing
      • EdDSA
      • circomlibjs
    • circom-tester
    • hardhat-circom
    • SHIELD
    • Circomspect
  • 🌆Ecosystem
    • Circom vs Other Solutions
      • Domain-Specific Languages
      • ZK Virtual Machines
      • ZK Ethereum Virtual Machines
    • Communities to Join
    • Recorded Content
    • Projects
  • 🛳️Examples
    • BattleZips V1
      • On the BattleZips Project
      • Docs holder
        • Join Game UML Sequence Diagram
        • Play Game UML Sequence Diagram
        • End Game UML Sequence Diagram
      • ZK Privacy Stack
      • Deploying Artifacts to Prod
      • Browser Client
    • RollupNC
      • Smart Contracts
      • Account/ State Tree
      • Transaction Tree
      • Layer 1 Deposits to Layer 2
      • Layer 2 Transacting
      • Layer 2 Withdrawals to Layer 1
Powered by GitBook
On this page
  1. Development
  2. Circom Language

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.

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

PreviousComponents and TemplatesNextSyntax

Last updated 2 years ago

🏗️