Skip to content
Draft
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
250 changes: 138 additions & 112 deletions services/nillion-interactor/large_dataset-test.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@
"metadata": {
"collapsed": true,
"ExecuteTime": {
"end_time": "2024-08-22T13:57:21.425536Z",
"start_time": "2024-08-22T13:57:21.319781Z"
"end_time": "2024-09-13T19:17:01.391890Z",
"start_time": "2024-09-13T19:17:01.066083Z"
}
},
"source": [
Expand Down Expand Up @@ -163,8 +163,8 @@
{
"metadata": {
"ExecuteTime": {
"end_time": "2024-08-22T14:24:49.198120Z",
"start_time": "2024-08-22T14:24:47.342660Z"
"end_time": "2024-09-13T19:17:07.083724Z",
"start_time": "2024-09-13T19:17:06.241704Z"
}
},
"cell_type": "code",
Expand All @@ -184,18 +184,18 @@
" [ 12184325, 1, 754105, 4]])"
]
},
"execution_count": 13,
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"execution_count": 13
"execution_count": 3
},
{
"metadata": {
"ExecuteTime": {
"end_time": "2024-08-22T14:34:09.411111Z",
"start_time": "2024-08-22T14:34:09.406476Z"
"end_time": "2024-09-13T19:17:13.489386Z",
"start_time": "2024-09-13T19:17:13.483613Z"
}
},
"cell_type": "code",
Expand All @@ -208,12 +208,92 @@
"(631955, 4)"
]
},
"execution_count": 15,
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"execution_count": 15
"execution_count": 4
},
{
"metadata": {
"ExecuteTime": {
"end_time": "2024-09-13T19:17:16.699898Z",
"start_time": "2024-09-13T19:17:16.688849Z"
}
},
"cell_type": "code",
"source": "gene_data[gene_data[:, 0] == 1815739]",
"id": "a019086389c4aff",
"outputs": [
{
"data": {
"text/plain": [
"array([[ 1815739, 11, 66328095, 6]])"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"execution_count": 5
},
{
"metadata": {
"ExecuteTime": {
"end_time": "2024-09-13T19:21:14.529977Z",
"start_time": "2024-09-13T19:21:14.464082Z"
}
},
"cell_type": "code",
"source": [
"target_snp_1 = 1815739\n",
"target_genotype_1 = 6\n",
"\n",
"boolean_mask = gene_data[:, 0] == target_snp_1\n",
"actual_genotype_1 = np.dot(boolean_mask, gene_data[:, 3])\n",
"actual_genotype_1"
],
"id": "4c536a0beca2655c",
"outputs": [
{
"data": {
"text/plain": [
"6"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"execution_count": 10
},
{
"metadata": {
"ExecuteTime": {
"end_time": "2024-09-13T19:21:17.846807Z",
"start_time": "2024-09-13T19:21:17.842518Z"
}
},
"cell_type": "code",
"source": [
"\n",
"is_successful = actual_genotype_1 == target_genotype_1\n",
"print(is_successful)"
],
"id": "273585be787988f6",
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"True\n"
]
}
],
"execution_count": 11
},
{
"metadata": {},
Expand All @@ -229,6 +309,33 @@
}
},
"cell_type": "code",
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Loading environment variables from /Users/vishakh/.config/nillion/nillion-devnet.env\n",
"NILLION_CLUSTER_ID: 9e68173f-9c23-4acc-ba81-4f079b639964\n",
"NILLION_BOOTNODE_MULTIADDRESS: /ip4/127.0.0.1/tcp/37939/p2p/12D3KooWMvw1hEqm7EWSDEyqTb6pNetUVkepahKY6hixuAuMZfJS\n",
"NILLION_BOOTNODE_WEBSOCKET: /ip4/127.0.0.1/tcp/54936/ws/p2p/12D3KooWMvw1hEqm7EWSDEyqTb6pNetUVkepahKY6hixuAuMZfJS\n",
"NILLION_NILCHAIN_CHAIN_ID: nillion-chain-devnet\n",
"NILLION_NILCHAIN_JSON_RPC: http://127.0.0.1:48102\n",
"NILLION_NILCHAIN_REST_API: http://localhost:26650\n",
"NILLION_NILCHAIN_GRPC: localhost:26649\n",
"NILLION_NILCHAIN_PRIVATE_KEY_0: 9a975f567428d054f2bf3092812e6c42f901ce07d9711bc77ee2cd81101f42c5\n",
"NILLION_NILCHAIN_PRIVATE_KEY_1: 1e491133b9408b39572a29f91644873decea554224b20e2b0b923aeb860a1c18\n",
"NILLION_NILCHAIN_PRIVATE_KEY_2: 980488572f235316cdb330191f8bafe4e635efbe88b3a40f5bee9bd21047c059\n",
"NILLION_NILCHAIN_PRIVATE_KEY_3: 612bb5173dc60d9e91404fcc0d1f1847fb4459a7d5160d63d84e91aacbf2ab2f\n",
"NILLION_NILCHAIN_PRIVATE_KEY_4: 04f5a984eeea9dce4e5e907da69c01a61568e3071b1a91cbed89225f9fd913b5\n",
"NILLION_NILCHAIN_PRIVATE_KEY_5: 5f992c58921f4af83b4c6b650c4914626664cd02020577b0ada49cfa00d2c8a4\n",
"NILLION_NILCHAIN_PRIVATE_KEY_6: 8f0297d3bb647eb59b95b29550b2aebbedd9be2c954b000e772efe8c9318a42d\n",
"NILLION_NILCHAIN_PRIVATE_KEY_7: c395243df9bb68dc809668efe4125f0eb017771ed8e3747b8d6860551913fecb\n",
"NILLION_NILCHAIN_PRIVATE_KEY_8: 4bb5eaa799e24ae2b48545c41331921afe7e6a8dd7a850f5fbeb20a8226664ec\n",
"NILLION_NILCHAIN_PRIVATE_KEY_9: ef4b944d4fdb0077057925fe2dde365dfa2c83cf320463b14589feccd1b2b938\n"
]
}
],
"execution_count": 47,
"source": [
"import os\n",
"import py_nillion_client as nillion\n",
Expand Down Expand Up @@ -267,34 +374,7 @@
" prefix=\"nillion\",\n",
")"
],
"id": "84da614cf4520b6c",
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Loading environment variables from /Users/vishakh/.config/nillion/nillion-devnet.env\n",
"NILLION_CLUSTER_ID: 9e68173f-9c23-4acc-ba81-4f079b639964\n",
"NILLION_BOOTNODE_MULTIADDRESS: /ip4/127.0.0.1/tcp/37939/p2p/12D3KooWMvw1hEqm7EWSDEyqTb6pNetUVkepahKY6hixuAuMZfJS\n",
"NILLION_BOOTNODE_WEBSOCKET: /ip4/127.0.0.1/tcp/54936/ws/p2p/12D3KooWMvw1hEqm7EWSDEyqTb6pNetUVkepahKY6hixuAuMZfJS\n",
"NILLION_NILCHAIN_CHAIN_ID: nillion-chain-devnet\n",
"NILLION_NILCHAIN_JSON_RPC: http://127.0.0.1:48102\n",
"NILLION_NILCHAIN_REST_API: http://localhost:26650\n",
"NILLION_NILCHAIN_GRPC: localhost:26649\n",
"NILLION_NILCHAIN_PRIVATE_KEY_0: 9a975f567428d054f2bf3092812e6c42f901ce07d9711bc77ee2cd81101f42c5\n",
"NILLION_NILCHAIN_PRIVATE_KEY_1: 1e491133b9408b39572a29f91644873decea554224b20e2b0b923aeb860a1c18\n",
"NILLION_NILCHAIN_PRIVATE_KEY_2: 980488572f235316cdb330191f8bafe4e635efbe88b3a40f5bee9bd21047c059\n",
"NILLION_NILCHAIN_PRIVATE_KEY_3: 612bb5173dc60d9e91404fcc0d1f1847fb4459a7d5160d63d84e91aacbf2ab2f\n",
"NILLION_NILCHAIN_PRIVATE_KEY_4: 04f5a984eeea9dce4e5e907da69c01a61568e3071b1a91cbed89225f9fd913b5\n",
"NILLION_NILCHAIN_PRIVATE_KEY_5: 5f992c58921f4af83b4c6b650c4914626664cd02020577b0ada49cfa00d2c8a4\n",
"NILLION_NILCHAIN_PRIVATE_KEY_6: 8f0297d3bb647eb59b95b29550b2aebbedd9be2c954b000e772efe8c9318a42d\n",
"NILLION_NILCHAIN_PRIVATE_KEY_7: c395243df9bb68dc809668efe4125f0eb017771ed8e3747b8d6860551913fecb\n",
"NILLION_NILCHAIN_PRIVATE_KEY_8: 4bb5eaa799e24ae2b48545c41331921afe7e6a8dd7a850f5fbeb20a8226664ec\n",
"NILLION_NILCHAIN_PRIVATE_KEY_9: ef4b944d4fdb0077057925fe2dde365dfa2c83cf320463b14589feccd1b2b938\n"
]
}
],
"execution_count": 47
"id": "84da614cf4520b6c"
},
{
"metadata": {},
Expand All @@ -310,6 +390,8 @@
}
},
"cell_type": "code",
"outputs": [],
"execution_count": 48,
"source": [
"from typing import Any\n",
"import nada_numpy.client as na_client\n",
Expand Down Expand Up @@ -346,9 +428,7 @@
" )\n",
" return store_id"
],
"id": "2740bbe472dbdffb",
"outputs": [],
"execution_count": 48
"id": "2740bbe472dbdffb"
},
{
"metadata": {},
Expand All @@ -364,22 +444,6 @@
}
},
"cell_type": "code",
"source": [
"permissions = nillion.Permissions.default_for_user(monadic_user_id)\n",
"\n",
"store_id = await store_secret_array(\n",
" monadic_client,\n",
" payments_wallet,\n",
" payments_client,\n",
" cluster_id,\n",
" gene_data,\n",
" \"gene_data\",\n",
" nillion.SecretInteger,\n",
" 1,\n",
" permissions,\n",
")"
],
"id": "ad961c332478c206",
"outputs": [
{
"name": "stdout",
Expand All @@ -402,7 +466,23 @@
]
}
],
"execution_count": 49
"execution_count": 49,
"source": [
"permissions = nillion.Permissions.default_for_user(monadic_user_id)\n",
"\n",
"store_id = await store_secret_array(\n",
" monadic_client,\n",
" payments_wallet,\n",
" payments_client,\n",
" cluster_id,\n",
" gene_data,\n",
" \"gene_data\",\n",
" nillion.SecretInteger,\n",
" 1,\n",
" permissions,\n",
")"
],
"id": "ad961c332478c206"
},
{
"metadata": {},
Expand All @@ -419,60 +499,6 @@
],
"id": "755c0d8d6ef4ceb6"
},
{
"metadata": {
"ExecuteTime": {
"end_time": "2024-08-22T14:41:58.625914Z",
"start_time": "2024-08-22T14:41:58.616792Z"
}
},
"cell_type": "code",
"source": "gene_data[gene_data[:, 0] == 1815739]",
"id": "a019086389c4aff",
"outputs": [
{
"data": {
"text/plain": [
"array([[ 1815739, 11, 66328095, 6]])"
]
},
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
],
"execution_count": 16
},
{
"metadata": {
"ExecuteTime": {
"end_time": "2024-08-22T14:44:11.011121Z",
"start_time": "2024-08-22T14:44:11.003410Z"
}
},
"cell_type": "code",
"source": [
"target_snp_1 = 1815739\n",
"target_genotype_1 = 9\n",
"\n",
"rows_of_interest = gene_data[gene_data[:, 0] == target_snp_1]\n",
"is_successful = rows_of_interest[0, 3] == target_genotype_1\n",
"print(rows_of_interest)\n",
"print(is_successful)"
],
"id": "273585be787988f6",
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[[ 1815739 11 66328095 6]]\n",
"False\n"
]
}
],
"execution_count": 21
},
{
"metadata": {},
"cell_type": "markdown",
Expand Down
9 changes: 4 additions & 5 deletions services/nillion-interactor/programs/muscle-perform-array.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ def nada_main():
party1 = Party(name="Party1")

gene_data = na.array((1, 4), party1, "gene_data", SecretInteger)
rows_of_interest = gene_data[gene_data[:, 0] == target_snp_1]
is_successful = rows_of_interest[0, 3] == target_genotype_1
boolean_mask = gene_data[:, 0] == target_snp_1
actual_genotype_1 = boolean_mask.dot(gene_data[:, 3])
is_successful = actual_genotype_1 == target_genotype_1

result = is_successful.reveal()

return [Output(result, "Result", party1)]
return [Output(is_successful, "Result", party1)]
1 change: 1 addition & 0 deletions services/nillion-interactor/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
python-dotenv==1.0.0
nada-dsl==0.6.0
nada-numpy==0.5.2
py-nillion-client==0.6.0
pytest-asyncio>=0.23.6
Flask[async]==3.0.3
Expand Down