This repo creates zk circuit equivalents of the Optimism RPGF allocator (see here).
We leverage ezkl to build the circuit directly from the python code in a jupyter notebook rpgf3_allocator.ipynb
. The notebook has associated markdown cells that explain the circuit and the steps to build it.
- We first build a pytorch equivalent of the allocator function, originally in pandas.
- We then export the pytorch function to an onnx file and use the ezkl compiler to convert it into a zk-circuit.
- We generate a proof for a given input and verify.
- We add sanity checks for numerical accuracy and compare the results with the original pandas function.
To get started
python -m venv .env
source .env/bin/activate
pip install ezkl torch pandas numpy jupyter onnx plotly onnxruntime
Then open the notebook and follow the instructions.
There are two notebooks:
rpgf3_allocator.ipynb
runs on dummy data for validation.rpgf3_allocator_real.ipynb
runs on data of truncated vote amounts that the OP foundation has published.