[Final Report] ZeroStyl - Privacy Toolkit for Arbitrum Stylus

[Final Report] ZeroStyl — Privacy Toolkit for Arbitrum Stylus

Program: Domain Allocators for Developer Tooling
Repository: GitHub - kazai777/zerostyl: ZeroStyl is an open-source Rust-based toolkit to streamline privacy-preserving smart contract development on Arbitrum Stylus. · GitHub
License: MIT (fully open-source)

Executive summary

ZeroStyl is an open-source Rust toolkit that makes privacy-preserving smart contracts practical to build on Arbitrum Stylus, using halo2 zk-SNARKs (KZG polynomial commitment on the BN254 curve).

Over the grant, ZeroStyl grew from a design into a complete local zero-knowledge development workflow: developers can build and debug halo2 circuits, generate and verify proofs off-chain, export privacy-safe contract ABIs from annotated Stylus functions, and generate typed client SDKs in three languages — all without an external proving service. The toolkit also ships an Orbit deployability adapter for per-chain analysis and a runtime + technical dashboard providing the standardized on-chain event and fingerprinting primitives.

All source code is public and MIT-licensed. The reusable library crates and the client SDKs are published on crates.io, npm, and PyPI.


Milestone 1 — zk-Compiler & reference circuits

A Rust library that turns halo2 zk-SNARK circuits into WASM-targetable components for the Stylus runtime, together with a set of reference circuits.

Delivered:

  • Circuit-building library (zerostyl-compiler) on the halo2 PSE fork (KZG/BN254), plus a dedicated no_std / wasm32 gadget crate (zerostyl-gadgets) providing Poseidon, range-check, comparison and Merkle-membership gadgets — the building blocks for privacy circuits that must eventually run in a WASM verifier.
  • Three reference circuits (the proposal targeted two — private_vote was added as a bonus):
    • state_mask — proves a hidden collateral_ratio lies within [150, 300] and that hidden_balance > threshold, while committing to the secret values with a Poseidon hash. (Private solvency / eligibility.)
    • tx_privacy — validates a private token transfer through balance conservation, Merkle membership of the spent note, and an unlinkable nullifier, without revealing balances or the amount.
    • private_vote — casts a boolean vote proving eligibility (balance ≥ threshold), committing to both the balance and the vote with Poseidon.
  • Local Stylus tests and a comprehensive automated test suite, with CI running build, tests, clippy, formatting and a wasm32 build across Linux, macOS and Windows, plus a dedicated coverage job.
  • 5-minute demo video: https://youtu.be/OTnLZRm5Ww8

Proof: crates/zerostyl-compiler · crates/zerostyl-gadgets · examples/ (circuits) · CI workflows


Milestone 2 — Privacy Debugger & on-chain integration

A command-line debugger built around zk-mocking, plus off-chain proving/verification and reference verifier contracts on testnet.

Delivered:

  • zerostyl-debug — the privacy debugger. Uses halo2’s MockProver (zk-mocking: constraint checking without generating a full proof) to run a witness against a circuit and report exactly which gate and region fails, with readable diagnostics. Sub-commands: inspect (columns/gates/constraints/degree), schema (expected witness JSON), witness (assignments + derived public inputs), debug (failure diagnostics).
  • zerostyl-prove — off-chain proving/verification. Generates a compact halo2-KZG proof from a witness (measured proof size ~2.7 KB) and verifies it against the circuit’s public inputs. Proving parameters are cached after first use.
  • zerostyl-verifier — a no_std verifier library implementing halo2-KZG verification for the Arbitrum Stylus runtime, with the verifying key and parameters embedded at build time (no runtime keygen). Compiles to wasm32-unknown-unknown.

Proof: crates/zerostyl-debugger · crates/zerostyl-cli · crates/zerostyl-verifier · docs/DEPLOYMENTS.md


Milestone 3 — Toolkit launch, Orbit adapter & STARK study

The privacy-safe ABI exporter, multi-language SDKs, documentation, published packages, the Orbit adapter module, and the zk-STARKs feasibility study.

