No project description provided
Project description
:thought_balloon:
EZKL
Easy Zero-Knowledge Inference
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:
- Define a computational graph, for instance a neural network (but really any arbitrary set of operations), as you would normally in pytorch or tensorflow.
- Export the final graph of operations as an .onnx file and some sample inputs to a
.json
file. - 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"
"I ran my private neural network on some public data and it produced this output"
"I correctly ran this publicly available neural network on some public data and it produced this output"
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.
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
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:
-
See currently open issues for ideas on how to contribute.
-
For PRs we use the conventional commits naming convention.
-
To report bugs or request new features create a new issue within Issues to inform the greater community.
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.
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 Distributions
Built Distributions
Hashes for ezkl-12.0.0-cp37-abi3-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0019807eeca2e8b80eee17ac58e1f3ef96abcc2d54890e0248d17f711a21b351 |
|
MD5 | 7a7847dbdc84e71d637491be544dbc19 |
|
BLAKE2b-256 | 8fb638cbee523d85ec74d0c6c3fbaca5caf1e236e34f5a4e131cd17c83efe382 |
Hashes for ezkl-12.0.0-cp37-abi3-musllinux_1_2_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | af5470483518e8d21dd468e91499c4ee256f7e59712f4c3317b05c038ac6944a |
|
MD5 | 7c80d927c16f18219643a034f5c25968 |
|
BLAKE2b-256 | 8211a712187edd4178017716b94ade8937085e3fea7b5ce0c841570281b3b42e |
Hashes for ezkl-12.0.0-cp37-abi3-musllinux_1_2_armv7l.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e3967e4a2549fff0aa2bcd05ad9547360facc8c3ba0ba06b7234b4e07f94ba08 |
|
MD5 | 9ac97de09a507a4565180b1042d541a1 |
|
BLAKE2b-256 | 0169315d6cc8ee985d55a9e9bb91051d0b3a7c7801e65efed4fda0ed8e925eed |
Hashes for ezkl-12.0.0-cp37-abi3-musllinux_1_2_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 85ffead969f24ab94d3d20439601adf2d87645af0494476ed032892e061dee2d |
|
MD5 | 27f31b4a75cba24ff68427e725e52471 |
|
BLAKE2b-256 | abadac39a40ce364db6324de3384688a47b656a9cdfe53c8a03fb2fb3395bcad |
Hashes for ezkl-12.0.0-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 683299d47ea0cf07d32c940a3704d7e2bae333e3d02f6b4152e08af20d146e5f |
|
MD5 | 80e208f9ab99bf3c75d66514e1f0d2c8 |
|
BLAKE2b-256 | 6b256b87676ef306d01b46dd1e9ba7526c55987ba338d0f32c6cce08a905fc12 |
Hashes for ezkl-12.0.0-cp37-abi3-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8e5a80cc5b8476993e046614d30e2e16534fca3c10006775cd756e68e583c5b3 |
|
MD5 | ee9fa0ca6ddcf2f26c38f8101cf1a4af |
|
BLAKE2b-256 | 2d046f645a0f3f6cbd4b36d0ead32b607c50a4bef7ae16f62e55a8e4dfe5cb88 |
Hashes for ezkl-12.0.0-cp37-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ebe432ba1aea9a2c4d6612d41b111898543649d1ee68818b6f298479981f47eb |
|
MD5 | 28fe77b09304219583677b95c515103c |
|
BLAKE2b-256 | 00d0bcf5c7c4c3cb3b2e23cce4d14b8174ed60f024735698ebcca6e9f465ad92 |