Skip to content

Repository files navigation

ZKForge

Pure Rust ZK Compiler — No circom. No snarkjs. No Node.js.

crates.io CI License Rust Tests Speed Proof Systems


ZKForge compiles a high-level DSL into zero-knowledge proof circuits — entirely in Rust. No circom toolchain, no snarkjs, no Node.js dependency. Generate Groth16 or PLONK proofs in under a second, get an EIP-197 Solidity verifier, and deploy with Foundry — all from a single binary.

🔥 Why ZKForge?

ZKForge circom + snarkjs
Language Pure Rust 🦀 Rust DSL + JavaScript runtime
Install cargo install zkforge Node.js + npm + circom + snarkjs
Prove time (simple) <0.1s ~0.3s (with Node.js)
Proof size 128 B ~128 B
Verifier Solidity (EIP-197) + Foundry deploy Solidity (manual deploy)
Proof systems Groth16 + PLONK Groth16 + PLONK
zkML ✅ Built-in
Auto-shielding ✅ Automatic
Recursive proofs ✅ Native

🚀 Quick Start

# Install from crates.io
cargo install zkforge

# Or from GitHub
cargo install --git https://github.com/zkarchitect/zkforge.git

# Write a circuit
cat > prove_age.zkf << 'EOF'
prove {
    input age: Private<u8>;
    input min_age: Public<u8>;
    assert age >= min_age;
    output valid<bool>;
}
EOF

# Generate a proof
zkforge prove-native prove_age.zkf -w witness.json

# Deploy verifier to any EVM chain
zkforge deploy prove_age.zkf --chain-id 11155111

📊 Benchmarks

Circuit Constraints R1CS Vars Prove Time Proof Size Gas (verify)
Age Verify 13 15 <0.1s 128 B ~170K
Credit Score 36 38 <0.1s 128 B ~170K
Token Balance 74 76 <0.1s 128 B ~170K
NFT Ownership 5 7 <0.1s 128 B ~170K
Merkle Proof 18 23 <0.1s 128 B ~170K
ECDSA Verify 3,041 3,045 <0.8s 128 B ~290K

🏗 Architecture

.zkf DSL → Parser (~770 LoC)
        → Constraint Synthesizer (~1,380 LoC)
        → R1CS (BigUint, BN254 field, ~630 LoC)
        → Native Groth16 (arkworks, BN254, ~630 LoC)
        → PLONK (KZG, 3-gate, ~500 LoC)
        → Solidity Verifier (EIP-197, ~320 LoC)
        → Foundry Deploy Package

Zero circom. Zero snarkjs. Zero Node.js in the core path.

📦 Features

  • Groth16 Proving — Native arkworks backend, BN254 curve, EIP-197 compatible
  • PLONK Proving — KZG polynomial commitments, 3-gate universal circuit, Fiat-Shamir
  • Recursive Proofs — Fold multiple proofs into one for batch verification
  • zkML — Zero-knowledge neural network inference (ReLU, softmax, field-aware)
  • Solidity Verifier — Auto-generated, EIP-197, compilable with solc 0.8.x
  • Foundry Deploy — One command: verifier + deployment script + test
  • Auto-Shielding — Wrap any Solidity contract with ZK privacy
  • ECDSA Verification — Signature checks via k256, committed in-circuit via Poseidon
  • Merkle Proofs — Tree membership via 73-round Poseidon hash chain
  • Crypto Primitives — Poseidon hashing, field arithmetic

📂 Project Structure

zkforge/
├── compiler/          # Core compiler (17 Rust modules, ~10,200 LoC)
├── cli/               # CLI binary
├── examples/          # 6 .zkf example circuits (all passing e2e)
├── assets/            # Logo and assets
└── .github/           # CI workflows, templates, security review

🔐 Security

Internal security review completed. 3 critical bugs found and fixed:

  1. Comparison constraintsassert age >= 18 was silently passing for age = 3
  2. Plonk witness bypass — prover used domain elements instead of real witness values
  3. Inequality inversion!= check used -1 instead of 1 for the witness

All fixes verified with adversarial tests (131/131 passing). Full audit report →

🧪 Testing

131 tests passing — parser, AST, constraint synthesis, R1CS, Groth16, 
PLONK, crypto primitives, recursive prover, auto-shield, zkML, deployment.

Many tests include adversarial counterexamples: wrong inputs produce rejected proofs.

🛠 Troubleshooting

cargo install zkforge fails on Rust 1.95+

Cause: Upstream incompatibility between ark-ff 0.6.0 and Rust ≥1.95.

Workaround: Install from GitHub source directly:

cargo install --git https://github.com/zkarchitect/zkforge.git

This builds the latest commit and avoids the crates.io pre-built dependency lock.

👥 Community

Star History

Star History Chart

📄 License

Apache 2.0 — see LICENSE

🌟 Contributing

ZKForge is open source and welcomes contributions. See CONTRIBUTING.md for guidelines.

About

Pure Rust ZK compiler — no circom, no snarkjs, no Node.js. Groth16 + PLONK + zkML + Recursive Proofs. EIP-197 Solidity verifier. Foundry deploy.

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages