mirror of
https://github.com/MPCStats/zk-stats-lib.git
synced 2026-01-08 05:04:07 -05:00
331 lines
26 KiB
Plaintext
331 lines
26 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 1,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"Requirement already satisfied: ezkl==7.0.0 in /Users/mhchia/Library/Caches/pypoetry/virtualenvs/zkstats-brXmXluj-py3.12/lib/python3.12/site-packages (from -r ../../requirements.txt (line 1)) (7.0.0)\n",
|
|
"Requirement already satisfied: torch in /Users/mhchia/Library/Caches/pypoetry/virtualenvs/zkstats-brXmXluj-py3.12/lib/python3.12/site-packages (from -r ../../requirements.txt (line 2)) (2.2.0)\n",
|
|
"Requirement already satisfied: requests in /Users/mhchia/Library/Caches/pypoetry/virtualenvs/zkstats-brXmXluj-py3.12/lib/python3.12/site-packages (from -r ../../requirements.txt (line 3)) (2.31.0)\n",
|
|
"Requirement already satisfied: scipy in /Users/mhchia/Library/Caches/pypoetry/virtualenvs/zkstats-brXmXluj-py3.12/lib/python3.12/site-packages (from -r ../../requirements.txt (line 4)) (1.12.0)\n",
|
|
"Requirement already satisfied: numpy in /Users/mhchia/Library/Caches/pypoetry/virtualenvs/zkstats-brXmXluj-py3.12/lib/python3.12/site-packages (from -r ../../requirements.txt (line 5)) (1.26.3)\n",
|
|
"Requirement already satisfied: matplotlib in /Users/mhchia/Library/Caches/pypoetry/virtualenvs/zkstats-brXmXluj-py3.12/lib/python3.12/site-packages (from -r ../../requirements.txt (line 6)) (3.8.2)\n",
|
|
"Requirement already satisfied: statistics in /Users/mhchia/Library/Caches/pypoetry/virtualenvs/zkstats-brXmXluj-py3.12/lib/python3.12/site-packages (from -r ../../requirements.txt (line 7)) (1.0.3.5)\n",
|
|
"Requirement already satisfied: onnx in /Users/mhchia/Library/Caches/pypoetry/virtualenvs/zkstats-brXmXluj-py3.12/lib/python3.12/site-packages (from -r ../../requirements.txt (line 8)) (1.15.0)\n",
|
|
"Requirement already satisfied: filelock in /Users/mhchia/Library/Caches/pypoetry/virtualenvs/zkstats-brXmXluj-py3.12/lib/python3.12/site-packages (from torch->-r ../../requirements.txt (line 2)) (3.13.1)\n",
|
|
"Requirement already satisfied: typing-extensions>=4.8.0 in /Users/mhchia/Library/Caches/pypoetry/virtualenvs/zkstats-brXmXluj-py3.12/lib/python3.12/site-packages (from torch->-r ../../requirements.txt (line 2)) (4.9.0)\n",
|
|
"Requirement already satisfied: sympy in /Users/mhchia/Library/Caches/pypoetry/virtualenvs/zkstats-brXmXluj-py3.12/lib/python3.12/site-packages (from torch->-r ../../requirements.txt (line 2)) (1.12)\n",
|
|
"Requirement already satisfied: networkx in /Users/mhchia/Library/Caches/pypoetry/virtualenvs/zkstats-brXmXluj-py3.12/lib/python3.12/site-packages (from torch->-r ../../requirements.txt (line 2)) (3.2.1)\n",
|
|
"Requirement already satisfied: jinja2 in /Users/mhchia/Library/Caches/pypoetry/virtualenvs/zkstats-brXmXluj-py3.12/lib/python3.12/site-packages (from torch->-r ../../requirements.txt (line 2)) (3.1.3)\n",
|
|
"Requirement already satisfied: fsspec in /Users/mhchia/Library/Caches/pypoetry/virtualenvs/zkstats-brXmXluj-py3.12/lib/python3.12/site-packages (from torch->-r ../../requirements.txt (line 2)) (2023.12.2)\n",
|
|
"Requirement already satisfied: charset-normalizer<4,>=2 in /Users/mhchia/Library/Caches/pypoetry/virtualenvs/zkstats-brXmXluj-py3.12/lib/python3.12/site-packages (from requests->-r ../../requirements.txt (line 3)) (3.3.2)\n",
|
|
"Requirement already satisfied: idna<4,>=2.5 in /Users/mhchia/Library/Caches/pypoetry/virtualenvs/zkstats-brXmXluj-py3.12/lib/python3.12/site-packages (from requests->-r ../../requirements.txt (line 3)) (3.6)\n",
|
|
"Requirement already satisfied: urllib3<3,>=1.21.1 in /Users/mhchia/Library/Caches/pypoetry/virtualenvs/zkstats-brXmXluj-py3.12/lib/python3.12/site-packages (from requests->-r ../../requirements.txt (line 3)) (2.2.0)\n",
|
|
"Requirement already satisfied: certifi>=2017.4.17 in /Users/mhchia/Library/Caches/pypoetry/virtualenvs/zkstats-brXmXluj-py3.12/lib/python3.12/site-packages (from requests->-r ../../requirements.txt (line 3)) (2024.2.2)\n",
|
|
"Requirement already satisfied: contourpy>=1.0.1 in /Users/mhchia/Library/Caches/pypoetry/virtualenvs/zkstats-brXmXluj-py3.12/lib/python3.12/site-packages (from matplotlib->-r ../../requirements.txt (line 6)) (1.2.0)\n",
|
|
"Requirement already satisfied: cycler>=0.10 in /Users/mhchia/Library/Caches/pypoetry/virtualenvs/zkstats-brXmXluj-py3.12/lib/python3.12/site-packages (from matplotlib->-r ../../requirements.txt (line 6)) (0.12.1)\n",
|
|
"Requirement already satisfied: fonttools>=4.22.0 in /Users/mhchia/Library/Caches/pypoetry/virtualenvs/zkstats-brXmXluj-py3.12/lib/python3.12/site-packages (from matplotlib->-r ../../requirements.txt (line 6)) (4.47.2)\n",
|
|
"Requirement already satisfied: kiwisolver>=1.3.1 in /Users/mhchia/Library/Caches/pypoetry/virtualenvs/zkstats-brXmXluj-py3.12/lib/python3.12/site-packages (from matplotlib->-r ../../requirements.txt (line 6)) (1.4.5)\n",
|
|
"Requirement already satisfied: packaging>=20.0 in /Users/mhchia/Library/Caches/pypoetry/virtualenvs/zkstats-brXmXluj-py3.12/lib/python3.12/site-packages (from matplotlib->-r ../../requirements.txt (line 6)) (23.2)\n",
|
|
"Requirement already satisfied: pillow>=8 in /Users/mhchia/Library/Caches/pypoetry/virtualenvs/zkstats-brXmXluj-py3.12/lib/python3.12/site-packages (from matplotlib->-r ../../requirements.txt (line 6)) (10.2.0)\n",
|
|
"Requirement already satisfied: pyparsing>=2.3.1 in /Users/mhchia/Library/Caches/pypoetry/virtualenvs/zkstats-brXmXluj-py3.12/lib/python3.12/site-packages (from matplotlib->-r ../../requirements.txt (line 6)) (3.1.1)\n",
|
|
"Requirement already satisfied: python-dateutil>=2.7 in /Users/mhchia/Library/Caches/pypoetry/virtualenvs/zkstats-brXmXluj-py3.12/lib/python3.12/site-packages (from matplotlib->-r ../../requirements.txt (line 6)) (2.8.2)\n",
|
|
"Requirement already satisfied: docutils>=0.3 in /Users/mhchia/Library/Caches/pypoetry/virtualenvs/zkstats-brXmXluj-py3.12/lib/python3.12/site-packages (from statistics->-r ../../requirements.txt (line 7)) (0.20.1)\n",
|
|
"Requirement already satisfied: protobuf>=3.20.2 in /Users/mhchia/Library/Caches/pypoetry/virtualenvs/zkstats-brXmXluj-py3.12/lib/python3.12/site-packages (from onnx->-r ../../requirements.txt (line 8)) (4.25.2)\n",
|
|
"Requirement already satisfied: six>=1.5 in /Users/mhchia/Library/Caches/pypoetry/virtualenvs/zkstats-brXmXluj-py3.12/lib/python3.12/site-packages (from python-dateutil>=2.7->matplotlib->-r ../../requirements.txt (line 6)) (1.16.0)\n",
|
|
"Requirement already satisfied: MarkupSafe>=2.0 in /Users/mhchia/Library/Caches/pypoetry/virtualenvs/zkstats-brXmXluj-py3.12/lib/python3.12/site-packages (from jinja2->torch->-r ../../requirements.txt (line 2)) (2.1.4)\n",
|
|
"Requirement already satisfied: mpmath>=0.19 in /Users/mhchia/Library/Caches/pypoetry/virtualenvs/zkstats-brXmXluj-py3.12/lib/python3.12/site-packages (from sympy->torch->-r ../../requirements.txt (line 2)) (1.3.0)\n",
|
|
"\n",
|
|
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip is available: \u001b[0m\u001b[31;49m23.3.1\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m23.3.2\u001b[0m\n",
|
|
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpip install --upgrade pip\u001b[0m\n",
|
|
"Note: you may need to restart the kernel to use updated packages.\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"pip install -r ../../requirements.txt"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 2,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"import ezkl\n",
|
|
"import torch\n",
|
|
"from torch import nn\n",
|
|
"import json\n",
|
|
"import os\n",
|
|
"import time\n",
|
|
"import scipy\n",
|
|
"import numpy as np\n",
|
|
"import matplotlib.pyplot as plt\n",
|
|
"import statistics\n",
|
|
"import math"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 3,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"from zkstats.core import prover_gen_settings, setup, prover_gen_proof, verifier_verify, get_data_commitment_maps"
|
|
]
|
|
},
|
|
{
|
|
"attachments": {},
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": []
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 4,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"# init path\n",
|
|
"os.makedirs(os.path.dirname('shared/'), exist_ok=True)\n",
|
|
"os.makedirs(os.path.dirname('prover/'), exist_ok=True)\n",
|
|
"verifier_model_path = os.path.join('shared/verifier.onnx')\n",
|
|
"prover_model_path = os.path.join('prover/prover.onnx')\n",
|
|
"verifier_compiled_model_path = os.path.join('shared/verifier.compiled')\n",
|
|
"prover_compiled_model_path = os.path.join('prover/prover.compiled')\n",
|
|
"pk_path = os.path.join('shared/test.pk')\n",
|
|
"vk_path = os.path.join('shared/test.vk')\n",
|
|
"proof_path = os.path.join('shared/test.pf')\n",
|
|
"settings_path = os.path.join('shared/settings.json')\n",
|
|
"# srs_path = os.path.join('shared/kzg.srs')\n",
|
|
"# this is private to prover since it contains actual data\n",
|
|
"sel_data_path = os.path.join('prover/sel_data.json')\n",
|
|
"witness_path = os.path.join('prover/witness.json')"
|
|
]
|
|
},
|
|
{
|
|
"attachments": {},
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"======================= ZK-STATS FLOW ======================="
|
|
]
|
|
},
|
|
{
|
|
"attachments": {},
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Step 1\n",
|
|
"Verifier calls `export_onnx` with dummy data, to generate the onnx model. Dummy data is used to infer the shape of the model\n",
|
|
"\n",
|
|
"### Output\n",
|
|
"- `verifier.onnx` file"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 5,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"data_path = os.path.join('data.json')"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 6,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"scales = [2]\n",
|
|
"selected_columns = ['x', 'y']\n",
|
|
"commitment_maps = get_data_commitment_maps(data_path, scales)"
|
|
]
|
|
},
|
|
{
|
|
"attachments": {},
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Step 2\n",
|
|
"- User defines their computation in a function with signature `computation(state: State, x: list[torch.Tensor])`.\n",
|
|
"- Prover calls `computation_to_model(computation)` to derive the actual model.\n",
|
|
"- Prover calls `prover_gen_settings`: export onnx file and compute the settings required by `ezkl.calibrate_settings`"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 7,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"/var/folders/t3/5psrvr1x0w1_6n9kx2n7d9700000gn/T/ipykernel_37051/4262130413.py:7: TracerWarning: torch.tensor results are registered as constants in the trace. You can safely ignore this warning if you use this function to create tensors out of constant variables that would be the same every time you call this function. In any other case, this might cause the trace to be incorrect.\n",
|
|
" return state.mean(torch.tensor([out_0, out_1]).reshape(1,-1,1))\n",
|
|
"/var/folders/t3/5psrvr1x0w1_6n9kx2n7d9700000gn/T/ipykernel_37051/4262130413.py:7: TracerWarning: Converting a tensor to a Python float might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!\n",
|
|
" return state.mean(torch.tensor([out_0, out_1]).reshape(1,-1,1))\n",
|
|
"/Users/mhchia/projects/work/pse/zk-stats-lib/zkstats/computation.py:75: TracerWarning: torch.tensor results are registered as constants in the trace. You can safely ignore this warning if you use this function to create tensors out of constant variables that would be the same every time you call this function. In any other case, this might cause the trace to be incorrect.\n",
|
|
" is_precise_aggregated = torch.tensor(1.0)\n",
|
|
"/Users/mhchia/Library/Caches/pypoetry/virtualenvs/zkstats-brXmXluj-py3.12/lib/python3.12/site-packages/torch/onnx/symbolic_opset9.py:2174: FutureWarning: 'torch.onnx.symbolic_opset9._cast_Bool' is deprecated in version 2.0 and will be removed in the future. Please Avoid using this function and create a Cast node instead.\n",
|
|
" return fn(g, to_cast_func(g, input, False), to_cast_func(g, other, False))\n"
|
|
]
|
|
},
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"==== Generate & Calibrate Setting ====\n",
|
|
"scale: [2]\n",
|
|
"setting: {\"run_args\":{\"tolerance\":{\"val\":0.0,\"scale\":1.0},\"input_scale\":2,\"param_scale\":2,\"scale_rebase_multiplier\":10,\"lookup_range\":[-194,338],\"logrows\":12,\"num_inner_cols\":2,\"variables\":[[\"batch_size\",1]],\"input_visibility\":{\"Hashed\":{\"hash_is_public\":true,\"outlets\":[]}},\"output_visibility\":\"Public\",\"param_visibility\":\"Private\"},\"num_rows\":2624,\"total_assignments\":370,\"total_const_size\":74,\"model_instance_shapes\":[[1],[1]],\"model_output_scales\":[0,2],\"model_input_scales\":[2,2],\"module_sizes\":{\"kzg\":[],\"poseidon\":[2624,[2]],\"elgamal\":[0,[0]]},\"required_lookups\":[\"Abs\",{\"GreaterThan\":{\"a\":0.0}},\"KroneckerDelta\"],\"check_mode\":\"UNSAFE\",\"version\":\"7.0.0\",\"num_blinding_factors\":null}\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"from zkstats.computation import State, computation_to_model\n",
|
|
"\n",
|
|
"\n",
|
|
"def computation(state: State, x: list[torch.Tensor]):\n",
|
|
" out_0 = state.median(x[0])\n",
|
|
" out_1 = state.median(x[1])\n",
|
|
" return state.mean(torch.tensor([out_0, out_1]).reshape(1,-1,1))\n",
|
|
"\n",
|
|
"_, prover_model = computation_to_model(computation)\n",
|
|
"prover_gen_settings(data_path, selected_columns, sel_data_path, prover_model, prover_model_path, scales, \"resources\", settings_path)\n"
|
|
]
|
|
},
|
|
{
|
|
"attachments": {},
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Step 3\n",
|
|
"- Prover generates proof with `prover_gen_proof`:\n",
|
|
" - 1. Compile circuit with `compile_circuit`\n",
|
|
" - Inputs: onnx model, settings path\n",
|
|
" - Outputs: compiled \n",
|
|
" - 2. Generate witness with\n",
|
|
"- Verifier generates keys with "
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 8,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"spawning module 0\n",
|
|
"spawning module 2\n"
|
|
]
|
|
},
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"==== setting up ezkl ====\n"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"spawning module 0\n",
|
|
"spawning module 2\n",
|
|
"spawning module 0\n"
|
|
]
|
|
},
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"Time setup: 0.8651909828186035 seconds\n",
|
|
"=======================================\n",
|
|
"==== Generating Witness ====\n",
|
|
"witness boolean: 1.0\n",
|
|
"witness result 1 : 12.75\n",
|
|
"==== Generating Proof ====\n"
|
|
]
|
|
},
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"spawning module 2\n"
|
|
]
|
|
},
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"proof: {'instances': [[[3403910923874899465, 10189271995497415241, 320534846571637606, 100697469688841817], [13248845538017813727, 14468596293127334607, 8656550560197473959, 2161239339877761890], [12436184717236109307, 3962172157175319849, 7381016538464732718, 1011752739694698287], [12362648763242643187, 13940026059969050459, 6027715406760125980, 2781413989188023337]]], 'proof': '1ece89bb01f80c0829026081ae5558d4d6fbb7347311be4b21b8b89e7e42bfb7078a69191dbfc31e1873d596b492a5ae9a599349e8cba18db69ff91a76dc59a41527fb20a6b65bc4ea7687e3a2df3307eb6c3134121c7ff624c92292d86171751d7496d8be004190b11a393f4ad05c3d2de6d1aae53d5210dbc16048f350f9cf2ce86cc113c462e83d2b0608a9b88aa28a6b5de96ef0c151bec1cbf0618405770471913d8efd53d6212bb1ffce224221b343a0a81b1f0eee91905e71a6dbf1210f62d553b5d61772c4c80eb5a19bcaf6b5337248975fffe83598fcf08ae432b3272188c85b274937b54c77f81124b28c9e7024e7deb1d8ee3bfd3bbceef4f00028195ff5ea5711e0871410610bc3f53b0ca2397958aeb119b1169c7d6096422e0aa17a4859ad681733e6bebbbb023c99d53b270e134215f3c4c8523f5330e60919acef5e89b7466cb100ef4f5422a1178691c241923a533c4843d5443e4fdf9b0b9784601fdedc8e30df0c84defec5c7478ad4080467bb5387e87b581f18751100b17c2e9825d5a0bfaa14a49d6da29fbbc3bb322ecd8f1705454401d34060f32c10c6c3b20ed3ede4c86fbe2d084270c165d862e407a2050c6fab3cb6ebd4140b69bd5635263ac0c92baa05f2d6d32e239713d6552a04a7de0775856e28a12917bab7243e9a5fcc466606618d83e21694b910dbd62465549971e5ac987b00021d0143cba8756a8bb0e71a15e37b5cf048ba5318b53fd67176c9a37d9ef09fee056732c36c46114cbaa03d10747f16454b8adb77d97e62df6ebbe32847716b93085b51671d3c1f036ded2a70bdcf8f5bb5035d17d7bbb0b3dbcb1d76ab567aea0ae4e37d1e9b0c79c0c92df767e0ed5bac5dfecf3ae3206cee2a025bf360d0a20fe03847173a7f908c1e0937126820f0a2522bf28bb1b9d603233bb0399efb8d2e83b0f0b8f8da12eb0ff6340bcc50fb635433b3d537b44c2fac508d61a0fbf40849d8bcbf2c21549a612d449c85a3c2996a654f05f9071aa3b01547624475642316e2aba3a2d1d26d33457ab1b3a6bcefe6a4d80305c538142b7c39f4e670c516ded3691d3cd14369e93f5f4ccd2941a39ae529b193e2a89c398d6eb589661014935337b8b7a8dee134f3419424453974742038de6026d64ae163b8e5e56c0518e1c210ed08a17d8c9834d6c933ec350cd052e49569dfeb3e4ff63d01664da72735323e7b62dbb195ac8eb2c16223c4a6a1afb22e8383f4acaa5f1a233d4406161377416d8cbb451075147c682ef3ceb7dd50cb874f4d3cecd973e4434b60d512106651494e9a0f64c81b849c2dba84b44cd19fb74299d861c8ff68c2fbbcd5286cfbbefbb21d994f9f9276220b507b46ed321036fe886e89a68e291048d7fc0d14fd51b216f80e10a16c4366633fa020035bc8f306a6ce252bf4f5f32f5b4c17b613d3c0bcb66b728873b65cf01ad1ca97846f6eb6732ef8247a10959f8e2808e8945a94c94fb9be82c2874d17f72fb120352151823391fdc8140eaadb9a952affcd3b601cf21c9aec0866cc6afdeba5cecd916983784911d087372f1272f01940eb61e014de0b7f8895beb973f7f9db4f76ea8b7ddbe85541cc0788231cd31e1ce9a7463dc08f9e6ab6f5b69ad1d732ca55dfdc15f0caeb8c457ecdcb841b256c286c71ed44aab9a240bbdf42fda8ed7e18d3b5074ce99b6eaaef6a2b972b079ea567b22007be2e01cd1afcfe1606c7cccb0b7824288dd0aced3b5dee359a0b0bac0e6c884b74ececed91c1f10e94a9dd83280db53fe7008d3f311265212204841ab74038fb42e92aa9d5767754f104ad1278efb6528e377d58053eaee8fe006ba7e09807a317d022480542967933be4604ad22c6f337bf3552e70f72692c2f381bdd20855a40a30c5b80a8835861bd035ea6402322c9156549fe04131a3b19b3bbd4cbc9123f290461e22b26361dbc83f7b75b5f8d54a03e985593564c672e454e18e7a10f97416c866de820db8fa45a7ea8fb3e7a1eaa82118e7b78f9c80cf6bd21c6465b22438ae19f3b5299ae7bd1df370035501683fc40b27aa94a3427ca3c3857676e6bdf93bef8d3638d802dea6e85b48b7fda37b4739ff539625c066363dae71b1d36b653e7573d48cff2c0b932a95f5b24d046e614732e279e9d2cee2b6aac3674f2bf6f656216b6cc16e7f6b9e21abab7ae52d0d11616d5a0c51d02aaf6812cb3dc887c93cf475e44350f5d58d93e4f562530346a36fb7bd5f2188e6eb3633e75323bba8e30fce2f9590ce9f49158f856ca42b3f37cfb14f07221940b8e881297f450fc990ad7b3e46556314b0fb64af4266fd42fe9c79baa63064bc004e360744e84bae394842bdacdcd0bfb3c3f9b27ea740267edca608a2f0ccee91252780f697291240892d748a70cd0611d0ba620b8a66677705ff0f1a2225a69f301769c390b119a6a51423e1404858b1c96669a4cfeaf4365817205920dbbf318c8cb857013e4815cbc957e11bbd3d2912fead5ba999ecbb3a6c2aab52d28af56f02a97cd52b61aebf064328e8625b299de1788973f1814b4a89a077901ebc9b47961a2300db7017904ed7b64b66554df7ce0d0854e65a9a0c81732fb26071d3cdb8e50ab38297e8c1fce9f0a330a6a850402ee2eed1d83f9d1f923c00d5ed1a1f7b3fdfe90fd65237a0842de3b272470a49256e9e6d26e17fa13cb4d083d6749cab53ac7f5421cc351832dc7267528b7dfdfd32d80ed401d926b55080c50401ca78c59a4f04c447f657862084b472d15455fe9845303d39d8111b8e21536003f6c0af96af30f39b4c9ef590df8f38882f9428ab6e04446e8f8aeeb8d17d504e0f1e7069ec38a56209fb88008bde75d8cdafe8cb4098718da3b76a93815c95d75e33c33cceb00787cbcb62fa2f826043fe050ce43847bc8c61e21fbd826fe23a5b98181ff580e024039cc71bf3c7365ac57761956a80c8d6d794cdd9e2904425522242181b0143ffb8ee862ae52d8d4dd8d21dcde392c13d98233b713303fe1d509168267c9d48e358e53271cc98c84a3cbfe29b7373bae694348c16f22bf3799a13a882ccbfab2b88e9a35eef3929dbc0b9ec3a1c0804a2b59e165b90b733134c446dba5ea36bcf0b00d52b758c4c8f354e9ea4d52c51dc176f4c8640e523d6d6713b61d79a1467d82c25c473fe9f3361af7936c5beea4278fdf5fca06bb845fd533a72244df47857c301ee4620b725d83f374900aafaa332b7d30fe0d3205363dd57ad3d1eaa74625c07430253f23c588beff666b5bed38e1630cb80c5b5bf281b55b3fd60d8a12e24eaf4caa6f70c1e4361bbd304294f9e5656b50139541e6de46e591b33d8c9ef0007d4fec692e50535e5baafde1f404afa3f3b72bc9d99022be1467164ccf2b262344172850eeadf0f119cbd343b0b9a878850c058be9297e1a21e979f1b2229b4fda3d864a397b5fcefc32c55025d4aec074a12fa643cd3c54e3f217f34c3aa0c2bbc77efb7b618b71c5e80c1533337b6f55942a3e83d2dd302401ea4215547cdfa1458fc1e34eafcddea05e55ca7a0f29fa9d130d5a6efa31477716cd068879c25f7d2f5e92bc11398eb612d97d3a6949eb462b1f11885f60092f146fe2a5e8dffbf576db73cb804df19220efbad56efd535412974be77f803cfbbcb582f2737542c30e5c9b9497f8152e717a284f4fbc6dea1a192c72fc07b29ae888350a182df4849ecf356bd7b9fd39b07a0fa5caf0b6bd1947c4a03e0a8ab0128f7fcf2eec4780636f12144269527f835e55279de732b62559c5a7c1c6c57cb6118b8d221df76744b9a9195db7ab0b8533872ebbd957bb1b606436a9618ebcc2e78df93307634882942c997334f158bc877b3fba6c1e1e23065de9c4c1204765a80507fcfca1933d6194d3915990a93172282cc0bfc0fc0e3166600fbad46c0b840a1dd381270de25f85b0345f70edeace91fd352d253000000000000000000000000000000000000000000000000000000000000000000da56cfb290469c365a3361f31b086a6e6c9138dbbf7e4a21b87c20b75c640d510d1dfe5ac9d43871bed9229c78e2b990b10003f82a6173419c98fd175d0adbf29f7dc301f72a85f050b012b7334f8ccccfb4fd207de3a135bc7dff8d2a81b3c1d3ea64556457c6479e0aac9adbba1ed1f58db4af39bfd4e409648d17b552cec15f86f4a6f2c134e66eed943df463909126546aa963186e4f06c3a4be3a524a72a9805899141c0ea5729b20799b5948128bcb61900572c67489bd8fbbff23cdb000000000000000000000000000000000000000000000000000000000000000008eadeba03d209585c8fb24bcfb740e4e6bf060e0e3ae634fa92f96ed709db1c0db75a0008eddb8a168bb048be304926e2ff6c11ca11dfcec838ff46cecaace918f3aff6df2dd6e12cb369fb75bb3f273afb12366012acc8bd75d14fa6fc2db20e56c885b0bc996c4622f1934960d0767ebad2534d2ab3df5a451f2b7c929b001ed707704a7cc5cd52c5a7993690e667d2ab9debfe868808df6fb96df7d515e11d032981b12115715de970d60a966b6247c414a2f734e4c9eacdd96cc56b5e3e0dd8c4a42e4d049eb1dfdd384ca3addba3c5ca1d686a41b2f16e7b6e5f68e2a0041cf7feeeeb48d2d154820f54c3e785851f3166371a66a968aa3dcf6dd1a48717137415d8e8505a2d710042840b9f4041c8329a580ecd602ce3a09baf80f449171c33467189cd4f9e8c0100f10a3ca71e57174e9a7616c04faf40c88cf4bfb62e33ac2632c39eeee64666d6e38668350bb82a7973b0d28bd67f20ea9533d0690c5949e2147f681cb01e1259f09e89bbec5eb26e70eb76a03de2d13b8768b885189e8bcb8503b3c759ebd86d9335eaf48f3a52e1edf53027cc38c55046d691221ec88286a8909a63a069e5da6742655e3f35ef20029d92015beb39838f32863430202acad94f6f52b29acda8df1232e9f1bb22c0e3b51f4a0ccbe378f35b11702c338f04d632244f8be600481549c40faa6174956e67de96c465178bba3ab39728c53cfe30ae0a17ebc52980bbafb7f4f3cefac4bf66c3ee43d15313bd7c301a093265845c82c0f25f0d29d7a5404c711e0224693241d313b0e3d2cff026c83e016cf4e62c017bfc8dbb0536e7990b56011490f7bc6152aca638c6b8d67013380633c1271cf9c1ba8bbe9354dc036801f2094e01592715a08be7f1941a77a5cd0ef27b481413e6f0e1978257ba87917052b42f048e868cf632a00d9ac9c9b4b917f2b38462be7ae5990ee0f05e2b7e3d7bd87f71669040cbd4112485e000f40c0880845b0ef79c873bccbe094b22f48bcee8e92291fbf06608e64929b2c837180963e14e6519fb7cb664eab40040635be4d060a8ca81364bad5e92d2641e5df728742a052b3126d2447c3198e6e7bccb03fabe7752841ccdb6186b433b1e64670bc28c08138d636b448198ba408148466eef6c752b45350f36dacedc46dad806154740362784b561e66f34daee5ba6c4499701275b9360dbc57454e8d51094e507caec7acfe21713dfcbc46e90603304d0a252824bd835198f54ef9ba04bce872a17a95527ff6145bc9c6c02c9f1fa4613385e6becc634530267fbd3797d03610efa1b176aa234b7eedb079adef9f8d9ae5792eec3744534f2865a0bb6f23b4f0a0090c9f6b9f78313c86a6a2b8ced696c59bad06bfe7a881424e355bdf4405d167a784e39b828e0049e34556e94f5f94d4b81414017dd7fcd64372eaf1aa1370e0c9d732106748aa845ab28b773e1f4e6a557004218086f7b41fd65c5599fc5072d013e5f34f25c0866dd5194ba5cba9622f413716e7a9b7054d366f2662b5f19cbb1ee142b8499c44db9e0cde6d31c28851d34a75246b735c36db7b9c483390944fb4c848eeaf1860e162fb66810d58acfbc81a3c65c34c64aeb59b57e622c26f746786ad077b29fa13c2fb521162b2374f2078709cc8808f6e1fe3d72080026df16d2cf414571dff77b5000386703c911de1c64cdba3b3d9de7f565ff760708451d0f4e53f76fd5b218bbb97d25589288591d9d51d2930ee88754b83ce8ae0afdfcb60b4ae98dd83e42f37626e75df17ef3701a2c7a7bbcb756d499c99af50410f27040fe030bab897feb6cc7bbf2594f63f08771197ed3ac2e65b1f1aa0418002090625ca12b163bb8bc0a1ab1213c4b8d4b7a9d13b01a3277b93f8d24db1b498506b99c926684858641a521dbbcd08b45f840d8de4ea3c82376739edd7f102344846006fe1601907294e7cde5852524769571894a0d914d9e2aec4494d5', 'transcript_type': 'EVM'}\n",
|
|
"Time gen prf: 1.2174098491668701 seconds\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"# Here verifier & prover can concurrently call setup since all params are public to get pk.\n",
|
|
"# Here write as verifier function to emphasize that verifier must calculate its own vk to be sure\n",
|
|
"setup(prover_model_path, prover_compiled_model_path, settings_path, vk_path, pk_path )\n",
|
|
"\n",
|
|
"print(\"=======================================\")\n",
|
|
"# Prover generates proof\n",
|
|
"# print(\"Theory output: \", theory_output)\n",
|
|
"prover_gen_proof(prover_model_path, sel_data_path, witness_path, prover_compiled_model_path, settings_path, proof_path, pk_path)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 9,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"12.75"
|
|
]
|
|
},
|
|
"execution_count": 9,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"# Verifier verifies\n",
|
|
"verifier_verify(proof_path, settings_path, vk_path, selected_columns, commitment_maps)"
|
|
]
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": "Python 3",
|
|
"language": "python",
|
|
"name": "python3"
|
|
},
|
|
"language_info": {
|
|
"codemirror_mode": {
|
|
"name": "ipython",
|
|
"version": 3
|
|
},
|
|
"file_extension": ".py",
|
|
"mimetype": "text/x-python",
|
|
"name": "python",
|
|
"nbconvert_exporter": "python",
|
|
"pygments_lexer": "ipython3",
|
|
"version": "3.12.1"
|
|
},
|
|
"orig_nbformat": 4
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 2
|
|
}
|