Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**/.DS_Store
24 changes: 22 additions & 2 deletions Getting Started/Installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,61 +4,81 @@ order: 96
---

+++ Local CLI

1. Install the binary with the following bash script.

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

2. Alternatively, build from source:

```bash
git clone git@github.com:zkonduit/ezkl.git
cd ezkl
cargo install --force --path .
```

For detailed options, use `ezkl --help` or `ezkl <command> --help`.

+++ Python
Install EZKL using pip:

```bash
pip install ezkl
```

You may also need to install additional dependencies:

- `onnx` for exporting models
- PyTorch or TensorFlow for creating models

To use EZKL in your Python code:

```bash
import ezkl
```

+++ JavaScript
Install EZKL using npm:

```bash
npm install @ezkljs/engine
```

To use EZKL in your JavaScript code:

```bash
import { Engine } from '@ezkljs/engine';
```
+++ Remote CLI

+++ Remote CLI (Lilith)

1. Install `archon` with the following script

```bash
curl https://download.ezkl.xyz/download_archon.sh | bash
```

2. If your system settings block the installed binary you will need to allow your system to run the binary.

3. Set the server environment variable:

```bash
export ARCHON_SERVER_URL="https://archon-v0.ezkl.xyz"
```

4. Test the connection:

```bash
archon ping
```

+++

## Additional Notes

- While there is some support for Windows with the original `ezkl` repository, unfortunately Lilith does not work on Windows systems.
- EZKL uses your system's `solc` Solidity compiler. You may need to adjust it using `svm-rs` or `solc-select`.
- For rendering model circuits with EZKL, compile with the `render` feature and install required libraries (e.g., `libexpat1-dev` and `libfreetype6-dev` on Debian systems).
- For EZKL Rust documentation, use `cargo doc --open`.
- For EZKL Rust documentation, use `cargo doc --open`.
63 changes: 54 additions & 9 deletions Getting Started/Setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,164 +2,209 @@
icon: gear
order: 95
---

The lifecycle of an EZKL proof consists of three core components: Setup, Prove, and Verify. This page focuses on the Setup phase, which defines the rules for proof generation and verification. Recall that:

- **Setup**: Defines proof parameters and generates keys (performed by developers)
- **Prove**: Generates a proof based on the setup (performed by users)
- **Verify**: Checks the validity of a proof (performed by verifiers)

### Process

The setup process involves the following steps:

1. **Generate settings**: Creates a configuration file with default parameters for the circuit.
2. **Calibrate settings (optional)**: Fine-tunes the circuit parameters to optimize for either accuracy or resource usage.
3. **Compile the model**: Converts the ONNX model into a format optimized for zero-knowledge proofs.
4. **Run setup**: Generates the cryptographic keys needed for proving and verifying.

### Parameters

To perform the setup, you'll need to provide and/or create the following:

#### ONNX File

For PyTorch:

```python
import torch.onnx

dummy_input = torch.randn(1, 3, 224, 224) # Adjust input dimensions as needed
torch.onnx.export(model, dummy_input, "network.onnx", opset_version=10)
```

For TensorFlow:

```python
import tf2onnx

onnx_model, _ = tf2onnx.convert.from_keras(model)
with open("network.onnx", "wb") as f:
f.write(onnx_model.SerializeToString())
```
#### Structured Reference String (SRS)
The SRS is a common, public piece of cryptographic data. You can download it using the EZKL CLI:
```bash
ezkl get-srs
```

#### Configuration Options

These are defined in the `settings.json` file, which is generated and optionally calibrated during the setup process.

### Instructions

+++ Local CLI

1. Generate settings:

```bash
ezkl gen-settings
```

This creates a settings.json file with default parameters based on your ONNX model.

2. Calibrate settings (optional):
``` bash

```bash
ezkl calibrate-settings
```

This optimizes the settings for resource usage. You can also use `--target accuracy` to optimize for accuracy, and `--target resources` to optimize for resources.

3. Compile model:

```bash
ezkl compile-circuit
```

This converts your ONNX model into an optimized format for zero-knowledge proofs, creating the `network.ezkl` file.

4. Run setup:

```bash
ezkl setup
```

This generates the cryptographic keys needed for proving and verifying.

+++ Python

1. Generate settings:

```python
import ezkl

ezkl.gen_settings("network.onnx")
```

This creates a `settings.json` file with default parameters based on your ONNX model.

2. Calibrate settings (optional):

```python
ezkl.calibrate_settings("network.onnx", "settings.json", target="resources")
```

This optimizes the settings for resource usage. You can also use `target="accuracy"` to optimize for accuracy.

3. Compile model:

```python
ezkl.compile_circuit("network.onnx", "network.ezkl", "settings.json")
```

This converts your ONNX model into an optimized format for zero-knowledge proofs, creating the `network.ezkl` file.

4. Run setup:

```python
ezkl.setup("network.ezkl", "vk.key", "pk.key", "kzg.srs")
```

This generates the cryptographic keys needed for proving and verifying.

+++ JavaScript

1. Generate settings:

```javascript
import { Engine } from '@ezkljs/engine';
import { Engine } from "@ezkljs/engine";

const engine = new Engine();
await engine.genSettings("network.onnx");
```

This creates a `settings.json` file with default parameters based on your ONNX model.

2. Calibrate settings (optional):

```javascript
await engine.calibrateSettings("network.onnx", "settings.json", { target: "resources" });
await engine.calibrateSettings("network.onnx", "settings.json", {
target: "resources",
});
```

This optimizes the settings for resource usage. You can also use `{ target: "accuracy" }` to optimize for accuracy.

3. Compile model:

```javascript
await engine.compileCircuit("network.onnx", "network.ezkl", "settings.json");
```

This converts your ONNX model into an optimized format for zero-knowledge proofs, creating the `network.ezkl` file.

4. Run setup:

```javascript
await engine.setup("network.ezkl", "vk.key", "pk.key", "kzg.srs");
```

This generates the cryptographic keys needed for proving and verifying.

+++ Remote CLI (Lilith)

1. Upload your files,

```bash
archon create-artifact -a test -i input.json -m network.onnx -c calibration.json
```

2. Generate settings:

```bash
archon job -a test gen-settings
```

This creates a `settings.json` file with default parameters based on your ONNX model.

3. Calibrate settings (optional):

```bash
archon job -a test calibrate-settings
```

This optimizes the settings for resource usage. You can also use `--target accuracy` to optimize for accuracy, and `--target resources` to optimize for resources.

4. Compile model:

```bash
archon job -a test compile-circuit
```

This converts your ONNX model into an optimized format for zero-knowledge proofs, creating the `network.ezkl` file.

4. Run setup:

```bash
archon job -a test setup
```

This generates the cryptographic keys needed for proving and verifying.
+++

### Outputs

The setup process will generate the following:

- `network.onnx`: model in ONNX format
- `settings.json`: generated file which is optionally calibrated during the setup process
- `network.ezkl`: compiled circuit created from your ONNX model in step 3.
- `kzg.srs`: Structured Reference String (SRS), which you can download using `ezkl get-srs`.
- `vk.key` and `pk.key`: verification and proving keys generated during the setup process
- `vk.key` and `pk.key`: verification and proving keys generated during the setup process
Loading