Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix get_data_commitment #13

Merged
merged 9 commits into from
Feb 29, 2024
Merged
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
22 changes: 0 additions & 22 deletions bench.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,28 +164,6 @@ def verifier_setup(verifier_model_path, verifier_compiled_model_path, settings_p
# ===================================================================================================
# ===================================================================================================

def prover_setup(
data_path,
col_array,
sel_data_path,
prover_model,
prover_model_path,
prover_compiled_model_path,
scale,
mode,
settings_path,
vk_path,
pk_path,
):
data_tensor_array = process_data(data_path, col_array, sel_data_path)

# export onnx file
export_onnx(prover_model, data_tensor_array, prover_model_path)
# gen + calibrate setting
gen_settings(sel_data_path, prover_model_path, scale, mode, settings_path)
verifier_setup(prover_model_path, prover_compiled_model_path, settings_path, vk_path, pk_path)


def prover_gen_proof(
prover_model_path,
sel_data_path,
Expand Down
156 changes: 80 additions & 76 deletions examples/computation/computation.ipynb

Large diffs are not rendered by default.

33 changes: 5 additions & 28 deletions examples/computation/data.json
Original file line number Diff line number Diff line change
@@ -1,31 +1,8 @@
{
"input_data": [
[
23.2, 92.8, 91.0, 37.2, 82.0, 15.5, 79.3, 46.6, 98.1, 75.5, 78.9, 77.6,
33.8, 75.7, 96.8, 12.3, 18.4, 13.4, 6.0, 8.2, 25.8, 41.3, 68.5, 15.2,
74.7, 72.7, 18.0, 42.2, 36.1, 76.7, 1.2, 96.4, 4.9, 92.0, 12.8, 28.2,
61.8, 56.9, 44.3, 50.4, 81.6, 72.5, 12.9, 40.3, 12.8, 28.8, 36.3, 16.1,
68.4, 35.3, 79.2, 48.4, 97.1, 93.7, 77.0, 48.7, 93.7, 54.1, 65.4, 30.8,
34.4, 31.4, 78.7, 12.7, 90.7, 39.4, 86.0, 55.9, 6.8, 22.2, 65.3, 18.8,
7.1, 55.9, 38.6, 15.6, 59.2, 77.3, 76.9, 11.9, 19.9, 19.4, 54.3, 39.4,
4.0, 61.1, 16.8, 81.9, 49.3, 76.9, 19.2, 68.2, 54.4, 70.2, 89.8, 23.4,
67.5, 18.7, 10.8, 80.7, 80.3, 96.2, 62.3, 17.2, 23.0, 98.0, 19.1, 8.1,
36.2, 7.5, 55.9, 1.2, 56.8, 85.1, 18.9, 23.0, 13.5, 64.3, 9.1, 14.1, 14.1,
23.1, 73.2, 86.6, 39.1, 45.5, 85.0, 79.0, 15.8, 5.2, 81.5, 34.3, 24.3,
14.2, 84.6, 33.7, 86.3, 83.3, 62.8, 72.7, 14.7, 36.8, 92.5, 4.7, 30.0,
59.4, 57.6, 37.4, 22.0, 20.9, 61.6, 26.8, 47.1, 63.6, 6.0, 96.6, 61.2,
80.2, 59.3, 23.1, 29.3, 46.3, 89.2, 77.6, 83.2, 87.2, 63.2, 81.8, 55.0,
59.7, 57.8, 43.4, 92.4, 66.9, 82.1, 51.0, 22.1, 29.9, 41.0, 85.2, 61.5,
14.6, 48.0, 52.7, 31.4, 83.9, 35.5, 77.3, 35.8, 32.6, 22.2, 19.3, 49.1,
70.9, 43.9, 88.8, 56.3, 41.8, 90.3, 20.4, 80.4, 36.4, 91.5, 69.6, 75.3,
92.4, 84.8, 17.7, 2.3, 41.3, 91.3, 68.6, 73.3, 62.5, 60.5, 73.5, 70.7,
77.5, 76.8, 98.1, 40.9, 66.3, 8.6, 48.9, 75.4, 14.7, 35.9, 89.6, 15.1,
45.0, 77.6, 30.5, 76.1, 46.9, 34.3, 65.1, 43.9, 91.6, 88.8, 8.9, 42.9,
11.8, 32.1, 20.1, 48.9, 79.7, 15.3, 45.4, 80.1, 73.1, 76.5, 52.4, 9.6,
41.9, 52.7, 55.1, 30.9, 83.7, 46.7, 39.3, 40.5, 52.4, 19.2, 25.8, 52.7,
81.0, 38.0, 54.5, 15.3, 64.3, 88.3, 49.8, 90.5, 90.4, 79.7, 87.3, 32.3,
11.9, 5.7, 33.6, 75.1, 65.9, 29.1, 39.4, 87.5, 3.3, 66.3, 79.0, 97.9,
69.6, 22.0, 62.8, 97.1, 90.4, 39.5, 11.7, 30.3, 18.9, 34.6, 6.6
]
"x": [
0, 1, 2, 3, 4
],
"y": [
2.0, 5.2, 47.4, 23.6, 24.8
]
}
197 changes: 98 additions & 99 deletions examples/correlation/correlation.ipynb

Large diffs are not rendered by default.

9 changes: 2 additions & 7 deletions examples/correlation/data.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
{
"x": [
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
40, 41, 42, 43, 44, 45, 46, 47, 48, 49
0, 1, 2, 3, 4, 5
],
"y": [
2.0, 5.2, 47.4, 23.6, 24.8, 27.0, 47.2, 50.4, 58.6, 57.8, 60.0, 27.2, 40.4,
63.6, 28.8, 19.0, 65.2, 50.4, 63.6, 24.8, 35.0, 41.2, 54.4, 61.6, 57.8,
78.0, 63.2, 55.4, 78.6, 72.8, 51.0, 62.2, 42.4, 47.6, 83.8, 62.0, 47.26,
90.4, 80.6, 87.8, 82.0, 50.2, 80.4, 86.6, 80.8, 66.0, 95.2, 58.4, 74.6, 95.8
2.0, 5.2, 47.4, 23.6, 24.8, 27.0
]
}
141 changes: 71 additions & 70 deletions examples/covariance/covariance.ipynb

Large diffs are not rendered by default.

143 changes: 76 additions & 67 deletions examples/geomean/geomean.ipynb

Large diffs are not rendered by default.

128 changes: 72 additions & 56 deletions examples/geomean/geomean_OG.ipynb

Large diffs are not rendered by default.

119 changes: 64 additions & 55 deletions examples/harmomean/harmomean.ipynb

Large diffs are not rendered by default.

180 changes: 91 additions & 89 deletions examples/mean+median/mean+median.ipynb

Large diffs are not rendered by default.

134 changes: 75 additions & 59 deletions examples/mean/mean.ipynb

Large diffs are not rendered by default.

23 changes: 17 additions & 6 deletions examples/mean/mean_OG.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,17 @@
"theory_output = torch.mean(data_tensor)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"scales = [15]\n",
"selected_columns = ['col_name']\n",
"commitment_maps = get_data_commitment_maps(data_path, scales)"
]
},
{
"cell_type": "code",
"execution_count": 7,
Expand All @@ -161,8 +172,8 @@
" def forward(self,X):\n",
" return (torch.tensor(1), torch.mean(X))\n",
" # return (torch.abs(torch.sum(X)-X.size()[1]*(self.w))<=torch.abs(0.01*X.size()[1]*self.w), self.w)\n",
" \n",
"verifier_define_calculation(dummy_data_path, ['col_name'],sel_dummy_data_path,verifier_model, verifier_model_path)"
"\n",
"verifier_define_calculation(dummy_data_path, selected_columns,sel_dummy_data_path,verifier_model, verifier_model_path)"
]
},
{
Expand Down Expand Up @@ -201,7 +212,7 @@
" def forward(self,X):\n",
" return (torch.tensor(1),torch.mean(X))\n",
" # return (torch.abs(torch.sum(X)-X.size()[1]*(self.w))<=torch.abs(0.01*X.size()[1]*self.w), self.w)\n",
"prover_gen_settings(data_path,['col_name'], sel_data_path, prover_model,prover_model_path, [15], \"resources\", settings_path)"
"prover_gen_settings(data_path, selected_columns, sel_data_path, prover_model,prover_model_path, scales, \"resources\", settings_path)"
]
},
{
Expand Down Expand Up @@ -253,7 +264,7 @@
}
],
"source": [
"# Here verifier & prover can concurrently call setup since all params are public to get pk. \n",
"# 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",
"verifier_setup(verifier_model_path, verifier_compiled_model_path, settings_path,vk_path, pk_path )\n",
"\n",
Expand Down Expand Up @@ -282,7 +293,7 @@
],
"source": [
"# Verifier verifies\n",
"verifier_verify(proof_path, settings_path, vk_path)"
"verifier_verify(proof_path, settings_path, vk_path, selected_columns, commitment_maps)"
]
},
{
Expand All @@ -309,7 +320,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.0"
"version": "3.11.4"
},
"orig_nbformat": 4
},
Expand Down
Loading
Loading