ZK Tookit

Cryptographic Infrastructure

ZK Toolkit

Circom • SnarkJS • Halo2 (Experimental)


SnarkSide is architected as a privacy-first perpetual DEX built entirely around zero-knowledge constraint systems. At its core, the protocol depends on high-performance zk toolchains that allow for:

  • Intent encryption

  • Proof-based execution

  • Vault privacy

  • Order invisibility

  • Verifiable constraint satisfaction

The ZK stack powering SnarkSide includes proven tools like Circom and SnarkJS for prototyping and production, and explores emerging high-efficiency systems like Halo2 for future recursive proof composition and native prover integration.

This section details how SnarkSide uses these frameworks, the structure of its circuits, the lifecycle of proof generation, and the roadmap toward scalable, trustless ZK verification.


Circom: Primary Circuit Language

Circom is a domain-specific language for defining arithmetic constraint systems in zero-knowledge circuits. SnarkSide uses Circom as its primary language for describing:

  • Trade intent circuits

  • Vault deposit and state transition constraints

  • Funding and liquidation logic

  • Merkle inclusion and nullifier proofs

  • Oracle commit-reveal mechanisms

Why Circom?

  • Supports Poseidon and other ZK-friendly hash functions

  • Optimized for finite field operations

  • Actively maintained and widely adopted in ZK projects

  • Compatible with SnarkJS and Groth16 backends

Example: Nullifier Check Circuit

template NullifierCheck() {
    signal input nullifier;
    signal input nullifierSetRoot;
    signal input merkleProof[];

    component inclusion = MerkleInclusionProof(depth);
    inclusion.leaf <== Poseidon(nullifier);
    inclusion.root <== nullifierSetRoot;

    for (var i = 0; i < depth; i++) {
        inclusion.path[i] <== merkleProof[i];
    }

    assert(inclusion.included == 0); // Must not be previously used
}

This constraint enforces non-reusability of a vault nullifier without disclosing any vault data.


SnarkJS: Proof Lifecycle Management

SnarkJS is the default CLI and runtime environment for:

  • Circuit compilation

  • Witness generation

  • Proof creation

  • Verifier generation (Solidity + JSON)

SnarkSide uses SnarkJS to:

  • Compile circuits defined in Circom

  • Generate Groth16 proof systems

  • Export verifier contracts for each constraint module

  • Test gas usage and circuit depth during CI

Prover Workflow:

circom intent.circom --r1cs --wasm --sym
snarkjs groth16 setup intent.r1cs pot_final.ptau intent.zkey
snarkjs groth16 prove intent.zkey witness.wtns intent.proof.json intent.public.json
snarkjs groth16 verify verification_key.json intent.public.json intent.proof.json

Verifier contracts are deployed per-module and auto-integrated into the intent matcher and settlement contracts.


Halo2: Recursive SNARKs and Future Integration

SnarkSide is currently experimenting with Halo2 (developed by Zcash / Electric Coin Co.) to:

  • Enable recursive proof composition (e.g., batch intent proof + batch vault proof)

  • Reduce prover time for large circuits

  • Explore native Rust prover integration for long-term scalability

Halo2 Benefits:

  • No trusted setup

  • Native recursion support

  • Flexible circuit composition

  • Fast verification time (optimized for L1s and rollups)

Planned Use Cases:

  • Recursive batch inclusion of vault updates

  • Proof composition for funding + liquidation + matching

  • zkBridge integration for off-chain prover delegation

Halo2 circuits will eventually replace Groth16-based submodules for high-frequency operations.


Performance Benchmarks (Groth16 w/ Circom)

Circuit
Avg Constraints
Prover Time (sec)
Proof Size
Verifier Gas (EVM)

Intent Matching

41,210

~1.3

~192 bytes

430,000

Vault Transition

52,700

~1.6

~210 bytes

520,000

Merkle Inclusion + Null

37,000

~1.2

~200 bytes

400,000

Oracle Commit-Prove

23,500

~0.9

~180 bytes

390,000

Benchmarks run on i7-12700H CPU, 32GB RAM. Halo2 in progress for recursive scaling and compression.


Toolchain Roadmap

Layer
Current
Planned

Circuit Language

Circom v2

Circom + Halo2 hybrid

Prover

SnarkJS (Groth16)

Arkworks / Halo2-native

Verifier Format

Solidity

Wasm + L2-native verifier

Build System

Custom CLI

Integrated monorepo (NX)

Recursion

Simulated (batch zk)

Halo2-native recursion

On-chain Integration

Solidity

zkVM proof forwarding


Summary

SnarkSide’s cryptographic foundation is powered by a rigorous, modular ZK stack:

  • Circom + SnarkJS for current production constraints

  • Halo2 (WIP) for future recursive SNARK composition

  • Multi-prover, multi-format tooling for flexibility across EVM and non-EVM chains

This architecture enables SnarkSide to treat zero-knowledge not as a bolt-on privacy layer, but as the core execution environment for the entire protocol.

Last updated