Skip to main content


:thought_balloon:

EZKL


Easy Zero-Knowledge Inference

Test

ezkl is a library and command-line tool for doing inference for deep learning models and other computational graphs in a zk-snark (ZKML). It enables the following workflow:

  1. Define a computational graph, for instance a neural network (but really any arbitrary set of operations), as you would normally in pytorch or tensorflow.
  2. Export the final graph of operations as an .onnx file and some sample inputs to a .json file.
  3. Point ezkl to the .onnx and .json files to generate a ZK-SNARK circuit with which you can prove statements such as:

"I ran this publicly available neural network on some private data and it produced this output"

Notebook

"I ran my private neural network on some public data and it produced this output"

Notebook

"I correctly ran this publicly available neural network on some public data and it produced this output"

Notebook

In the backend we use the collaboratively-developed Halo2 as a proof system.

The generated proofs can then be verified with much less computational resources, including on-chain (with the Ethereum Virtual Machine), in a browser, or on a device.

  • If you have any questions, we'd love for you to open up a discussion topic in Discussions. Alternatively, you can join the ✨EZKL Community Telegram Group💫.

  • For more technical writeups and details check out our blog.

  • To see what you can build with ezkl, check out cryptoidol.tech where ezkl is used to create an AI that judges your singing ... forever.


getting started ⚙️

The easiest way to get started is to try out a notebook.

Python

Install the python bindings by calling.

pip install ezkl

Or for the GPU:

pip install ezkl-gpu

Google Colab Example to learn how you can train a neural net and deploy an inference verifier onchain for use in other smart contracts. Notebook

More notebook tutorials can be found within examples/notebooks.

CLI

Install the CLI

curl https://raw.githubusercontent.com/zkonduit/ezkl/main/install_ezkl_cli.sh | bash

https://user-images.githubusercontent.com/45801863/236771676-5bbbbfd1-ba6f-418a-902e-20738ce0e9f0.mp4

For more details visit the docs. The CLI is faster than Python, as it has less overhead. For even more speed and convenience, check out the remote proving service, which feels like the CLI but is backed by a tuned cluster.

Build the auto-generated rust documentation and open the docs in your browser locally. cargo doc --open

In-browser EVM verifier

As an alternative to running the native Halo2 verifier as a WASM binding in the browser, you can use the in-browser EVM verifier. The source code of which you can find in the in-browser-evm-verifier directory and a README with instructions on how to use it.

building the project 🔨

Rust CLI

You can install the library from source

cargo install --locked --path .

ezkl now auto-manages solc installation for you.

building python bindings

Python bindings exists and can be built using maturin. You will need rust and cargo to be installed.

python -m venv .env
source .env/bin/activate
pip install -r requirements.txt
maturin develop --release --features python-bindings
# dependencies specific to tutorials
pip install torch pandas numpy seaborn jupyter onnx kaggle py-solc-x web3 librosa tensorflow keras tf2onnx

GPU Acceleration

If you have access to NVIDIA GPUs, you can enable acceleration by building with the feature icicle and setting the following environment variable:

export ENABLE_ICICLE_GPU=true

GPU acceleration is provided by Icicle

To go back to running with CPU, the previous environment variable must be unset instead of being switch to a value of false:

unset ENABLE_ICICLE_GPU

NOTE: Even with the above environment variable set, icicle is disabled for circuits where k <= 8. To change the value of k where icicle is enabled, you can set the environment variable ICICLE_SMALL_K.

contributing 🌎

If you're interested in contributing and are unsure where to start, reach out to one of the maintainers:

  • dante (alexander-camuto)
  • jason (jasonmorton)

More broadly:

Any contribution intentionally submitted for inclusion in the work by you shall be licensed to Zkonduit Inc. under the terms and conditions specified in the CLA, which you agree to by intentionally submitting a contribution. In particular, you have the right to submit the contribution and we can distribute it, among other terms and conditions.

no security guarantees

Ezkl is unaudited, beta software undergoing rapid development. There may be bugs. No guarantees of security are made and it should not be relied on in production.

NOTE: Because operations are quantized when they are converted from an onnx file to a zk-circuit, outputs in python and ezkl may differ slightly.

no warranty

Copyright (c) 2024 Zkonduit Inc. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Release files for ezkl-gpu 16.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for ezkl-gpu 16.1.0
File Interpreter ABI Platform
ezkl_gpu-16.1.0-cp37-abi3-manylinux_2_35_x86_64.whl CPython 3.7 abi3 Linux glibc 2.35+ x86-64 Details

Release files / ezkl_gpu-16.1.0-cp37-abi3-manylinux_2_35_x86_64.whl

Download URL ezkl_gpu-16.1.0-cp37-abi3-manylinux_2_35_x86_64.whl
Size 59.6 MB
Tags CPython 3.7 Linux glibc 2.35+ x86-64 abi3
SHA-256 checksum
How to use checksums
0b2eba76ef0efc82b300224cfa8277d645769f23d833ce7b58a55efa1d5c5424
BLAKE2b-256 checksum
How to use checksums
ace3f078052e25e446b1ea1dcfc365ab876692d1255966cc36e8ce7f25985782
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.0.1 CPython/3.12.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 6, 2024.

Transparency log

Release history Release notifications | RSS feed

This release

16.1.0 This release

1 release file

15.6.3

1 release file

15.6.2

1 release file

15.6.0

1 release file

15.5.0

1 release file

15.4.0

1 release file

15.1.0

1 release file

15.0.0

1 release file

14.0.0

1 release file

13.0.1

1 release file

13.0.0

1 release file

12.0.1

1 release file

12.0.0

1 release file

11.4.2

1 release file

11.4.1

1 release file

11.4.0

1 release file

11.3.2

1 release file

11.2.2

1 release file

11.2.0

1 release file

11.1.0

1 release file

11.0.14

1 release file

11.0.11

1 release file

11.0.7

1 release file

10.4.2

1 release file

10.2.9

1 release file

10.2.7

1 release file

10.1.0

1 release file

10.0.2

1 release file

9.5.0

1 release file

9.4.4

1 release file

9.4.3

1 release file

9.1.0

1 release file

9.0.1

1 release file

8.4.1

1 release file

8.3.0

1 release file

8.1.7

1 release file

8.0.1

1 release file

8.0.0

1 release file

7.1.12

1 release file

7.1.4

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page