JSTProve — Verifiable ML by Inference Labs (Python CLI)
Project description
_/ _/_/_/ _/_/_/_/_/ _/_/_/
_/ _/ _/ _/ _/ _/ _/_/ _/_/ _/ _/ _/_/
_/ _/_/ _/ _/_/_/ _/_/ _/ _/ _/ _/ _/_/_/_/
_/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/
_/_/ _/_/_/ _/ _/ _/ _/_/ _/ _/_/_/
JSTProve
Zero-knowledge proofs of ML inference on ONNX models — powered by Polyhedra Network’s Expander (GKR/sum-check prover) and Expander Compiler Collection (ECC).
- 🎯 You bring ONNX → we quantize, compile to a circuit, generate a witness, prove, and verify — via a simple CLI.
- ✅ Supported ops (current): Conv2D, GEMM/MatMul (FC), ReLU, MaxPool2D.
- 🧰 CLI details: see docs/cli.md
What is JSTProve?
JSTProve is a zkML toolkit/CLI that produces zero-knowledge proofs of AI inference. You provide an ONNX model and inputs; JSTProve handles quantization, circuit generation (via ECC), witness creation, proving (via Expander), and verification — with explicit, user-controlled file paths.
High-level architecture
- Python pipeline: Converts ONNX → quantized ONNX, prepares I/O, drives the Rust runner, exposes the CLI.
- Rust crate:
rust/jstprove_circuitsimplements layer circuits (Conv2D, ReLU, MaxPool2D, GEMM/FC) and a runner. - Circuit frontend: ECC Rust API for arithmetic circuits.
- Prover backend: Expander (GKR/sum-check prover/verification).
ONNX model ─► Quantizer (Py) ─► Circuit via ECC (Rust) ─► Witness (Rust) ─► Proof (Rust) ─► Verify (Rust)
Design principles
- User-friendly frontend to Expander: A thin, practical, circuit-based layer that makes Expander/ECC easy to use from a simple CLI — no circuit classes, no path inference, predictable artifacts.
- Explicit & reproducible: You pass exact paths; we emit concrete artifacts (circuit, quantized ONNX, witness, proof). No hidden discovery or heuristics.
- Clear separation: Python orchestrates the pipeline and I/O; Rust implements the circuits and invokes Expander/ECC.
- Quantization that's simple & faithful: We scale tensors, round to integers, run the model, and (where needed) rescale outputs back. Scaling keeps arithmetic cheap while remaining close to the original FP behavior.
- Small, fast circuits when possible: Where safe, we fuse common patterns (e.g., Linear + ReLU, Conv + ReLU) into streamlined circuit fragments to reduce constraints.
- Deterministic debugging: We prefer loud failures and inspectable intermediates (e.g.,
*_reshaped.json) over implicit magic.
Installation
Run commands from the repo root so the runner binary path (e.g.,
./target/release/onnx_generic_circuit) resolves.
0) System packages
Ubuntu/Debian
sudo apt-get update && sudo apt-get install -y \
libopenmpi-dev openmpi-bin pkg-config libclang-dev clang
macOS
brew install open-mpi llvm
1) Rust toolchain
Install Rust via rustup (if you don't have it):
# macOS/Linux:
curl https://sh.rustup.rs -sSf | sh
# then restart your shell
Verify your install:
rustup --version
rustc --version
cargo --version
This repo includes a
rust-toolchain.tomlthat pins the required nightly. When you runcargoin this directory, rustup will automatically download/use the correct toolchain. You do not need to runrustup override set nightly.
(Optional) If you want to prefetch nightly ahead of time:
rustup toolchain install nightly
2) Install the app
Install from PyPI
pip install jstprove
Or install from source
Clone the repository:
git clone https://github.com/inference-labs-inc/JSTProve.git
cd JSTProve
Use venv to create a virtual environment (recommended):
python -m venv .venv
# macOS/Linux:
source .venv/bin/activate
Install project dependencies:
pip install -r requirements.txt
3) Install & verify Expander (before building JSTProve)
JSTProve relies on Polyhedra Network’s Expander (prover) and Expander Compiler Collection (ECC) crates. For a clean environment, install Expander and run its self-checks first.
# In a sibling folder (or anywhere you keep deps)
git clone https://github.com/PolyhedraZK/Expander.git
cd Expander
# Build (uses the toolchain you configured with rustup)
cargo build --release
Verify Expander: follow the “Correctness Test” (or equivalent) in the Expander README. If you’re unsure, a quick smoke test is often:
cargo test --release
Refer to the Expander README for the authoritative verification command(s), which may change over time.
(You do not need to clone ECC separately unless you plan to override Cargo git sources; Cargo will fetch ECC automatically when building JSTProve.)
4) Build the JSTProve runner (optional; the CLI can build on demand)
# From JSTProve repo root
cargo build --release
./target/release/onnx_generic_circuit --help
The CLI
compilestep will (re)build the runner automatically when needed, so this step is just a sanity check.
5) Try the CLI
jstprove --help
You can now follow the Quickstart commands (compile → witness → prove → verify).
Quickstart (LeNet demo)
Demo paths:
- ONNX:
python/models/models_onnx/lenet.onnx - Input JSON:
python/models/inputs/lenet_input.json - Artifacts:
artifacts/lenet/*
- Compile → circuit + quantized ONNX
jstprove compile \
-m python/models/models_onnx/lenet.onnx \
-c artifacts/lenet/circuit.txt \
-q artifacts/lenet/quantized.onnx
- Witness → reshape/scale inputs, run model, write witness + outputs
jstprove witness \
-c artifacts/lenet/circuit.txt \
-q artifacts/lenet/quantized.onnx \
-i python/models/inputs/lenet_input.json \
-o artifacts/lenet/output.json \
-w artifacts/lenet/witness.bin
- Prove → witness → proof
jstprove prove \
-c artifacts/lenet/circuit.txt \
-w artifacts/lenet/witness.bin \
-p artifacts/lenet/proof.bin
- Verify → check the proof (needs quantized ONNX for input shapes)
jstprove verify \
-c artifacts/lenet/circuit.txt \
-q artifacts/lenet/quantized.onnx \
-i python/models/inputs/lenet_input.json \
-o artifacts/lenet/output.json \
-w artifacts/lenet/witness.bin \
-p artifacts/lenet/proof.bin
If it prints Verified, you're done 🎉
CLI reference
The CLI is intentionally minimal and doesn't infer paths. See docs/cli.md for subcommands, flags, and examples.
Troubleshooting
Contributing
See docs/CONTRIBUTING.md for dev setup, pre-commit hooks, and PR guidelines.
Legal
Placeholder (subject to change):
- License: See
LICENSE(TBD). Third-party components (e.g., Expander, ECC) are licensed under their respective terms.- No warranty: Provided “as is” without warranties or conditions of any kind. Use at your own risk.
- Security & export: Cryptography may be subject to local laws. Conduct your own security review before production use.
- Trademarks: All product names, logos, and brands are property of their respective owners.
Acknowledgments
We gratefully acknowledge Polyhedra Network for:
-
Expander — the GKR/sumcheck proving system we build on.
-
Expander Compiler Collection (ECC) — the circuit frontend used to construct arithmetic circuits for ML layers.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jstprove_test-0.1.0.tar.gz.
File metadata
- Download URL: jstprove_test-0.1.0.tar.gz
- Upload date:
- Size: 45.5 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.8.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e28529c188df436cde3b923b98cbb0e934c8170b8fef5bc5b55cf20ef52f05d6
|
|
| MD5 |
2450282a06d6af0a7fa5177c5735f0da
|
|
| BLAKE2b-256 |
e529139c2b71718c99b83b59b48bf97c9b74b87edd2fc10b0da1e0bdf1a6f703
|
File details
Details for the file jstprove_test-0.1.0-py3-none-any.whl.
File metadata
- Download URL: jstprove_test-0.1.0-py3-none-any.whl
- Upload date:
- Size: 45.5 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.8.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ead83a701824205d081f54e282cb102a6bea0f66adfb4e5ae58e68dd33ef1b03
|
|
| MD5 |
19f327e13d7b2f057ecee2d6ab287aa4
|
|
| BLAKE2b-256 |
b01d5249e5d5735761c9b8f45108d6f4154bb3cd327015e6a4e6fd7ebc7995c6
|