Getting Started

Prerequisites

System Requirements:

  • Node.js for website development
  • Rust for mobile app compilation
  • Git for version control

Circuit Development Tools:

  • Circom
  • snarkjs
  • Noir/Nargo

App Development Tools:

  • Mopro CLI
  • Flutter
  • Android Studio

Quick Start

1. Clone the Repository

Bash
git clone https://github.com/BlocSoc-iitr/Deimos.git
cd Deimos

2. Explore the Website Dashboard

Bash
cd website
npm install
npm run dev

The website will be available at http://localhost:3000

Working with Circom Circuits

Step 1: Compiling a Circuit

Bash
cd benchmarking-suite/frameworks/circom/circuits/sha256

circom circom.circom --r1cs --wasm --sym --c

Step 2: Computing the Witness

First, copy the input.json file from inputs/sha256/ to the appropriate directory:

  • For WebAssembly: circuits/sha256/circom_js/
  • For C++: circuits/sha256/circom_cpp/

Option 1: Computing Witness with WebAssembly

Bash
cd benchmarking-suite/frameworks/circom/circuits/sha256/circom_js/

node generate_witness.js circom.wasm input.json witness.wtns

Option 2: Computing Witness with C++

Bash
cd benchmarking-suite/frameworks/circom/circuits/sha256/circom_cpp/

make
./circom input.json witness.wtns

Step 3: Generating Proving Keys

3a. Powers of Tau Ceremony (Circuit-Independent)

The Powers of Tau ceremony is a one-time setup that doesn't depend on a specific circuit.

Bash
# Start new ceremony
snarkjs powersoftau new bn128 12 pot12_0000.ptau -v

# Contribute randomness
snarkjs powersoftau contribute pot12_0000.ptau pot12_0001.ptau --name="First contribution" -v

3b. Generating zkey and verification key (Circuit-Dependent)

These steps are specific to your circuit and must be done for each circuit you compile.

Bash
# Prepare for phase 2
snarkjs powersoftau prepare phase2 pot12_0001.ptau pot12_final.ptau -v

# Generate proving key
snarkjs groth16 setup circom.r1cs pot12_final.ptau circuit_0000.zkey

# Contribute to the proving key
snarkjs zkey contribute circuit_0000.zkey circuit_0001.zkey --name="1st Contributor Name" -v

# Export verification key
snarkjs zkey export verificationkey circuit_0001.zkey verification_key.json

Step 4: Generating and Verifying Proofs

Once you have the proving key and witness, you can generate and verify proofs.

Bash
# Generate proof
snarkjs groth16 prove circuit_0001.zkey witness.wtns proof.json public.json

# Verify proof
snarkjs groth16 verify verification_key.json public.json proof.json

# Expected output: [INFO] snarkJS: OK!

Setting Up MoPro Mobile Apps

Initialize MoPro Project

bash
cd benchmarking-suite/moPro/mopro-sha256

# Initialize MoPro configuration
mopro init

# Build native bindings
mopro build

# Generate platform templates
mopro create

# Update bindings after changes
mopro update

Android Development

Prerequisites: Android Studio, Android SDK, Java 11+

bash
# Open in Android Studio
open android -a Android\ Studio

# Or build from command line
cd android
./gradlew build

# Run on device
./gradlew installDebug

iOS Development

Prerequisites: Xcode, macOS, CocoaPods

Bash
# Open in Xcode
open ios/MoproApp.xcodeproj

# Or build from command line
cd ios
xcodebuild -project MoproApp.xcodeproj -scheme MoproApp build

Running Tests

Bash
# Run Rust tests
cargo test

# Test specific circuit
cargo test test_circom

# Run with verbose output
cargo test -- --nocapture

Project Structure Navigation

Circuit Implementations

All Circom circuits are in benchmarking-suite/frameworks/circom/circuits/

  • sha256/ - SHA-256 hash circuit
  • keccak256/ - Keccak-256 hash circuit
  • blake2s256/ - BLAKE2s-256 hash circuit
  • poseidon/ - Poseidon hash circuit
  • mimc256/ - MiMC hash circuit
  • pedersen/ - Pedersen hash circuit

Test Inputs

Test vectors are in benchmarking-suite/frameworks/circom/inputs/

Mobile Apps

MoPro mobile implementations are in benchmarking-suite/moPro/

  • mopro-sha256/ - SHA-256 benchmarking app
  • mopro-keccack256/ - Keccak-256 benchmarking app
  • mopro-example-app/ - Example implementation

Documentation

  • README.md - Project overview
  • CONTRIBUTING.md - Contribution guidelines
  • APP_INTEGRATION_GUIDE.md - Integration guide
  • benchmarking-suite/frameworks/circom/ADDING_HASH_FUNCTIONS.md - Circuit development guide
  • benchmarking-suite/moPro/README.md - MoPro documentation

Common Issues and Solutions

Circuit Compilation Errors

Issue: "Too many values for input signal"

Solution: Make sure your input JSON only contains fields that match circuit inputs. Remove any extra fields like 'hash', 'N', etc.

Issue: "Not enough coefficients"

Solution: Your Powers of Tau file is too small. Use a larger pot file (pot14 → pot16 → pot18 → pot20).

Issue: Library import errors

Solution: Check import paths in your circuit files. Use relative paths to circomlib and other libraries.

MoPro Build Issues

Issue: UniFFI version mismatch

Solution: Make sure you're using UniFFI version 0.29.0 as specified in Cargo.toml.

Issue: Android build fails

Solution: Ensure you have the correct Android SDK version and Java 11+ installed. Run mopro update to refresh bindings.

Performance Issues

Issue: Slow proof generation on mobile

Solution: This is expected for large circuits. Use physical devices instead of emulators for accurate benchmarks. Consider using ZK-friendly hash functions like Poseidon for better performance.