Veritas: Streamlining Circom Circuit Testing with Go Integration
Testing Circom circuits is tedious as developers typically need to perform a multi-step testing process to ensure the circuit is functioning correctly. Veritas was born out of necessity during the development of Privacy Pools, a compliant privacy protocol for the Ethereum Virtual Machine (EVM). To rapidly prototype and test our circuits, we required a more robust toolchain, as current Circom development tools did not meet our needs. We saw significant room for improvement, especially in how circuits are developed, tested, and integrated.
Circom is an excellent DSL for writing zero-knowledge circuits, but the existing dev tools can introduce friction, particularly for Go developers. We believe that Golang complements Circom but remains underutilized in the common Circom development toolchain. Therefore, we built Veritas—an opinionated Go front-end for Circom that allows circuits to be embedded and tested directly within Go projects. This approach reduces the complexity of switching between different languages and environments, optimizing the workflow for Circom developers.
To achieve this, we forked Circom v2.2.0 to support the Bus implementation and implemented Foreign Function Interface (FFI) bindings to create a continuous pipeline for circuit compilation (from AST to WASM) and evaluation.
How to Use
Veritas is not meant to replace other Circom dev tools like Circomkit or Circomspect but serves as a complementary tool. It streamlines the development and testing of Circom circuits by integrating them directly into Go’s testing ecosystem, reducing the need for multi-step testing processes or switching between developer environments.
You can package Circom circuits (i.e., `.circom` files) as Programs, which may include templates, functions, and more. These programs are then linked and compiled into a Circuit Library.
Evaluating Circuits
Veritas allows you to evaluate your circuits with dynamic input data. Simply call the `Evaluate` method, passing in JSON inputs, which enables rapid testing iterations, making the testing process more efficient and integrated.
Key Benefits
Reduced Cognitive Overhead: Developers can focus on writing and testing circuits in a single environment, reducing the complexity of switching between languages or tools.
Faster Development Cycles: Testing circuits directly in Go speeds up the iteration process, as developers can immediately test and evaluate their circuits without leaving the Go environment.
Better-Designed Circuits: By simplifying the development flow, Veritas encourages more secure and performant circuit designs.
Improved Auditability: Go’s robust testing framework allows for comprehensive unit tests and constraint analysis, improving the auditability of circuits.
What's Next?
We aim to further enhance Veritas with support for constraint analysis, debugging, and optimizations, as well as integrating formal verification tools and folding schemes like Sonobe.
Veritas was built out of necessity for our Privacy Pool and ASP circuits, but we hope it serves as a valuable tool for other engineers tackling zero-knowledge circuits in Circom.
To get started, check out our GitHub repository.