-
Notifications
You must be signed in to change notification settings - Fork 217
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* getting started with python sdk documentation * improve python sdk doc * transpiler description * minor changes * revert change
- Loading branch information
Showing
3 changed files
with
159 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
--- | ||
id: aleo-sdk | ||
title: Aleo SDK | ||
sidebar_label: Aleo SDK | ||
--- | ||
|
||
<!-- markdown-link-check-disable --> | ||
[![github]](https://github.com/AleoHQ/python-sdk/tree/master/sdk) | ||
<!-- markdown-link-check-enable --> | ||
|
||
[github]: https://img.shields.io/badge/github-8da0cb?style=for-the-badge&labelColor=555555&logo=github | ||
|
||
[**aleo on PyPI**](https://pypi.org/project/aleo/) | ||
|
||
Aleo Python bindings for building zero-knowledge applications. | ||
|
||
This project uses `PyO3` and `Maturin` to provide a Python library named `aleo` that binds to `snarkVM` Rust functionalities. The resulting `aleo` library can be easily installed and used within Python. The project is at an early stage. At the moment, only Mac OS 11 or newer on Apple Silicon is supported - support for other operating systems will follow. If you are using another operating system, you may be able to build the library yourself following the instructions below. | ||
|
||
Supported functionalities currently include: | ||
* Private key generation | ||
|
||
## Usage | ||
The `aleo` Python library is available on [PyPI](https://pypi.org/project/aleo/) for installation. | ||
|
||
### Installation | ||
Ensure you have Python 3.11 or newer installed. If your operating system is supported, you can install the library from pip: | ||
|
||
```bash | ||
pip3 install aleo | ||
``` | ||
|
||
<!-- markdown-link-check-disable --> | ||
Alternatively, you can also install from a `.whl` file, either from the [GitHub repository](https://github.com/AleoHQ/python-sdk/tree/master/sdk/target/wheels), or by building it yourself. For the installation, use a command like this: | ||
<!-- markdown-link-check-enable --> | ||
|
||
```bash | ||
pip3 install aleo-0.0.3-cp311-cp311-macosx_11_0_arm64.whl | ||
``` | ||
|
||
Note: On some systems, you may need to use `pip` instead of `pip3`. | ||
|
||
### Example use | ||
You can import the library, generate a private key object, and print it as a string as in the following example: | ||
```Python | ||
import aleo | ||
private_key = aleo.PrivateKey() | ||
print(private_key.to_string()) | ||
``` | ||
|
||
<!-- markdown-link-check-disable --> | ||
### Build Instructions | ||
To build it, first clone the [GitHub repository](https://github.com/AleoHQ/python-sdk/tree/master/sdk). Then, run the following command: | ||
```bash | ||
bash build.sh | ||
``` | ||
<!-- markdown-link-check-enable --> | ||
|
||
After successful building, you will find a new `.whl` file in the `target/wheels` directory that you can install using the command from above. | ||
|
||
## Building Python Apps | ||
|
||
Further documentation and tutorials as to how to use the `aleo` Python library will follow soon. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
--- | ||
id: zkml-transpiler | ||
title: zkml transpiler | ||
sidebar_label: zkml Transpiler | ||
--- | ||
|
||
<!-- markdown-link-check-disable --> | ||
[![github]](https://github.com/AleoHQ/python-sdk/tree/master/zkml) | ||
<!-- markdown-link-check-enable --> | ||
|
||
[github]: https://img.shields.io/badge/github-8da0cb?style=for-the-badge&labelColor=555555&logo=github | ||
|
||
[**zkml on PyPI**](https://pypi.org/project/zkml/) | ||
|
||
Aleo transpiler for building zero-knowledge machine learning applications. | ||
|
||
This project provides a Python library named `zkml` that transpiles `scikit-learn` machine learning models into a `Leo` project for inference. The resulting leo project can then be run and executed from Python. The project is at an early stage. | ||
|
||
Supported functionalities currently include: | ||
* Decision tree classifiers | ||
|
||
## Usage | ||
The `zkml` Python library is available on [PyPI](https://pypi.org/project/zkml/) for installation. | ||
|
||
### Prerequisites | ||
#### Python | ||
Ensure you have 3.9.6 or newer installed. | ||
- Verify with: | ||
```bash | ||
python3 --version | ||
``` | ||
- If not installed, follow the instructions [here](https://wiki.python.org/moin/BeginnersGuide/Download). | ||
|
||
#### Leo | ||
Ensure you have Leo version 1.9.3 or newer installed. | ||
- Verify with: | ||
```bash | ||
leo --version | ||
``` | ||
- If necessary, update: | ||
```bash | ||
leo update | ||
``` | ||
- Installation guide: [Leo Installation](./../../leo/01_installation.md) | ||
|
||
### Installation | ||
|
||
You can install the `zkml` Python library from PyPI using the following command: | ||
```bash | ||
pip3 install zkml | ||
``` | ||
|
||
<!-- markdown-link-check-disable --> | ||
Note: On some systems, you may need to use `pip` instead of `pip3`. | ||
Alternatively, you can also install through the `.whl` file or in editable mode from the [GitHub repository](https://github.com/AleoHQ/python-sdk/tree/master/zkml). | ||
<!-- markdown-link-check-enable --> | ||
|
||
### Usage | ||
|
||
<!-- markdown-link-check-disable --> | ||
Below is a brief description of the classes and functions provided by the library. Detailed documentation is in progress and will be available soon. | ||
We encourage you to also check out the [examples on GitHub](https://github.com/AleoHQ/python-sdk/tree/master/zkml/examples). | ||
<!-- markdown-link-check-enable --> | ||
|
||
* In a first step, you can receive an object of the class `zkml.LeoTranspiler(model, validation_data)` | ||
* For the `model` parameter, pass the trained scikit-learn model | ||
* For the `validation_data` parameter, pass the training or validation dataset. While this parameter is not strictly required, we recommend using it. The dataset is used to compute a fixed-point scaling factor and the required Leo integer types. Using the parameter helps to ensure numerical stability in the inference computation. The larger the dataset, the better. | ||
* In a second step, you can start the transpilation process through `leo_transpiler.to_leo(path, project_name, model_as_input)` | ||
* For the `path` parameter, pass the path where the new leo project should be stored in | ||
* For the `project_name` parameter, pass the desired name of the leo project. | ||
* The Boolean `model_as_input` parameter is optional and by default `False`. If set to `False`, the model parameters (i.e., thresholds, weights, biases) are hardcoded in the Leo code. If set to `True`, these model parameters are treated as additional circuit inputs. | ||
* After transpiling, you can run the computation of the Leo project through `leo_transpiler.run(input)`, and receive an object of class `LeoComputation` | ||
* For the `input` parameter, pass the inference data sample or dataset | ||
* Similarly, after transpiling, you can execute the Leo project through `leo_transpiler.execute(input)`, and receive an object of class `ZeroKnowledgeProof` | ||
* For the `input` parameter, pass the inference data sample or dataset | ||
|
||
## Building Python Apps | ||
|
||
<!-- markdown-link-check-disable --> | ||
Please check out the [examples on GitHub](https://github.com/AleoHQ/python-sdk/tree/master/zkml/examples). | ||
Further documentation and tutorials as to how to use the `zkml` Python library will follow soon. | ||
<!-- markdown-link-check-enable --> |