Delivered:

  • zerostyl-export — the zk-safe ABI exporter. Scans a Stylus contract for parameters annotated with #[zk_private] and generates, for each circuit: a halo2 circuit, a backend-agnostic descriptor, a privacy-safe ABI (abi.json, replacing private parameters with a commitment + proof), and a transformed contract module.
  • Typed client SDKs in three languages, all reading the same abi.json:
    • Rustzerostyl-sdk: registry, prove/verify helpers, witness builder, proof envelope.
    • TypeScript@zerostyl/sdk-ts: abi.json → typed TypeScript module.
    • Pythonzerostyl-sdk: abi.json → typed dataclasses, pure Python.
  • Package publication: SDKs on npm and PyPI, and the reusable library crates (zerostyl-sdk, zerostyl-orbit, zerostyl-circuits, zerostyl-runtime) on crates.io.
  • Documentation & tutorials at docs.zerostyl.dev (installation, quick start, CLI reference, circuit reference, end-to-end tutorials, and an events/fingerprinting reference).
  • Mock DeFi integration: reference verifier contracts on Arbitrum Sepolia covering private lending (solvency), private swaps and voting patterns.
  • zk-STARKs feasibility study: docs/STARK_FEASIBILITY.md — analyzes FRI-based transparent/post-quantum proving against the project’s measured constraints and outlines when a STARK backend would make sense behind the toolkit’s backend-agnostic circuit interface.
  • Orbit zk-Adapter Module (zerostyl-orbit): per-chain configuration profiles (size caps, ink/gas model, required precompiles) as TOML, built-in profiles for Arbitrum One / Nova / Sepolia and a customizable Orbit template, deployability analysis (Brotli-compressed sizing against a chain’s on-chain budget), a precompile-requirement mapping per proving system, and a multi-chain analysis CLI (list / show / check / matrix / init).
  • zerostyl-runtime + technical dashboard. The runtime crate provides the standardized ZeroStylPrivacyTransaction event (with its canonical signature and topic0) and the BytecodeFingerprint primitive — a single source of truth for on-chain tracking. The technical dashboard exposes the event schema, its exact topic0, a live client-side keccak256 fingerprint tool, and the deployed-contract registry.

Proof: crates/zerostyl-exporter · crates/zerostyl-sdk · packages/sdk-ts · packages/sdk-py · crates/zerostyl-orbit · crates/zerostyl-runtime · Dashboard: Dashboard | ZeroStyl


Technical architecture

  • Proof system: halo2 (PSE fork) with a KZG polynomial commitment on BN254, SHPLONK, Keccak transcript.
  • Workspace (Rust, MIT):
zerostyl-circuits    Backend-agnostic circuit descriptors, registry & ABI schema (published)
zerostyl-gadgets     no_std/wasm32 halo2 gadgets — Poseidon, range, comparison, Merkle
zerostyl-compiler    halo2 circuit construction for the reference circuits
zerostyl-runtime     On-chain primitives — privacy event & bytecode fingerprint (published)
zerostyl-verifier    no_std halo2-KZG verifier for the Stylus runtime
zerostyl-sdk         Rust client SDK (published)
zerostyl-orbit       Per-chain deployability analysis + CLI (published)
zerostyl-debugger    `zerostyl-debug` — circuit inspection & witness diagnostics
zerostyl-cli         `zerostyl-prove` — off-chain proving & verification
zerostyl-exporter    `zerostyl-export` — #[zk_private] → circuit + ABI + bindings
packages/sdk-ts      TypeScript SDK (@zerostyl/sdk-ts, npm)
packages/sdk-py      Python SDK (zerostyl-sdk, PyPI)
  • Command-line tools: zerostyl-debug, zerostyl-prove, zerostyl-export, zerostyl-orbit.
  • On-chain path: the verifier and gadget crates compile to wasm32-unknown-unknown for the Stylus runtime.

Project resources


Closing

ZeroStyl delivers an end-to-end, open-source zero-knowledge development workflow for Arbitrum Stylus — from circuit building and debugging to proving, verification, privacy-safe ABI export, typed SDKs, and per-chain deployability analysis.

The work does not stop at the close of the grant. The focus going forward is to improve the toolkit as far as it can go, to have it professionally audited, and to grow awareness so that more developers adopt privacy tooling on Stylus.

Interesting project. Privacy tools can be valuable, but for everyday users the important part will be clear and simple explanations of what is private, what is public, and what they need to do. Making that easy to understand will matter a lot.

1 Like

Thanks! Completely agree.

That’s exactly why I’m planning a series of videos where I build something concrete from A to Z. The goal is to make it very easy for developers who aren’t familiar with zero-knowledge proofs to clearly understand both the value and, more importantly, the real need for them.

Alongside that, there’s a secondary but really important objective (as you mentioned): helping everyday users understand that on the blockchain everything is public and traceable by default and that transparent solutions exist to fix this without sacrificing usability.

Clear and simple explanations will be at the heart of the whole series.

1 Like