Build Requirements

Build Requirements

Rust, Circom, Node.js Versions • Trusted Setup Validation Suite


The SnarkSide protocol stack is an intricate composition of zero-knowledge circuits, relayer infrastructure, cryptographic tooling, and Ethereum-compatible smart contracts. Given its use of constraint systems, recursive hashing, Merkle root commitments, and Groth16 proof construction, the build environment must be tightly controlled for compatibility, determinism, and verifiability.

This document outlines the software dependencies and tooling stack required to build, verify, and test SnarkSide locally or in CI environments.


1. Core Language and Runtime Versions

To ensure proper interoperability between circuits, verifiers, and relayers, the following versions are recommended and tested:

Component
Required Version
Notes

Rust

>=1.72.0

Used for constraint generation (optional)

Node.js

v18.x

Required for Circom tooling and relayer

Yarn

1.22+

Package manager for node-based stack

Circom

2.1.7

Main ZK circuit language

SnarkJS

0.6.11

Trusted setup + verifier compiler

Solidity

^0.8.20

For verifying Groth16 proofs on-chain

Docker

Latest stable

Optional, for prover containers

Always use nvm or Docker to control Node versions explicitly, especially when compiling witnesses or verifying constraints.


2. Circom Compiler Setup

Install the Circom compiler from source for optimal reproducibility.

git clone https://github.com/iden3/circom.git
cd circom
cargo build --release
sudo cp target/release/circom /usr/local/bin

Verify installation:

circom --version
# Output: 2.1.7

3. SnarkJS Setup

SnarkJS handles:

  • Groth16 trusted setup

  • Witness generation

  • Solidity verifier creation

  • Proof generation and verification

yarn global add [email protected]

Test:

snarkjs --version

snarkside/

├── circuits/
│   ├── trade_intent/
│   ├── vault_transition/
│   └── liquidation/

├── verifier/
│   └── verifier.sol

├── relayer/
│   └── index.ts

├── zk-tools/
│   └── setup/
│       ├── powersOfTau28_hez_final.ptau
│       ├── circuit.r1cs
│       └── zkey/

Each circuit directory should have:

  • .circom file

  • input.json (test vector)

  • generate_witness.js

  • compile.sh

  • README.md


5. Trusted Setup Validation Suite

All circuits are compiled and proven using Groth16. The setup process consists of:

Phase 1: Powers of Tau Ceremony

You can use the default ptau file or contribute your own entropy:

snarkjs powersoftau new bn128 14 pot14_0000.ptau -v
snarkjs powersoftau contribute pot14_0000.ptau pot14_0001.ptau --name="SnarkSide contributor" -v

Phase 2: Circuit-specific Setup

circom intent.circom --r1cs --wasm --sym
snarkjs groth16 setup intent.r1cs pot14_0001.ptau intent_0000.zkey
snarkjs zkey contribute intent_0000.zkey intent_final.zkey --name="ZK Operator" -v
snarkjs zkey export verificationkey intent_final.zkey verification_key.json

ZK Verifier Generation

snarkjs zkey export solidityverifier intent_final.zkey verifier.sol

The generated verifier.sol must be tested against your circuit proof and undergo gas benchmarking before deployment.


6. Witness Generator Build

You can generate witnesses either:

  • In-browser (for small circuits)

  • In Node.js via wasm

  • In Docker for reproducibility

cd intent_js
node generate_witness.js intent.wasm input.json witness.wtns

Optional Docker build:

FROM node:18
RUN yarn global add snarkjs
COPY . /circuits
WORKDIR /circuits

7. CI Integration (Optional)

CI pipelines must:

  • Validate .circom syntax

  • Compile R1CS and check constraints

  • Run deterministic witness generation

  • Validate Groth16 proof generation

  • Compare verifier output against reference


8. Example Setup Verification Script

#!/bin/bash

circom intent.circom --r1cs --wasm
snarkjs groth16 setup intent.r1cs pot14_0001.ptau intent.zkey
snarkjs zkey contribute intent.zkey final.zkey --name="Verifier"
snarkjs zkey export verificationkey final.zkey verification_key.json
snarkjs zkey export solidityverifier final.zkey verifier.sol

Add assertions to check file hashes and commit to CI.


Conclusion

SnarkSide’s build stack depends on strict determinism, reproducibility, and compatibility across ZK primitives and matching logic. Developers must adhere to exact versioning, especially across cryptographic hash functions, prover variants, and Circom constraints. All trusted setup artifacts must be verifiably generated, stored, and pinned before public deployment.

Only then can the system ensure that every trade, vault, and proof is not just private—but provably correct.

Last updated