diff --git a/services/nillion-interactor/.env b/services/nillion-interactor/.env index 7c1287a..4da14b6 100644 --- a/services/nillion-interactor/.env +++ b/services/nillion-interactor/.env @@ -1,17 +1,25 @@ -NILLION_BOOTNODE_MULTIADDRESS=/ip4/127.0.0.1/tcp/37939/p2p/12D3KooWMvw1hEqm7EWSDEyqTb6pNetUVkepahKY6hixuAuMZfJS -NILLION_CLUSTER_ID=9e68173f-9c23-4acc-ba81-4f079b639964 -NILLION_USERKEY_PATH_PARTY_1=/Users/vishakh/dev/MonadicDNA/services/nillion-interactor/user.key -NILLION_USERKEY_PATH_PARTY_2= -NILLION_USERKEY_PATH_PARTY_3= -NILLION_USERKEY_PATH_PARTY_4= -NILLION_USERKEY_PATH_PARTY_5= -NILLION_NODEKEY_PATH_PARTY_1=/Users/vishakh/dev/MonadicDNA/services/nillion-interactor/node.key -NILLION_NODEKEY_PATH_PARTY_2= -NILLION_NODEKEY_PATH_PARTY_3= -NILLION_NODEKEY_PATH_PARTY_4= -NILLION_NODEKEY_PATH_PARTY_5= -NILLION_BLOCKCHAIN_RPC_ENDPOINT=http://localhost:61391 -NILLION_CHAIN_ID=31337 -NILLION_PAYMENTS_SC_ADDRESS=5fc8d32690cc91d4c39d9d3abcbd16989f875707 -NILLION_BLINDING_FACTORS_MANAGER_SC_ADDRESS=a513e6e4b8f2a923d98304ec87f64353c4d5c853 -NILLION_WALLET_PRIVATE_KEY=df57089febbacf7ba0bc227dafbffa9fc08a93fdc68e1e42411a14efcf23656e \ No newline at end of file +# NILLION_BOOTNODE_MULTIADDRESS=/ip4/127.0.0.1/tcp/37939/p2p/12D3KooWMvw1hEqm7EWSDEyqTb6pNetUVkepahKY6hixuAuMZfJS +# NILLION_CLUSTER_ID=9e68173f-9c23-4acc-ba81-4f079b639964 +# NILLION_USERKEY_PATH_PARTY_1=/Users/vishakh/dev/MonadicDNA/services/nillion-interactor/user.key +# NILLION_USERKEY_PATH_PARTY_2= +# NILLION_USERKEY_PATH_PARTY_3= +# NILLION_USERKEY_PATH_PARTY_4= +# NILLION_USERKEY_PATH_PARTY_5= +# NILLION_NODEKEY_PATH_PARTY_1=/Users/vishakh/dev/MonadicDNA/services/nillion-interactor/node.key +# NILLION_NODEKEY_PATH_PARTY_2= +# NILLION_NODEKEY_PATH_PARTY_3= +# NILLION_NODEKEY_PATH_PARTY_4= +# NILLION_NODEKEY_PATH_PARTY_5= +# NILLION_BLOCKCHAIN_RPC_ENDPOINT=http://localhost:61391 +# NILLION_CHAIN_ID=31337 +# NILLION_PAYMENTS_SC_ADDRESS=5fc8d32690cc91d4c39d9d3abcbd16989f875707 +# NILLION_BLINDING_FACTORS_MANAGER_SC_ADDRESS=a513e6e4b8f2a923d98304ec87f64353c4d5c853 +# NILLION_WALLET_PRIVATE_KEY=df57089febbacf7ba0bc227dafbffa9fc08a93fdc68e1e42411a14efcf23656e + +# Nucleus 2 testet setup +MONADIC_PRIVKEY=11112217e1ba614ee927fdc38a31b686c7b56976aa92451e89f769b518416112 +SNIPPER_BOT_PRIVKEY=c653318e9a92e3d8a5fd536f6c3324047b85d294c48b2fdaa8e861b8bd53a3d1 +NILLION_BLOCKCHAIN_RPC_ENDPOINT=https://testnet-nillion-grpc.lavenderfive.com +NILLION_BOOTNODE_MULTIADDRESS=https://node-1.nucleus2.nillion-network.nilogy.xyz:14311 +NILLION_CHAIN_ID=nillion-chain-testnet-1 +THROMBOSIS_PROGRAM_ID=8557268d73e95608764ed372665ce53ec16c5c2b/thrombosis/sha256/1b40f8cf92763b3a19c55a272203e367d2204ad0d2f78c8f1d046afc3147b6b5 \ No newline at end of file diff --git a/services/nillion-interactor/E2E_Nillion_Test.ipynb b/services/nillion-interactor/E2E_Nillion_Test.ipynb index 9e147ef..c25937b 100644 --- a/services/nillion-interactor/E2E_Nillion_Test.ipynb +++ b/services/nillion-interactor/E2E_Nillion_Test.ipynb @@ -40,65 +40,66 @@ "name": "stdout", "output_type": "stream", "text": [ - "Requirement already satisfied: nada-dsl==0.6.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (0.6.0)\n", - "Requirement already satisfied: asttokens~=2.4 in /Users/aisha/Library/Python/3.12/lib/python/site-packages (from nada-dsl==0.6.0) (2.4.1)\n", - "Requirement already satisfied: richreports~=0.2 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from nada-dsl==0.6.0) (0.2.0)\n", - "Requirement already satisfied: parsial~=0.1 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from nada-dsl==0.6.0) (0.1.0)\n", - "Requirement already satisfied: sortedcontainers~=2.4 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from nada-dsl==0.6.0) (2.4.0)\n", - "Requirement already satisfied: six>=1.12.0 in /Users/aisha/Library/Python/3.12/lib/python/site-packages (from asttokens~=2.4->nada-dsl==0.6.0) (1.16.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;49m24.0\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m24.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;49mpip3 install --upgrade pip\u001b[0m\n", + "Requirement already satisfied: nada-dsl==0.7.2 in /home/hello/Projects/MonadicDNA/.venv/lib/python3.12/site-packages (0.7.2)\n", + "Requirement already satisfied: asttokens~=2.4 in /home/hello/Projects/MonadicDNA/.venv/lib/python3.12/site-packages (from nada-dsl==0.7.2) (2.4.1)\n", + "Requirement already satisfied: richreports~=0.2 in /home/hello/Projects/MonadicDNA/.venv/lib/python3.12/site-packages (from nada-dsl==0.7.2) (0.2.0)\n", + "Requirement already satisfied: parsial~=0.1 in /home/hello/Projects/MonadicDNA/.venv/lib/python3.12/site-packages (from nada-dsl==0.7.2) (0.1.0)\n", + "Requirement already satisfied: sortedcontainers~=2.4 in /home/hello/Projects/MonadicDNA/.venv/lib/python3.12/site-packages (from nada-dsl==0.7.2) (2.4.0)\n", + "Requirement already satisfied: typing_extensions~=4.12.2 in /home/hello/Projects/MonadicDNA/.venv/lib/python3.12/site-packages (from nada-dsl==0.7.2) (4.12.2)\n", + "Requirement already satisfied: six>=1.12.0 in /home/hello/Projects/MonadicDNA/.venv/lib/python3.12/site-packages (from asttokens~=2.4->nada-dsl==0.7.2) (1.17.0)\n", "Note: you may need to restart the kernel to use updated packages.\n", - "Requirement already satisfied: py-nillion-client==0.6.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (0.6.0)\n", - "Requirement already satisfied: protobuf<5.0.dev0,>=4.21.6 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from py-nillion-client==0.6.0) (4.25.4)\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;49m24.0\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m24.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;49mpip3 install --upgrade pip\u001b[0m\n", + "Requirement already satisfied: python-dotenv==1.0.0 in /home/hello/Projects/MonadicDNA/.venv/lib/python3.12/site-packages (1.0.0)\n", "Note: you may need to restart the kernel to use updated packages.\n", - "Requirement already satisfied: nillion-python-helpers==0.2.3 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (0.2.3)\n", - "Requirement already satisfied: cosmpy<0.10.0,>=0.9.2 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from nillion-python-helpers==0.2.3) (0.9.2)\n", - "Requirement already satisfied: pytest-asyncio<0.24.0,>=0.23.7 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from nillion-python-helpers==0.2.3) (0.23.8)\n", - "Requirement already satisfied: python-dotenv==1.0.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from nillion-python-helpers==0.2.3) (1.0.0)\n", - "Requirement already satisfied: bech32 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from cosmpy<0.10.0,>=0.9.2->nillion-python-helpers==0.2.3) (1.2.0)\n", - "Requirement already satisfied: ecdsa in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from cosmpy<0.10.0,>=0.9.2->nillion-python-helpers==0.2.3) (0.19.0)\n", - "Requirement already satisfied: googleapis-common-protos in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from cosmpy<0.10.0,>=0.9.2->nillion-python-helpers==0.2.3) (1.65.0)\n", - "Requirement already satisfied: grpcio in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from cosmpy<0.10.0,>=0.9.2->nillion-python-helpers==0.2.3) (1.66.1)\n", - "Requirement already satisfied: jsonschema<5,>=3.2.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from cosmpy<0.10.0,>=0.9.2->nillion-python-helpers==0.2.3) (4.23.0)\n", - "Requirement already satisfied: protobuf<5.0dev,>=4.21.6 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from cosmpy<0.10.0,>=0.9.2->nillion-python-helpers==0.2.3) (4.25.4)\n", - "Requirement already satisfied: pycryptodome<4.0.0,>=3.18.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from cosmpy<0.10.0,>=0.9.2->nillion-python-helpers==0.2.3) (3.20.0)\n", - "Requirement already satisfied: python-dateutil in /Users/aisha/Library/Python/3.12/lib/python/site-packages (from cosmpy<0.10.0,>=0.9.2->nillion-python-helpers==0.2.3) (2.9.0.post0)\n", - "Requirement already satisfied: requests in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from cosmpy<0.10.0,>=0.9.2->nillion-python-helpers==0.2.3) (2.32.3)\n", - "Requirement already satisfied: pytest<9,>=7.0.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from pytest-asyncio<0.24.0,>=0.23.7->nillion-python-helpers==0.2.3) (8.3.2)\n", - "Requirement already satisfied: attrs>=22.2.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from jsonschema<5,>=3.2.0->cosmpy<0.10.0,>=0.9.2->nillion-python-helpers==0.2.3) (24.2.0)\n", - "Requirement already satisfied: jsonschema-specifications>=2023.03.6 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from jsonschema<5,>=3.2.0->cosmpy<0.10.0,>=0.9.2->nillion-python-helpers==0.2.3) (2023.12.1)\n", - "Requirement already satisfied: referencing>=0.28.4 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from jsonschema<5,>=3.2.0->cosmpy<0.10.0,>=0.9.2->nillion-python-helpers==0.2.3) (0.35.1)\n", - "Requirement already satisfied: rpds-py>=0.7.1 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from jsonschema<5,>=3.2.0->cosmpy<0.10.0,>=0.9.2->nillion-python-helpers==0.2.3) (0.20.0)\n", - "Requirement already satisfied: iniconfig in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from pytest<9,>=7.0.0->pytest-asyncio<0.24.0,>=0.23.7->nillion-python-helpers==0.2.3) (2.0.0)\n", - "Requirement already satisfied: packaging in /Users/aisha/Library/Python/3.12/lib/python/site-packages (from pytest<9,>=7.0.0->pytest-asyncio<0.24.0,>=0.23.7->nillion-python-helpers==0.2.3) (24.1)\n", - "Requirement already satisfied: pluggy<2,>=1.5 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from pytest<9,>=7.0.0->pytest-asyncio<0.24.0,>=0.23.7->nillion-python-helpers==0.2.3) (1.5.0)\n", - "Requirement already satisfied: six>=1.9.0 in /Users/aisha/Library/Python/3.12/lib/python/site-packages (from ecdsa->cosmpy<0.10.0,>=0.9.2->nillion-python-helpers==0.2.3) (1.16.0)\n", - "Requirement already satisfied: charset-normalizer<4,>=2 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from requests->cosmpy<0.10.0,>=0.9.2->nillion-python-helpers==0.2.3) (3.3.2)\n", - "Requirement already satisfied: idna<4,>=2.5 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from requests->cosmpy<0.10.0,>=0.9.2->nillion-python-helpers==0.2.3) (3.8)\n", - "Requirement already satisfied: urllib3<3,>=1.21.1 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from requests->cosmpy<0.10.0,>=0.9.2->nillion-python-helpers==0.2.3) (2.2.2)\n", - "Requirement already satisfied: certifi>=2017.4.17 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from requests->cosmpy<0.10.0,>=0.9.2->nillion-python-helpers==0.2.3) (2024.8.30)\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;49m24.0\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m24.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;49mpip3 install --upgrade pip\u001b[0m\n", + "Requirement already satisfied: nillion_client==0.1.1 in /home/hello/Projects/MonadicDNA/.venv/lib/python3.12/site-packages (0.1.1)\n", + "Requirement already satisfied: cosmpy==0.9.2 in /home/hello/Projects/MonadicDNA/.venv/lib/python3.12/site-packages (from nillion_client==0.1.1) (0.9.2)\n", + "Requirement already satisfied: secp256k1==0.14.0 in /home/hello/Projects/MonadicDNA/.venv/lib/python3.12/site-packages (from nillion_client==0.1.1) (0.14.0)\n", + "Requirement already satisfied: base58==2.1.1 in /home/hello/Projects/MonadicDNA/.venv/lib/python3.12/site-packages (from nillion_client==0.1.1) (2.1.1)\n", + "Requirement already satisfied: tenacity==9.0.0 in /home/hello/Projects/MonadicDNA/.venv/lib/python3.12/site-packages (from nillion_client==0.1.1) (9.0.0)\n", + "Requirement already satisfied: nillion-client-core==0.1.1 in /home/hello/Projects/MonadicDNA/.venv/lib/python3.12/site-packages (from nillion_client==0.1.1) (0.1.1)\n", + "Requirement already satisfied: nillion-client-proto==0.1.1 in /home/hello/Projects/MonadicDNA/.venv/lib/python3.12/site-packages (from nillion_client==0.1.1) (0.1.1)\n", + "Requirement already satisfied: pyyaml==6.0.2 in /home/hello/Projects/MonadicDNA/.venv/lib/python3.12/site-packages (from nillion_client==0.1.1) (6.0.2)\n", + "Requirement already satisfied: bech32 in /home/hello/Projects/MonadicDNA/.venv/lib/python3.12/site-packages (from cosmpy==0.9.2->nillion_client==0.1.1) (1.2.0)\n", + "Requirement already satisfied: ecdsa in /home/hello/Projects/MonadicDNA/.venv/lib/python3.12/site-packages (from cosmpy==0.9.2->nillion_client==0.1.1) (0.19.0)\n", + "Requirement already satisfied: googleapis-common-protos in /home/hello/Projects/MonadicDNA/.venv/lib/python3.12/site-packages (from cosmpy==0.9.2->nillion_client==0.1.1) (1.66.0)\n", + "Requirement already satisfied: grpcio in /home/hello/Projects/MonadicDNA/.venv/lib/python3.12/site-packages (from cosmpy==0.9.2->nillion_client==0.1.1) (1.68.1)\n", + "Requirement already satisfied: jsonschema<5,>=3.2.0 in /home/hello/Projects/MonadicDNA/.venv/lib/python3.12/site-packages (from cosmpy==0.9.2->nillion_client==0.1.1) (4.23.0)\n", + "Requirement already satisfied: protobuf<5.0dev,>=4.21.6 in /home/hello/Projects/MonadicDNA/.venv/lib/python3.12/site-packages (from cosmpy==0.9.2->nillion_client==0.1.1) (4.25.5)\n", + "Requirement already satisfied: pycryptodome<4.0.0,>=3.18.0 in /home/hello/Projects/MonadicDNA/.venv/lib/python3.12/site-packages (from cosmpy==0.9.2->nillion_client==0.1.1) (3.21.0)\n", + "Requirement already satisfied: python-dateutil in /home/hello/Projects/MonadicDNA/.venv/lib/python3.12/site-packages (from cosmpy==0.9.2->nillion_client==0.1.1) (2.9.0.post0)\n", + "Requirement already satisfied: requests in /home/hello/Projects/MonadicDNA/.venv/lib/python3.12/site-packages (from cosmpy==0.9.2->nillion_client==0.1.1) (2.32.3)\n", + "Requirement already satisfied: grpcio-tools==1.62.3 in /home/hello/Projects/MonadicDNA/.venv/lib/python3.12/site-packages (from nillion-client-proto==0.1.1->nillion_client==0.1.1) (1.62.3)\n", + "Requirement already satisfied: betterproto==2.0.0b7 in /home/hello/Projects/MonadicDNA/.venv/lib/python3.12/site-packages (from nillion-client-proto==0.1.1->nillion_client==0.1.1) (2.0.0b7)\n", + "Requirement already satisfied: cffi>=1.3.0 in /home/hello/Projects/MonadicDNA/.venv/lib/python3.12/site-packages (from secp256k1==0.14.0->nillion_client==0.1.1) (1.17.1)\n", + "Requirement already satisfied: grpclib<0.5.0,>=0.4.1 in /home/hello/Projects/MonadicDNA/.venv/lib/python3.12/site-packages (from betterproto==2.0.0b7->nillion-client-proto==0.1.1->nillion_client==0.1.1) (0.4.7)\n", + "Requirement already satisfied: typing-extensions<5.0.0,>=4.7.1 in /home/hello/Projects/MonadicDNA/.venv/lib/python3.12/site-packages (from betterproto==2.0.0b7->nillion-client-proto==0.1.1->nillion_client==0.1.1) (4.12.2)\n", + "Requirement already satisfied: setuptools in /home/hello/Projects/MonadicDNA/.venv/lib/python3.12/site-packages (from grpcio-tools==1.62.3->nillion-client-proto==0.1.1->nillion_client==0.1.1) (75.6.0)\n", + "Requirement already satisfied: pycparser in /home/hello/Projects/MonadicDNA/.venv/lib/python3.12/site-packages (from cffi>=1.3.0->secp256k1==0.14.0->nillion_client==0.1.1) (2.22)\n", + "Requirement already satisfied: attrs>=22.2.0 in /home/hello/Projects/MonadicDNA/.venv/lib/python3.12/site-packages (from jsonschema<5,>=3.2.0->cosmpy==0.9.2->nillion_client==0.1.1) (24.3.0)\n", + "Requirement already satisfied: jsonschema-specifications>=2023.03.6 in /home/hello/Projects/MonadicDNA/.venv/lib/python3.12/site-packages (from jsonschema<5,>=3.2.0->cosmpy==0.9.2->nillion_client==0.1.1) (2024.10.1)\n", + "Requirement already satisfied: referencing>=0.28.4 in /home/hello/Projects/MonadicDNA/.venv/lib/python3.12/site-packages (from jsonschema<5,>=3.2.0->cosmpy==0.9.2->nillion_client==0.1.1) (0.35.1)\n", + "Requirement already satisfied: rpds-py>=0.7.1 in /home/hello/Projects/MonadicDNA/.venv/lib/python3.12/site-packages (from jsonschema<5,>=3.2.0->cosmpy==0.9.2->nillion_client==0.1.1) (0.22.3)\n", + "Requirement already satisfied: six>=1.5 in /home/hello/Projects/MonadicDNA/.venv/lib/python3.12/site-packages (from python-dateutil->cosmpy==0.9.2->nillion_client==0.1.1) (1.17.0)\n", + "Requirement already satisfied: charset-normalizer<4,>=2 in /home/hello/Projects/MonadicDNA/.venv/lib/python3.12/site-packages (from requests->cosmpy==0.9.2->nillion_client==0.1.1) (3.4.0)\n", + "Requirement already satisfied: idna<4,>=2.5 in /home/hello/Projects/MonadicDNA/.venv/lib/python3.12/site-packages (from requests->cosmpy==0.9.2->nillion_client==0.1.1) (3.10)\n", + "Requirement already satisfied: urllib3<3,>=1.21.1 in /home/hello/Projects/MonadicDNA/.venv/lib/python3.12/site-packages (from requests->cosmpy==0.9.2->nillion_client==0.1.1) (2.2.3)\n", + "Requirement already satisfied: certifi>=2017.4.17 in /home/hello/Projects/MonadicDNA/.venv/lib/python3.12/site-packages (from requests->cosmpy==0.9.2->nillion_client==0.1.1) (2024.12.14)\n", + "Requirement already satisfied: h2<5,>=3.1.0 in /home/hello/Projects/MonadicDNA/.venv/lib/python3.12/site-packages (from grpclib<0.5.0,>=0.4.1->betterproto==2.0.0b7->nillion-client-proto==0.1.1->nillion_client==0.1.1) (4.1.0)\n", + "Requirement already satisfied: multidict in /home/hello/Projects/MonadicDNA/.venv/lib/python3.12/site-packages (from grpclib<0.5.0,>=0.4.1->betterproto==2.0.0b7->nillion-client-proto==0.1.1->nillion_client==0.1.1) (6.1.0)\n", + "Requirement already satisfied: hyperframe<7,>=6.0 in /home/hello/Projects/MonadicDNA/.venv/lib/python3.12/site-packages (from h2<5,>=3.1.0->grpclib<0.5.0,>=0.4.1->betterproto==2.0.0b7->nillion-client-proto==0.1.1->nillion_client==0.1.1) (6.0.1)\n", + "Requirement already satisfied: hpack<5,>=4.0 in /home/hello/Projects/MonadicDNA/.venv/lib/python3.12/site-packages (from h2<5,>=3.1.0->grpclib<0.5.0,>=0.4.1->betterproto==2.0.0b7->nillion-client-proto==0.1.1->nillion_client==0.1.1) (4.0.0)\n", "Note: you may need to restart the kernel to use updated packages.\n", - "Requirement already satisfied: python-dotenv==1.0.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (1.0.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;49m24.0\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m24.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;49mpip3 install --upgrade pip\u001b[0m\n", + "Requirement already satisfied: cryptography==44.0.0 in /home/hello/Projects/MonadicDNA/.venv/lib/python3.12/site-packages (44.0.0)\n", + "Requirement already satisfied: cffi>=1.12 in /home/hello/Projects/MonadicDNA/.venv/lib/python3.12/site-packages (from cryptography==44.0.0) (1.17.1)\n", + "Requirement already satisfied: pycparser in /home/hello/Projects/MonadicDNA/.venv/lib/python3.12/site-packages (from cffi>=1.12->cryptography==44.0.0) (2.22)\n", "Note: you may need to restart the kernel to use updated packages.\n" ] } ], "source": [ - "%pip install nada-dsl==0.6.0\n", - "%pip install py-nillion-client==0.6.0\n", - "%pip install nillion-python-helpers==0.2.3\n", - "%pip install python-dotenv==1.0.0\n" + "%pip install nada-dsl==0.7.2\n", + "%pip install python-dotenv==1.0.0\n", + "%pip install nillion_client==0.1.1\n", + "%pip install cryptography==44.0.0" ] }, { @@ -110,7 +111,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 1, "metadata": { "ExecuteTime": { "end_time": "2024-08-09T23:28:05.762189Z", @@ -120,13 +121,29 @@ }, "outputs": [], "source": [ - "import py_nillion_client as nillion\n", - "from py_nillion_client import NodeKey, UserKey\n", + "import argparse\n", + "import asyncio\n", + "import os\n", + "\n", + "from nillion_client import (\n", + " InputPartyBinding,\n", + " Network,\n", + " NilChainPayer,\n", + " NilChainPrivateKey,\n", + " OutputPartyBinding,\n", + " SecretInteger,\n", + " UserId,\n", + " Permissions,\n", + " PermissionsDelta,\n", + " VmClient,\n", + " PrivateKey,\n", + ")\n", "from dotenv import load_dotenv\n", - "from nillion_python_helpers import get_quote_and_pay, create_nillion_client, create_payments_config\n", - "from cosmpy.aerial.client import LedgerClient\n", - "from cosmpy.aerial.wallet import LocalWallet\n", - "from cosmpy.crypto.keypairs import PrivateKey" + "from nillion_client.ids import UUID\n", + "from nillion_client.payer import DummyPayer\n", + "from nillion_client.permissions import (ComputePermissionCommand, ComputePermissions,ComputePermission)\n", + "import hashlib\n", + "from ecdsa import SigningKey, SECP256k1" ] }, { @@ -140,7 +157,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 2, "metadata": { "ExecuteTime": { "end_time": "2024-08-09T23:28:08.870617Z", @@ -157,14 +174,13 @@ "name": "stdout", "output_type": "stream", "text": [ - "Loading environment variables from /Users/aisha/.config/nillion/nillion-devnet.env\n", + "Loading environment variables from /home/hello/.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_GRPC: http://localhost:26649\n", + "NILLION_GRPC_ENDPOINT: http://127.0.0.1:37939\n", "NILLION_NILCHAIN_PRIVATE_KEY_0: 9a975f567428d054f2bf3092812e6c42f901ce07d9711bc77ee2cd81101f42c5\n", "NILLION_NILCHAIN_PRIVATE_KEY_1: 1e491133b9408b39572a29f91644873decea554224b20e2b0b923aeb860a1c18\n", "NILLION_NILCHAIN_PRIVATE_KEY_2: 980488572f235316cdb330191f8bafe4e635efbe88b3a40f5bee9bd21047c059\n", @@ -214,43 +230,58 @@ "name": "stdout", "output_type": "stream", "text": [ - "Cluster ID: 9e68173f-9c23-4acc-ba81-4f079b639964\n", - "Chain ID: nillion-chain-devnet\n", - "GRPC Endpoint: localhost:26649\n" + "c653318e9a92e3d8a5fd536f6c3324047b85d294c48b2fdaa8e861b8bd53a3d1\n", + "Chain ID: nillion-chain-testnet-1\n", + "GRPC Endpoint: https://node-1.nucleus2.nillion-network.nilogy.xyz:14311\n" ] + }, + { + "data": { + "text/plain": [ + "Network(chain_id='nillion-chain-testnet-1', chain_grpc_endpoint='https://testnet-nillion-grpc.lavenderfive.com', nilvm_grpc_endpoint='https://node-1.nucleus2.nillion-network.nilogy.xyz:14311')" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" } ], "source": [ - "cluster_id = os.getenv('NILLION_CLUSTER_ID')\n", - "chain_id = os.getenv('NILLION_NILCHAIN_CHAIN_ID')\n", - "grpc_endpoint = os.getenv('NILLION_NILCHAIN_GRPC')\n", - "\n", - "print(f\"Cluster ID: {cluster_id}\")\n", + "use_testnet = False\n", + "\n", + "if not use_testnet:\n", + " cluster_id = os.getenv('NILLION_CLUSTER_ID')\n", + " chain_id = os.getenv('NILLION_NILCHAIN_CHAIN_ID')\n", + " nilvm_grpc_endpoint = os.getenv('NILLION_NILCHAIN_GRPC')\n", + " payer_userkey_hex:str = os.getenv(\"NILLION_NILCHAIN_PRIVATE_KEY_0\")\n", + " monadic_seed = \"monadic_seed\"\n", + " monadic_userkey_hex = hashlib.sha256(monadic_seed.encode()).digest().hex()\n", + " snipper_seed = \"snipper_seed\"\n", + " snipper_userkey_hex = hashlib.sha256(snipper_seed.encode()).digest().hex()\n", + " patient_seed = \"patient_seed\"\n", + " patient_userkey_hex = hashlib.sha256(patient_seed.encode()).digest().hex()\n", + " network:Network = Network.from_config(\"devnet\")\n", + "else:\n", + " chain_id = \"nillion-chain-testnet-1\"\n", + " chain_grpc_endpoint = \"https://testnet-nillion-grpc.lavenderfive.com\"\n", + " nilvm_grpc_endpoint = \"https://node-1.nucleus2.nillion-network.nilogy.xyz:14311\"\n", + " payer_userkey_hex = \"11112217e1ba614ee927fdc38a31b686c7b56976aa92451e89f769b518416112\"\n", + " monadic_seed = \"monadic_seed\"\n", + " monadic_userkey_hex = hashlib.sha256(monadic_seed.encode()).digest().hex()\n", + " snipper_seed = \"snipper_seed\"\n", + " snipper_userkey_hex = hashlib.sha256(snipper_seed.encode()).digest().hex()\n", + " patient_seed = \"patient_seed\"\n", + " patient_userkey_hex = hashlib.sha256(patient_seed.encode()).digest().hex()\n", + " network:Network = Network(\n", + " chain_grpc_endpoint=chain_grpc_endpoint,\n", + " chain_id=chain_id,\n", + " nilvm_grpc_endpoint=nilvm_grpc_endpoint \n", + " )\n", + " \n", "print(f\"Chain ID: {chain_id}\")\n", - "print(f\"GRPC Endpoint: {grpc_endpoint}\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Each actor will need its own node key so we define a utility function here." - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": { - "ExecuteTime": { - "end_time": "2024-08-09T23:28:16.326786Z", - "start_time": "2024-08-09T23:28:16.320243Z" - } - }, - "outputs": [], - "source": [ - "import uuid\n", - "def gen_node_key():\n", - " return NodeKey.from_seed(uuid.uuid4().hex)" + "print(f\"GRPC Endpoint: {nilvm_grpc_endpoint}\")\n", + "\n", + "network" ] }, { @@ -262,7 +293,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 9, "metadata": { "ExecuteTime": { "end_time": "2024-08-09T23:28:19.828183Z", @@ -271,10 +302,13 @@ }, "outputs": [], "source": [ - "monadic_seed = \"monadic_seed\"\n", - "monadic_userkey = UserKey.from_seed(monadic_seed)\n", - "monadic_client = create_nillion_client(monadic_userkey, gen_node_key())\n", - "monadic_party_id = monadic_client.party_id\n", + "monadic_userkey = NilChainPrivateKey(bytes.fromhex(monadic_userkey_hex))\n", + "monadic_payer = NilChainPayer(\n", + " network,\n", + " wallet_private_key=monadic_userkey,\n", + " gas_limit=1000,\n", + ")\n", + "monadic_client = await VmClient.create(PrivateKey(bytes.fromhex(monadic_userkey_hex)), network, monadic_payer)\n", "monadic_user_id = monadic_client.user_id" ] }, @@ -287,7 +321,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 10, "metadata": { "ExecuteTime": { "end_time": "2024-08-09T23:28:22.512975Z", @@ -296,10 +330,13 @@ }, "outputs": [], "source": [ - "snipper_seed = \"snipper_seed\"\n", - "snipper_userkey = UserKey.from_seed(snipper_seed)\n", - "snipper_client = create_nillion_client(snipper_userkey, gen_node_key())\n", - "snipper_party_id = snipper_client.party_id\n", + "snipper_userkey = NilChainPrivateKey(bytes.fromhex(snipper_userkey_hex))\n", + "snipper_payer = NilChainPayer(\n", + " network,\n", + " wallet_private_key=snipper_userkey,\n", + " gas_limit=1000,\n", + ")\n", + "snipper_client = await VmClient.create(PrivateKey(bytes.fromhex(snipper_userkey_hex)), network, snipper_payer)\n", "snipper_user_id = snipper_client.user_id" ] }, @@ -312,7 +349,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 11, "metadata": { "ExecuteTime": { "end_time": "2024-08-09T23:28:28.760101Z", @@ -321,10 +358,13 @@ }, "outputs": [], "source": [ - "patient_seed = \"patient_seed\"\n", - "patient_userkey = UserKey.from_seed(patient_seed)\n", - "patient_client = create_nillion_client(patient_userkey, gen_node_key())\n", - "patient_party_id = patient_client.party_id\n", + "patient_userkey = NilChainPrivateKey(bytes.fromhex(patient_userkey_hex))\n", + "patient_payer = NilChainPayer(\n", + " network,\n", + " wallet_private_key=patient_userkey,\n", + " gas_limit=1000,\n", + ")\n", + "patient_client = await VmClient.create(PrivateKey(bytes.fromhex(patient_userkey_hex)), network, patient_payer)\n", "patient_user_id = patient_client.user_id" ] }, @@ -337,7 +377,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 12, "metadata": { "ExecuteTime": { "end_time": "2024-08-09T23:28:31.282228Z", @@ -347,47 +387,89 @@ }, "outputs": [], "source": [ - "payments_config = create_payments_config(chain_id, grpc_endpoint)\n", - "payments_client = LedgerClient(payments_config)\n", - "payments_wallet = LocalWallet(\n", - " PrivateKey(bytes.fromhex(os.getenv(\"NILLION_NILCHAIN_PRIVATE_KEY_0\"))),\n", - " prefix=\"nillion\",\n", - ")" + "payer_privKey = NilChainPrivateKey(bytes.fromhex(payer_userkey_hex))\n", + "\n", + "payer = NilChainPayer(\n", + " network,\n", + " wallet_private_key=payer_privKey,\n", + " gas_limit=10000000,\n", + ")\n", + "# We will identify ourselves with the pre-configured private key\n", + "payer_client= await VmClient.create(PrivateKey(bytes.fromhex(payer_userkey_hex)), network, payer)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "Configuration for the program to use. Change the contents of the below cell to use another program. " + "Add funds to clients" ] }, { "cell_type": "code", - "execution_count": 10, - "metadata": { - "ExecuteTime": { - "end_time": "2024-08-09T23:28:33.143041Z", - "start_time": "2024-08-09T23:28:33.134076Z" - }, - "id": "rEr0_JkMuVci" - }, + "execution_count": 13, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "💰 Current Payer Balance: 500000 uNIL\n", + "💰 Current Patient Balance: 496598 uNIL\n", + "💰 Current monadic Balance: 500000 uNIL\n", + "💰 Current sniper Balance: 500000 uNIL\n" + ] + } + ], + "source": [ + "funds_amount = 500000\n", + "bal = await payer_client.balance()\n", + "print(f\"💰 Current Payer Balance: {bal.balance} uNIL\")\n", + "if bal.balance < 400000:\n", + " print(f\"💰 Adding some funds to the executor client balance: {bal.balance} uNIL\")\n", + " await payer_client.add_funds(funds_amount)\n", + "bal = await patient_client.balance()\n", + "print(f\"💰 Current Patient Balance: {bal.balance} uNIL\")\n", + "if bal.balance < 400000:\n", + " await payer_client.add_funds(500000, target_user=patient_user_id)\n", + "bal = await monadic_client.balance()\n", + "print(f\"💰 Current monadic Balance: {bal.balance} uNIL\")\n", + "if bal.balance < 400000:\n", + " await payer_client.add_funds(500000, target_user=monadic_user_id)\n", + "bal = await snipper_client.balance()\n", + "print(f\"💰 Current sniper Balance: {bal.balance} uNIL\")\n", + "if bal.balance < 400000:\n", + " await payer_client.add_funds(500000, target_user=snipper_user_id)\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Configuration for the program to use. Change the contents of the below cell to use another program." + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": {}, "outputs": [], "source": [ "program_name = \"double\"\n", - "program_mir_path = f\"binaries/double.nada.bin\"" + "program_mir_path = f\"binaries/double.nada.bin\"\n", + "program = open(program_mir_path, \"rb\").read()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "As a baseline, let's ensure that the user can store the program and run it on their own secret. " + "As a baseline, let's ensure that the user can store the program and run it on their own secret." ] }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 15, "metadata": { "ExecuteTime": { "end_time": "2024-08-09T23:28:41.524938Z", @@ -400,21 +482,13 @@ "output_type": "stream", "text": [ "The patient is storing the program on the network\n", - "Getting quote for operation...\n", - "Quote cost is 2 unil\n", - "Submitting payment receipt 2 unil, tx hash D1584C1F65DAFA2701F73117E739E136C32A609AF6EF7FB43102E95337A98499\n", - "Action ID: 229XQCZoSQk9zDx4ixKXg8wAqCy7HnmUjcTuMe7D1bUVhNG7kYNF4xeZYjRsEtJUhKFvXwfM65ixFWDRhptfHCqw/double\n", + "Program ID: 4b367ad186fa672387ca7fb6ea9f75c13cc53a82/double/sha256/35f9b61f28b8e9aafbc987766f6ff549892aafe1d65256aa6feec84b1f5b6bf0\n", "The patient is storing a secret on the network\n", - "Getting quote for operation...\n", - "Quote cost is 482 unil\n", - "Submitting payment receipt 482 unil, tx hash 8070A55743C4A1A3DA557B9D288FD964A6DA58D27E2F2DB973FFF938E8425FE6\n", "The patient is running the program on the secret..\n", - "Getting quote for operation...\n", - "Quote cost is 3 unil\n", - "Submitting payment receipt 3 unil, tx hash 108432FF46244933B87378BBADE5F1F58F5E4CFA478F96B6DA8D8224A7288698\n", - "The computation was sent to the network. compute_id: 9881886b-174a-4ea1-88b2-2f974e739cfd\n", - "✅ Compute complete for compute_id 9881886b-174a-4ea1-88b2-2f974e739cfd\n", - "🖥️ The result is {'my_output': 4}\n" + "The computation was sent to the network. compute_id: e52ecb8b-26c5-4d49-9737-c12ec934ee1d\n", + "✅ Compute complete for compute_id e52ecb8b-26c5-4d49-9737-c12ec934ee1d\n", + "🖥️ The result is {'my_output': SecretInteger(4)}\n", + "💰 Final client balance: 496112 uNIL\n" ] } ], @@ -425,85 +499,52 @@ "\n", "print(\"The patient is storing the program on the network\")\n", "\n", - "async def store_program():\n", - " receipt_store_program = await get_quote_and_pay(\n", - " patient_client,\n", - " nillion.Operation.store_program(program_mir_path),\n", - " payments_wallet,\n", - " payments_client,\n", - " cluster_id,\n", - " )\n", - "\n", - " # Store the program\n", - " action_id = await patient_client.store_program(\n", - " cluster_id, program_name, program_mir_path, receipt_store_program\n", - " )\n", - " return action_id\n", + "program_id = await patient_client.store_program(\n", + " program_name, program,\n", + ").invoke()\n", "\n", - "action_id = await store_program()\n", - "print(f\"Action ID: {action_id}\")\n", + "print(f\"Program ID: {program_id}\")\n", "\n", "print(\"The patient is storing a secret on the network\")\n", "\n", - "program_id = f\"{patient_user_id}/{program_name}\"\n", - "\n", - "new_secret = nillion.NadaValues(\n", - " {\n", - " \"foo\": nillion.SecretInteger(2),\n", - " }\n", - ")\n", + "values = {\"foo\": SecretInteger(2) }\n", "\n", "# Set permissions for the client to compute on the program\n", - "permissions = nillion.Permissions.default_for_user(patient_user_id)\n", - "permissions.add_compute_permissions({patient_user_id: {program_id}})\n", - "\n", - "# Pay for and store the secret in the network and print the returned store_id\n", - "receipt_store = await get_quote_and_pay(\n", - " patient_client,\n", - " nillion.Operation.store_values(new_secret, ttl_days=5),\n", - " payments_wallet,\n", - " payments_client,\n", - " cluster_id,\n", - ")\n", + "permissions = Permissions.defaults_for_user(patient_user_id).allow_compute(\n", + " patient_user_id, program_id\n", + " )\n", + "\n", "# Store a secret\n", "store_id = await patient_client.store_values(\n", - " cluster_id, new_secret, permissions, receipt_store\n", - ")\n", + " values=values, ttl_days=5, permissions=permissions\n", + ").invoke()\n", + "\n", "\n", "print(\"The patient is running the program on the secret..\")\n", "\n", "party_name = \"Party1\"\n", - "compute_bindings = nillion.ProgramBindings(program_id)\n", - "compute_bindings.add_input_party(party_name, patient_party_id)\n", - "compute_bindings.add_output_party(party_name, patient_party_id)\n", - "computation_time_secrets = nillion.NadaValues({})\n", - "\n", - "# Pay for the compute\n", - "receipt_compute = await get_quote_and_pay(\n", - " patient_client,\n", - " nillion.Operation.compute(program_id, computation_time_secrets),\n", - " payments_wallet,\n", - " payments_client,\n", - " cluster_id,\n", - ")\n", + "\n", + "input_bindings = [InputPartyBinding(party_name, patient_user_id)]\n", + "output_bindings = [OutputPartyBinding(party_name, [patient_user_id])]\n", + "\n", + "computation_time_secrets = {}\n", "\n", "# Compute on the secret\n", "compute_id = await patient_client.compute(\n", - " cluster_id,\n", - " compute_bindings,\n", - " [store_id],\n", - " computation_time_secrets,\n", - " receipt_compute,\n", - ")\n", + " program_id,\n", + " input_bindings,\n", + " output_bindings,\n", + " values=computation_time_secrets,\n", + " value_ids=[store_id]\n", + ").invoke()\n", "\n", "# 8. Return the computation result\n", "print(f\"The computation was sent to the network. compute_id: {compute_id}\")\n", - "while True:\n", - " compute_event = await patient_client.next_compute_event()\n", - " if isinstance(compute_event, nillion.ComputeFinishedEvent):\n", - " print(f\"✅ Compute complete for compute_id {compute_event.uuid}\")\n", - " print(f\"🖥️ The result is {compute_event.result.value}\")\n", - " break" + "result = await patient_client.retrieve_compute_results(compute_id).invoke()\n", + "print(f\"✅ Compute complete for compute_id {compute_id}\")\n", + "print(f\"🖥️ The result is {result}\")\n", + "balance = await patient_client.balance()\n", + "print(f\"💰 Final client balance: {balance.balance} uNIL\")" ] }, { @@ -517,7 +558,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 16, "metadata": { "ExecuteTime": { "end_time": "2024-08-09T23:28:49.395066Z", @@ -535,33 +576,16 @@ "name": "stdout", "output_type": "stream", "text": [ - "Getting quote for operation...\n", - "Quote cost is 2 unil\n", - "Submitting payment receipt 2 unil, tx hash 0A2FBDA6C851AB4319E6E3A8B0D4B015E6E95044CD29C1D0DCC75EAEA8429570\n", - "Action ID: 3Uaays4LAuJ7QGbAC94etCHAr1dzt9NBnX4Q3QMY16cpJNYstDNBv6efyrgGeKfBAemaECUCxApThCfLxcmJbAPj/double\n" + "Program ID: ac9f9cea344cdbeaaa76ecca9eea25b21b0a1742/double/sha256/35f9b61f28b8e9aafbc987766f6ff549892aafe1d65256aa6feec84b1f5b6bf0\n" ] } ], "source": [ - "async def store_program():\n", - " receipt_store_program = await get_quote_and_pay(\n", - " monadic_client,\n", - " nillion.Operation.store_program(program_mir_path),\n", - " payments_wallet,\n", - " payments_client,\n", - " cluster_id,\n", - " )\n", - "\n", - " # Store the program\n", - " action_id = await monadic_client.store_program(\n", - " cluster_id, program_name, program_mir_path, receipt_store_program\n", - " )\n", - " return action_id\n", + "mondaic_program_id = await monadic_client.store_program(\n", + " program_name, program,\n", + ").invoke()\n", "\n", - "# Use this in your Jupyter notebook cell\n", - "action_id = await store_program()\n", - "print(f\"Action ID: {action_id}\")\n", - "\n" + "print(f\"Program ID: {mondaic_program_id}\")\n" ] }, { @@ -571,58 +595,38 @@ "Have the Patient store a secret on the network such that:\n", "- The Patient has all the regular persmissions\n", "- Monadic is able to modify permissions and compute on the secret\n", - "- Snipper is able to compute on the secret\n", "\n", "TODO: Establish a chain by having Monadic actually assign compute access to Snipper" ] }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 17, "metadata": { "ExecuteTime": { "end_time": "2024-08-09T23:28:54.210051Z", "start_time": "2024-08-09T23:28:52.165103Z" } }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Getting quote for operation...\n", - "Quote cost is 482 unil\n", - "Submitting payment receipt 482 unil, tx hash 61F8428B0BA42AE5B1D62C5588EC1055A556DD14E116ECD5EBD56A838720B5F8\n" - ] - } - ], + "outputs": [], "source": [ - "program_id = f\"{monadic_user_id}/{program_name}\"\n", + "program_id = mondaic_program_id\n", "\n", - "new_secret = nillion.NadaValues(\n", - " {\n", - " \"foo\": nillion.SecretInteger(2),\n", + "values = {\n", + " \"foo\": SecretInteger(2),\n", " }\n", - ")\n", + "\n", "\n", "# Set permissions for the client to compute on the program\n", - "permissions = nillion.Permissions.default_for_user(patient_user_id)\n", - "permissions.add_update_permissions(set([monadic_user_id]))\n", - "permissions.add_compute_permissions({monadic_user_id: {program_id}})\n", - "permissions.add_compute_permissions({snipper_user_id: {program_id}})\n", - "\n", - "# Pay for and store the secret in the network and print the returned store_id\n", - "receipt_store = await get_quote_and_pay(\n", - " patient_client,\n", - " nillion.Operation.store_values(new_secret, ttl_days=5),\n", - " payments_wallet,\n", - " payments_client,\n", - " cluster_id,\n", - ")\n", + "permissions = Permissions.defaults_for_user(patient_user_id)\\\n", + " .allow_update(monadic_user_id)\\\n", + " .allow_compute(monadic_user_id, program_id)\\\n", + "\n", + "\n", "# Store a secret\n", - "store_id = await patient_client.store_values(\n", - " cluster_id, new_secret, permissions, receipt_store\n", - ")" + "new_store_id = await patient_client.store_values(\n", + " values=values, ttl_days=5, permissions=permissions\n", + ").invoke()" ] }, { @@ -636,7 +640,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 18, "metadata": { "ExecuteTime": { "end_time": "2024-08-09T23:28:59.264419Z", @@ -648,12 +652,10 @@ "name": "stdout", "output_type": "stream", "text": [ - "Getting quote for operation...\n", - "Quote cost is 3 unil\n", - "Submitting payment receipt 3 unil, tx hash B6291177FFAC17961AE56CABFE813944EB3142AA184B1778A41884FA4CA2FC34\n", - "The computation was sent to the network. compute_id: 0c211b76-5f39-44ad-ae64-029a7547a22e\n", - "✅ Compute complete for compute_id 0c211b76-5f39-44ad-ae64-029a7547a22e\n", - "🖥️ The result is {'my_output': 4}\n" + "The computation was sent to the network. compute_id: c5d48389-c300-41a2-99d1-202788f3ecb8\n", + "✅ Compute complete for compute_id c5d48389-c300-41a2-99d1-202788f3ecb8\n", + "🖥️ The result is {'my_output': SecretInteger(4)}\n", + "💰 Final client balance: 499995 uNIL\n" ] } ], @@ -663,38 +665,62 @@ "os.environ['RUST_BACKTRACE'] = 'full'\n", "\n", "party_name = \"Party1\"\n", - "compute_bindings = nillion.ProgramBindings(program_id)\n", - "compute_bindings.add_input_party(party_name, monadic_party_id)\n", - "compute_bindings.add_output_party(party_name, monadic_party_id)\n", - "\n", - "computation_time_secrets = nillion.NadaValues({})\n", - "\n", - "# Pay for the compute\n", - "receipt_compute = await get_quote_and_pay(\n", - " monadic_client,\n", - " nillion.Operation.compute(program_id, computation_time_secrets),\n", - " payments_wallet,\n", - " payments_client,\n", - " cluster_id,\n", - ")\n", + "\n", + "input_bindings = [InputPartyBinding(party_name, monadic_user_id)]\n", + "output_bindings = [OutputPartyBinding(party_name, [monadic_user_id])]\n", + "\n", + "computation_time_secrets = {}\n", "\n", "# Compute on the secret\n", "compute_id = await monadic_client.compute(\n", - " cluster_id,\n", - " compute_bindings,\n", - " [store_id],\n", - " computation_time_secrets,\n", - " receipt_compute,\n", - ")\n", + " program_id,\n", + " input_bindings,\n", + " output_bindings,\n", + " values=computation_time_secrets,\n", + " value_ids=[new_store_id]\n", + ").invoke()\n", "\n", "# 8. Return the computation result\n", "print(f\"The computation was sent to the network. compute_id: {compute_id}\")\n", - "while True:\n", - " compute_event = await monadic_client.next_compute_event()\n", - " if isinstance(compute_event, nillion.ComputeFinishedEvent):\n", - " print(f\"✅ Compute complete for compute_id {compute_event.uuid}\")\n", - " print(f\"🖥️ The result is {compute_event.result.value}\")\n", - " break" + "result = await monadic_client.retrieve_compute_results(compute_id).invoke()\n", + "print(f\"✅ Compute complete for compute_id {compute_id}\")\n", + "print(f\"🖥️ The result is {result}\")\n", + "balance = await monadic_client.balance()\n", + "print(f\"💰 Final client balance: {balance.balance} uNIL\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Update permissions on the value to give snipper bot compute perms" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "existing compute perms count 1\n", + "new compute perms count 2\n" + ] + } + ], + "source": [ + "compute = ComputePermissions()\n", + "compute.permissions[snipper_user_id] = ComputePermission()\n", + "compute.permissions[snipper_user_id].program_ids.add(mondaic_program_id)\n", + "allowCompute = PermissionsDelta(compute=ComputePermissionCommand(grant=compute))\n", + "existingPermissions = await patient_client.retrieve_permissions(new_store_id).invoke()\n", + "await patient_client.update_permissions(new_store_id, allowCompute).invoke()\n", + "newPermissions = await patient_client.retrieve_permissions(new_store_id).invoke()\n", + "\n", + "print(\"existing compute perms count\", len(existingPermissions.compute.permissions))\n", + "print(\"new compute perms count\", len(newPermissions.compute.permissions))\n" ] }, { @@ -706,7 +732,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 20, "metadata": { "ExecuteTime": { "end_time": "2024-08-09T23:41:25.749809Z", @@ -718,57 +744,38 @@ "name": "stdout", "output_type": "stream", "text": [ - "Getting quote for operation...\n", - "Quote cost is 3 unil\n", - "Submitting payment receipt 3 unil, tx hash 71D060161BA2A3BCB88FD17F5BF5DE4F25BEC8BDD55C0D81EC847894C7F6308B\n", - "The computation was sent to the network. compute_id: 9382e2cb-ba4d-409e-a839-2efe38580052\n", - "✅ Compute complete for compute_id 9382e2cb-ba4d-409e-a839-2efe38580052\n", - "🖥️ The result is {'my_output': 4}\n" + "The computation was sent to the network. compute_id: b93f96e7-45d0-4e74-92a0-cc4d547cc321\n", + "✅ Compute complete for compute_id b93f96e7-45d0-4e74-92a0-cc4d547cc321\n", + "🖥️ The result is {'my_output': SecretInteger(4)}\n", + "💰 Final client balance: 499996 uNIL\n" ] } ], "source": [ "party_name = \"Party1\"\n", - "compute_bindings = nillion.ProgramBindings(program_id)\n", - "compute_bindings.add_input_party(party_name, snipper_party_id)\n", - "compute_bindings.add_output_party(party_name, snipper_party_id)\n", - "\n", - "computation_time_secrets = nillion.NadaValues({})\n", - "\n", - "# Pay for the compute\n", - "receipt_compute = await get_quote_and_pay(\n", - " snipper_client,\n", - " nillion.Operation.compute(program_id, computation_time_secrets),\n", - " payments_wallet,\n", - " payments_client,\n", - " cluster_id,\n", - ")\n", + "\n", + "input_bindings = [InputPartyBinding(party_name, snipper_user_id)]\n", + "output_bindings = [OutputPartyBinding(party_name, [snipper_user_id])]\n", + "\n", + "computation_time_secrets = {}\n", "\n", "# Compute on the secret\n", "compute_id = await snipper_client.compute(\n", - " cluster_id,\n", - " compute_bindings,\n", - " [store_id],\n", - " computation_time_secrets,\n", - " receipt_compute,\n", - ")\n", + " program_id,\n", + " input_bindings,\n", + " output_bindings,\n", + " values=computation_time_secrets,\n", + " value_ids=[new_store_id]\n", + ").invoke()\n", "\n", "# 8. Return the computation result\n", "print(f\"The computation was sent to the network. compute_id: {compute_id}\")\n", - "while True:\n", - " compute_event = await snipper_client.next_compute_event()\n", - " if isinstance(compute_event, nillion.ComputeFinishedEvent):\n", - " print(f\"✅ Compute complete for compute_id {compute_event.uuid}\")\n", - " print(f\"🖥️ The result is {compute_event.result.value}\")\n", - " break" + "result = await snipper_client.retrieve_compute_results(compute_id).invoke()\n", + "print(f\"✅ Compute complete for compute_id {compute_id}\")\n", + "print(f\"🖥️ The result is {result}\")\n", + "balance = await snipper_client.balance()\n", + "print(f\"💰 Final client balance: {balance.balance} uNIL\")" ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { @@ -776,7 +783,7 @@ "provenance": [] }, "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": ".venv", "language": "python", "name": "python3" }, @@ -790,7 +797,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.12.2" + "version": "3.12.7" } }, "nbformat": 4, diff --git a/services/nillion-interactor/app.py b/services/nillion-interactor/app.py index 988db04..7360775 100644 --- a/services/nillion-interactor/app.py +++ b/services/nillion-interactor/app.py @@ -1,25 +1,23 @@ -import asyncio -from flask import Flask, request, jsonify -from flask_cors import CORS +from quart import Quart, request, jsonify +from quart_cors import cors import os -import py_nillion_client as nillion import sys -import werkzeug -import socket import random import string +from uuid import UUID from dotenv import load_dotenv +from nillion_client import (VmClient, UserId, InputPartyBinding, OutputPartyBinding, SecretInteger, Permissions) + sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) from helpers.nillion_client_helper import create_nillion_client -from helpers.nillion_keypath_helper import getUserKeyFromFile, getNodeKeyFromFile load_dotenv() -app = Flask(__name__) -CORS(app, resources={r"/*": {"origins": "*"}}) +app = Quart(__name__) +app = cors(app, allow_origin="*") def get_random_node_key(): # hostname = socket.gethostname() @@ -30,9 +28,35 @@ def get_random_node_key(): print("Node key: ", result) return result -_userkey = getUserKeyFromFile(os.getenv("NILLION_USERKEY_PATH_PARTY_1")) -_nodekey = nillion.NodeKey.from_seed(get_random_node_key()) -_client = create_nillion_client(_userkey, _nodekey) +_keys = { + "monadic" : bytes.fromhex(os.getenv("MONADIC_PRIVKEY")), + "snipperBot" : bytes.fromhex(os.getenv("SNIPPER_BOT_PRIVKEY")) +} +_clients:dict[str, VmClient] = None + +_default_client = "monadic" + +_program_id = os.getenv("THROMBOSIS_PROGRAM_ID") + +async def initialize_client(): + global _clients, _program_id + if _clients is None: + _clients = {} + print("initializing clients") + for key in _keys : + _clients[key] = await create_nillion_client(_keys[key]) + print("done initializing clients") + if _program_id == '' or _program_id is None: + print("uploading thrombosis program") + _program_id = await upload_thrombosis_program() + print("thrombosis program uploaded, id "+_program_id) + +async def upload_thrombosis_program(): + program_name = "thrombosis" + program_mir_path = f"binaries/thrombosis.nada.bin" + program = open(program_mir_path, "rb").read() + return await _clients[_default_client].store_program(program_name, program,).invoke() + def read_and_filter_23andme(file_storage): # Define the SNPs of interest and their deterministic integer values @@ -70,17 +94,10 @@ def read_and_filter_23andme(file_storage): return results async def store_on_nillion(gene_data): - cluster_id = os.getenv("NILLION_CLUSTER_ID") - party_id = _client.party_id() - user_id = _client.user_id() - party_name = "Party1" - - program_name = "thrombosis" - program_mir_path = f"binaries/thrombosis.nada.bin" - program_id = f"{user_id}/{program_name}" - - secret_bindings = nillion.ProgramBindings(program_id) - secret_bindings.add_input_party(party_name, party_id) + # Set permissions for the client to compute on the program + permissions = Permissions.defaults_for_user(_clients[_default_client].user_id).allow_compute( + _clients[_default_client].user_id, _program_id + ) store_ids = {} @@ -88,79 +105,110 @@ async def store_on_nillion(gene_data): rsid = row['rsid'] rsid_int = row['rsid_int'] genotype_int = row['genotype_int'] - stored_secret = nillion.Secrets({ - "snp": nillion.SecretInteger(6), - "genotype": nillion.SecretInteger(9), - }) - store_id = await _client.store_secrets( - cluster_id, secret_bindings, stored_secret, None - ) + stored_secret = { + "snp": SecretInteger(rsid_int), + "genotype": SecretInteger(genotype_int), + } + store_id = await _clients[_default_client].store_values( + values=stored_secret, ttl_days=5, permissions=permissions + ).invoke() + store_ids[rsid] = store_id return store_ids -async def compute_on_nillion(store_id): - cluster_id = os.getenv("NILLION_CLUSTER_ID") - party_id = _client.party_id() - user_id = _client.user_id() - party_name = "Party1" - program_name = "thrombosis" - program_mir_path = f"binaries/thrombosis.nada.bin" +async def compute_on_nillion(client_id, store_id): - program_id = f"{user_id}/{program_name}" + party_name = "Party1" - compute_bindings = nillion.ProgramBindings(program_id) - compute_bindings.add_input_party(party_name, party_id) - compute_bindings.add_output_party(party_name, party_id) + input_bindings = [InputPartyBinding(party_name, _clients[client_id].user_id)] + output_bindings = [OutputPartyBinding(party_name, [_clients[client_id].user_id])] - computation_time_secrets = nillion.Secrets({}) + computation_time_secrets = {} # Compute on the secret - compute_id = await _client.compute( - cluster_id, - compute_bindings, - [store_id], - computation_time_secrets, - nillion.PublicVariables({}), - ) + compute_id = await _clients[client_id].compute( + _program_id, + input_bindings, + output_bindings, + values=computation_time_secrets, + value_ids=[UUID(f"urn:uuid:{store_id}")] + ).invoke() # Print compute result print(f"The computation was sent to the network. compute_id: {compute_id}") - while True: - compute_event = await _client.next_compute_event() - if isinstance(compute_event, nillion.ComputeFinishedEvent): - print(f"✅ Compute complete for compute_id {compute_event.uuid}") - print(f"🖥️ The result is {compute_event.result.value}") - return compute_event.result.value - + result = await _clients[client_id].retrieve_compute_results(compute_id).invoke() + return result['Result'].value + +async def fund_user(user_id): + try: + uid = UserId.parse(user_id) + except Exception: + return "Invalid UserID" + try: + await _clients[_default_client].add_funds(500000, target_user=uid) + except Exception: + return "Failed to add funds" @app.route('/dataset', methods=['PUT']) async def handle_dataset(): - if 'file' not in request.files: + files = await request.files + if 'file' not in files : return jsonify({'error': 'No file part'}), 400 - file = request.files['file'] + file = files['file'] if file.filename == '': return jsonify({'error': 'No selected file'}), 400 if file: - filtered_data = read_and_filter_23andme(file) - results = await asyncio.wait_for(store_on_nillion(filtered_data), timeout=120) - return jsonify(results) + try: + filtered_data = read_and_filter_23andme(file) + results = await store_on_nillion(filtered_data) + return jsonify(results) + except Exception as e: + print(e) + return jsonify({'error': 'internal error'}), 500 return jsonify({'error': 'File processing failed'}), 500 @app.route('/computations/thrombosis', methods=['POST']) async def thrombosis(): - store_id = request.json.get('store_id') - + store_id = (await request.json).get('store_id') if store_id is None: return jsonify({'error': 'Missing store_id'}), 400 - - result = await asyncio.wait_for(compute_on_nillion(store_id), timeout=120) + client_id = (await request.json).get('client_id') + if client_id is None: + client_id = _default_client + elif client_id not in _clients: + return jsonify({'error': 'Invalid client_id'}), 400 + try: + result = await compute_on_nillion(client_id, store_id) + except Exception as e: + print(e) + return jsonify({'error': 'internal error'}), 500 return jsonify(result) +@app.route('/fund', methods=['POST']) +async def fund(): + user_id = (await request.json).get('user_id') + if user_id is None: + return jsonify({'error': 'Missing user_id'}), 400 + try: + result = await fund_user(user_id) + if result.__contains__("Invalid UserID"): + return jsonify({'error': result}), 400 + elif result.__ne__(""): + return jsonify({'error': result}), 500 + except Exception as e: + print(e) + return jsonify({'error': 'internal error'}), 500 + return jsonify({'message': f"funded {user_id}"}) + @app.route('/') def hello_world(): return "Hello, world!" +@app.before_serving +async def startup(): + await initialize_client() + if __name__ == '__main__': app.run(host='0.0.0.0', debug=True, port=8732) diff --git a/services/nillion-interactor/binaries/double.nada.bin b/services/nillion-interactor/binaries/double.nada.bin index 9b101ea..7e805d9 100644 Binary files a/services/nillion-interactor/binaries/double.nada.bin and b/services/nillion-interactor/binaries/double.nada.bin differ diff --git a/services/nillion-interactor/binaries/double.nada.json b/services/nillion-interactor/binaries/double.nada.json index 5d9930b..890060c 100644 --- a/services/nillion-interactor/binaries/double.nada.json +++ b/services/nillion-interactor/binaries/double.nada.json @@ -1 +1 @@ -{"functions":[],"parties":[{"name":"Party1","source_ref_index":3}],"inputs":[{"type":"SecretInteger","party":"Party1","name":"foo","doc":"","source_ref_index":1}],"literals":[],"outputs":[{"name":"my_output","operation_id":4347741072,"party":"Party1","type":"SecretInteger","source_ref_index":2}],"operations":{"4347741072":{"Addition":{"id":4347741072,"left":4347690704,"right":4347690704,"type":"SecretInteger","source_ref_index":0}},"4347690704":{"InputReference":{"id":4347690704,"refers_to":"foo","type":"SecretInteger","source_ref_index":1}}},"source_files":{"double.py":"from nada_dsl import *\n\ndef nada_main():\n party1 = Party(name=\"Party1\")\n a = SecretInteger(Input(name=\"foo\", party=party1))\n\n result = a + a\n\n return [Output(result, \"my_output\", party1)]\n"},"source_refs":[{"file":"double.py","lineno":7,"offset":131,"length":18},{"file":"double.py","lineno":5,"offset":75,"length":54},{"file":"double.py","lineno":9,"offset":0,"length":0},{"file":"double.py","lineno":4,"offset":41,"length":33}]} \ No newline at end of file +{"functions":[],"parties":[{"name":"Party1","source_ref_index":3}],"inputs":[{"type":"SecretInteger","party":"Party1","name":"foo","doc":"","source_ref_index":1}],"literals":[],"outputs":[{"name":"my_output","operation_id":2,"party":"Party1","type":"SecretInteger","source_ref_index":2}],"operations":{"1":{"InputReference":{"id":1,"refers_to":"foo","type":"SecretInteger","source_ref_index":1}},"2":{"Addition":{"id":2,"left":1,"right":1,"type":"SecretInteger","source_ref_index":0}}},"source_files":{"double.py":"from nada_dsl import *\n\ndef nada_main():\n party1 = Party(name=\"Party1\")\n a = SecretInteger(Input(name=\"foo\", party=party1))\n\n result = a + a\n\n return [Output(result, \"my_output\", party1)]\n"},"source_refs":[{"file":"scalar_types.py","lineno":136,"offset":0,"length":0},{"file":"double.py","lineno":5,"offset":75,"length":54},{"file":"double.py","lineno":9,"offset":0,"length":0},{"file":"double.py","lineno":4,"offset":41,"length":33}]} \ No newline at end of file diff --git a/services/nillion-interactor/binaries/muscle-perform.nada.bin b/services/nillion-interactor/binaries/muscle-perform.nada.bin index 3af350d..c01bcaa 100644 Binary files a/services/nillion-interactor/binaries/muscle-perform.nada.bin and b/services/nillion-interactor/binaries/muscle-perform.nada.bin differ diff --git a/services/nillion-interactor/binaries/muscle-perform.nada.json b/services/nillion-interactor/binaries/muscle-perform.nada.json index 90edf68..5cf8040 100644 --- a/services/nillion-interactor/binaries/muscle-perform.nada.json +++ b/services/nillion-interactor/binaries/muscle-perform.nada.json @@ -1 +1 @@ -{"functions":[],"parties":[{"name":"Party1","source_ref_index":10}],"inputs":[{"type":"SecretInteger","party":"Party1","name":"genotype1","doc":"","source_ref_index":4},{"type":"SecretInteger","party":"Party1","name":"snp1","doc":"","source_ref_index":7}],"literals":[{"name":"0420609fa1d35394f41049df03ef341f","value":"0","type":"Integer"},{"name":"10d33944d37d5b1b833be6fd73d3033c","value":"1","type":"Integer"},{"name":"86e63315b115f2a1eb1d7fc854e4c36f","value":"9","type":"Integer"},{"name":"3bf3aca3a9762f07ea27308c85649001","value":"11","type":"Integer"},{"name":"be9dc3499e38754968f0ed1e2d88d815","value":"2","type":"Integer"}],"outputs":[{"name":"Result","operation_id":4372700816,"party":"Party1","type":"Integer","source_ref_index":9}],"operations":{"4372695760":{"IfElse":{"id":4372695760,"this":4372694928,"arg_0":4372695312,"arg_1":4372695568,"type":"SecretInteger","source_ref_index":6}},"4372696400":{"Not":{"id":4372696400,"this":4372700822,"type":"SecretBoolean","source_ref_index":3}},"4372697488":{"IfElse":{"id":4372697488,"this":4372696656,"arg_0":4372697040,"arg_1":4372697296,"type":"SecretInteger","source_ref_index":3}},"4372700432":{"LiteralReference":{"id":4372700432,"refers_to":"0420609fa1d35394f41049df03ef341f","type":"Integer","source_ref_index":1}},"4372697040":{"LiteralReference":{"id":4372697040,"refers_to":"10d33944d37d5b1b833be6fd73d3033c","type":"Integer","source_ref_index":3}},"4372696016":{"LiteralReference":{"id":4372696016,"refers_to":"0420609fa1d35394f41049df03ef341f","type":"Integer","source_ref_index":6}},"4372694352":{"LiteralReference":{"id":4372694352,"refers_to":"3bf3aca3a9762f07ea27308c85649001","type":"Integer","source_ref_index":8}},"4372700112":{"IfElse":{"id":4372700112,"this":4372699216,"arg_0":4372699664,"arg_1":4372699920,"type":"SecretInteger","source_ref_index":1}},"4372695312":{"LiteralReference":{"id":4372695312,"refers_to":"10d33944d37d5b1b833be6fd73d3033c","type":"Integer","source_ref_index":6}},"4372698768":{"Not":{"id":4372698768,"this":4372700821,"type":"SecretBoolean","source_ref_index":1}},"4372697296":{"LiteralReference":{"id":4372697296,"refers_to":"0420609fa1d35394f41049df03ef341f","type":"Integer","source_ref_index":3}},"4372695568":{"LiteralReference":{"id":4372695568,"refers_to":"0420609fa1d35394f41049df03ef341f","type":"Integer","source_ref_index":6}},"4372694736":{"Not":{"id":4372694736,"this":4372700820,"type":"SecretBoolean","source_ref_index":6}},"4372700816":{"Reveal":{"id":4372700816,"this":4372700624,"type":"Integer","source_ref_index":0}},"4372700819":{"LessThan":{"id":4372700819,"left":4372694352,"right":4372643472,"type":"SecretBoolean","source_ref_index":6}},"4372694928":{"Not":{"id":4372694928,"this":4372700819,"type":"SecretBoolean","source_ref_index":6}},"4372698000":{"IfElse":{"id":4372698000,"this":4372696400,"arg_0":4372697488,"arg_1":4372697808,"type":"SecretInteger","source_ref_index":3}},"4372700817":{"LessThan":{"id":4372700817,"left":4372699088,"right":4372698192,"type":"SecretBoolean","source_ref_index":1}},"4372643472":{"InputReference":{"id":4372643472,"refers_to":"snp1","type":"SecretInteger","source_ref_index":7}},"4369825936":{"InputReference":{"id":4369825936,"refers_to":"genotype1","type":"SecretInteger","source_ref_index":4}},"4372698576":{"LiteralReference":{"id":4372698576,"refers_to":"be9dc3499e38754968f0ed1e2d88d815","type":"Integer","source_ref_index":1}},"4372700818":{"LessThan":{"id":4372700818,"left":4372694480,"right":4369825936,"type":"SecretBoolean","source_ref_index":3}},"4372700820":{"LessThan":{"id":4372700820,"left":4372643472,"right":4372694352,"type":"SecretBoolean","source_ref_index":6}},"4372696656":{"Not":{"id":4372696656,"this":4372700818,"type":"SecretBoolean","source_ref_index":3}},"4372699216":{"Not":{"id":4372699216,"this":4372700817,"type":"SecretBoolean","source_ref_index":1}},"4372694480":{"LiteralReference":{"id":4372694480,"refers_to":"86e63315b115f2a1eb1d7fc854e4c36f","type":"Integer","source_ref_index":5}},"4372700624":{"IfElse":{"id":4372700624,"this":4372698768,"arg_0":4372700112,"arg_1":4372700432,"type":"SecretInteger","source_ref_index":1}},"4372699664":{"LiteralReference":{"id":4372699664,"refers_to":"10d33944d37d5b1b833be6fd73d3033c","type":"Integer","source_ref_index":1}},"4372699920":{"LiteralReference":{"id":4372699920,"refers_to":"0420609fa1d35394f41049df03ef341f","type":"Integer","source_ref_index":1}},"4372697808":{"LiteralReference":{"id":4372697808,"refers_to":"0420609fa1d35394f41049df03ef341f","type":"Integer","source_ref_index":3}},"4372698192":{"Addition":{"id":4372698192,"left":4372696208,"right":4372698000,"type":"SecretInteger","source_ref_index":2}},"4372696208":{"IfElse":{"id":4372696208,"this":4372694736,"arg_0":4372695760,"arg_1":4372696016,"type":"SecretInteger","source_ref_index":6}},"4372699088":{"LiteralReference":{"id":4372699088,"refers_to":"be9dc3499e38754968f0ed1e2d88d815","type":"Integer","source_ref_index":1}},"4372700822":{"LessThan":{"id":4372700822,"left":4369825936,"right":4372694480,"type":"SecretBoolean","source_ref_index":3}},"4372700821":{"LessThan":{"id":4372700821,"left":4372698192,"right":4372698576,"type":"SecretBoolean","source_ref_index":1}}},"source_files":{"muscle-perform.py":"from nada_dsl import *\n\n\n# Checks based on SNP rs1815739 whether someone is a sprinter or an endurance athelete\n# Genotype TT indicates endurance athlete\n# We arbitrarily assume sprinter otherwise\n# This program returns 0 if sprinter, 1 if endurance athelete\ndef nada_main():\n\n party1 = Party(name=\"Party1\")\n\n\n snp1 = SecretInteger(Input(name=\"snp1\", party=party1))\n genotype1 = SecretInteger(Input(name=\"genotype1\", party=party1))\n\n target_snp_1 = Integer(11)\n target_genotype_1 = Integer(9)\n\n eq1 = (snp1 >= target_snp_1).if_else((target_snp_1 >= snp1).if_else(Integer(1), Integer(0)), Integer(0))\n eq2 = (genotype1 >= target_genotype_1).if_else((target_genotype_1 >= genotype1).if_else(Integer(1), Integer(0)), Integer(0))\n\n\n total = eq1 + eq2\n\n is_successful = (total >= Integer(2)).if_else((Integer(2) >= total).if_else(Integer(1), Integer(0)), Integer(0))\n\n result = is_successful.reveal()\n\n return [Output(result, \"Result\", party1)]\n"},"source_refs":[{"file":"muscle-perform.py","lineno":27,"offset":890,"length":35},{"file":"muscle-perform.py","lineno":25,"offset":772,"length":116},{"file":"muscle-perform.py","lineno":23,"offset":749,"length":21},{"file":"muscle-perform.py","lineno":20,"offset":618,"length":128},{"file":"muscle-perform.py","lineno":14,"offset":372,"length":68},{"file":"muscle-perform.py","lineno":17,"offset":473,"length":34},{"file":"muscle-perform.py","lineno":19,"offset":509,"length":108},{"file":"muscle-perform.py","lineno":13,"offset":313,"length":58},{"file":"muscle-perform.py","lineno":16,"offset":442,"length":30},{"file":"muscle-perform.py","lineno":29,"offset":0,"length":0},{"file":"muscle-perform.py","lineno":10,"offset":277,"length":33}]} \ No newline at end of file +{"functions":[],"parties":[{"name":"Party1","source_ref_index":10}],"inputs":[{"type":"SecretInteger","party":"Party1","name":"genotype1","doc":"","source_ref_index":4},{"type":"SecretInteger","party":"Party1","name":"snp1","doc":"","source_ref_index":7}],"literals":[{"name":"3","value":"0","type":"Integer"},{"name":"2","value":"1","type":"Integer"},{"name":"1","value":"9","type":"Integer"},{"name":"0","value":"11","type":"Integer"},{"name":"4","value":"2","type":"Integer"}],"outputs":[{"name":"Result","operation_id":28,"party":"Party1","type":"SecretInteger","source_ref_index":9}],"operations":{"1":{"InputReference":{"id":1,"refers_to":"snp1","type":"SecretInteger","source_ref_index":7}},"2":{"InputReference":{"id":2,"refers_to":"genotype1","type":"SecretInteger","source_ref_index":4}},"3":{"LiteralReference":{"id":3,"refers_to":"0","type":"Integer","source_ref_index":8}},"4":{"LiteralReference":{"id":4,"refers_to":"1","type":"Integer","source_ref_index":5}},"5":{"Not":{"id":5,"this":34,"type":"SecretBoolean","source_ref_index":1}},"6":{"Not":{"id":6,"this":33,"type":"SecretBoolean","source_ref_index":1}},"7":{"LiteralReference":{"id":7,"refers_to":"2","type":"Integer","source_ref_index":6}},"8":{"LiteralReference":{"id":8,"refers_to":"3","type":"Integer","source_ref_index":6}},"9":{"IfElse":{"id":9,"this":6,"arg_0":7,"arg_1":8,"type":"SecretInteger","source_ref_index":6}},"10":{"LiteralReference":{"id":10,"refers_to":"3","type":"Integer","source_ref_index":6}},"11":{"IfElse":{"id":11,"this":5,"arg_0":9,"arg_1":10,"type":"SecretInteger","source_ref_index":6}},"12":{"Not":{"id":12,"this":32,"type":"SecretBoolean","source_ref_index":1}},"13":{"Not":{"id":13,"this":31,"type":"SecretBoolean","source_ref_index":1}},"14":{"LiteralReference":{"id":14,"refers_to":"2","type":"Integer","source_ref_index":3}},"15":{"LiteralReference":{"id":15,"refers_to":"3","type":"Integer","source_ref_index":3}},"16":{"IfElse":{"id":16,"this":13,"arg_0":14,"arg_1":15,"type":"SecretInteger","source_ref_index":3}},"17":{"LiteralReference":{"id":17,"refers_to":"3","type":"Integer","source_ref_index":3}},"18":{"IfElse":{"id":18,"this":12,"arg_0":16,"arg_1":17,"type":"SecretInteger","source_ref_index":3}},"19":{"Addition":{"id":19,"left":11,"right":18,"type":"SecretInteger","source_ref_index":2}},"20":{"LiteralReference":{"id":20,"refers_to":"4","type":"Integer","source_ref_index":0}},"21":{"Not":{"id":21,"this":30,"type":"SecretBoolean","source_ref_index":1}},"22":{"LiteralReference":{"id":22,"refers_to":"4","type":"Integer","source_ref_index":0}},"23":{"Not":{"id":23,"this":29,"type":"SecretBoolean","source_ref_index":1}},"24":{"LiteralReference":{"id":24,"refers_to":"2","type":"Integer","source_ref_index":0}},"25":{"LiteralReference":{"id":25,"refers_to":"3","type":"Integer","source_ref_index":0}},"26":{"IfElse":{"id":26,"this":23,"arg_0":24,"arg_1":25,"type":"SecretInteger","source_ref_index":0}},"27":{"LiteralReference":{"id":27,"refers_to":"3","type":"Integer","source_ref_index":0}},"28":{"IfElse":{"id":28,"this":21,"arg_0":26,"arg_1":27,"type":"SecretInteger","source_ref_index":0}},"29":{"LessThan":{"id":29,"left":22,"right":19,"type":"SecretBoolean","source_ref_index":1}},"30":{"LessThan":{"id":30,"left":19,"right":20,"type":"SecretBoolean","source_ref_index":1}},"31":{"LessThan":{"id":31,"left":4,"right":2,"type":"SecretBoolean","source_ref_index":1}},"32":{"LessThan":{"id":32,"left":2,"right":4,"type":"SecretBoolean","source_ref_index":1}},"33":{"LessThan":{"id":33,"left":3,"right":1,"type":"SecretBoolean","source_ref_index":1}},"34":{"LessThan":{"id":34,"left":1,"right":3,"type":"SecretBoolean","source_ref_index":1}}},"source_files":{"muscle-perform.py":"from nada_dsl import *\n\n\n# Checks based on SNP rs1815739 whether someone is a sprinter or an endurance athelete\n# Genotype TT indicates endurance athlete\n# We arbitrarily assume sprinter otherwise\n# This program returns 0 if sprinter, 1 if endurance athelete\ndef nada_main():\n\n party1 = Party(name=\"Party1\")\n\n\n snp1 = SecretInteger(Input(name=\"snp1\", party=party1))\n genotype1 = SecretInteger(Input(name=\"genotype1\", party=party1))\n\n target_snp_1 = Integer(11)\n target_genotype_1 = Integer(9)\n\n eq1 = (snp1 >= target_snp_1).if_else((target_snp_1 >= snp1).if_else(Integer(1), Integer(0)), Integer(0))\n eq2 = (genotype1 >= target_genotype_1).if_else((target_genotype_1 >= genotype1).if_else(Integer(1), Integer(0)), Integer(0))\n\n\n total = eq1 + eq2\n\n is_successful = (total >= Integer(2)).if_else((Integer(2) >= total).if_else(Integer(1), Integer(0)), Integer(0))\n\n result = is_successful\n\n return [Output(result, \"Result\", party1)]\n"},"source_refs":[{"file":"muscle-perform.py","lineno":25,"offset":772,"length":116},{"file":"scalar_types.py","lineno":200,"offset":0,"length":0},{"file":"scalar_types.py","lineno":136,"offset":0,"length":0},{"file":"muscle-perform.py","lineno":20,"offset":618,"length":128},{"file":"muscle-perform.py","lineno":14,"offset":372,"length":68},{"file":"muscle-perform.py","lineno":17,"offset":473,"length":34},{"file":"muscle-perform.py","lineno":19,"offset":509,"length":108},{"file":"muscle-perform.py","lineno":13,"offset":313,"length":58},{"file":"muscle-perform.py","lineno":16,"offset":442,"length":30},{"file":"muscle-perform.py","lineno":29,"offset":0,"length":0},{"file":"muscle-perform.py","lineno":10,"offset":277,"length":33}]} \ No newline at end of file diff --git a/services/nillion-interactor/binaries/thrombosis.nada.bin b/services/nillion-interactor/binaries/thrombosis.nada.bin index 2ece541..a720ff1 100644 Binary files a/services/nillion-interactor/binaries/thrombosis.nada.bin and b/services/nillion-interactor/binaries/thrombosis.nada.bin differ diff --git a/services/nillion-interactor/binaries/thrombosis.nada.json b/services/nillion-interactor/binaries/thrombosis.nada.json index 156594a..90e352b 100644 --- a/services/nillion-interactor/binaries/thrombosis.nada.json +++ b/services/nillion-interactor/binaries/thrombosis.nada.json @@ -1 +1 @@ -{"functions":[],"parties":[{"name":"Party1","source_ref_index":10}],"inputs":[{"type":"SecretInteger","party":"Party1","name":"genotype","doc":"","source_ref_index":4},{"type":"SecretInteger","party":"Party1","name":"snp","doc":"","source_ref_index":7}],"literals":[{"name":"0420609fa1d35394f41049df03ef341f","value":"0","type":"Integer"},{"name":"10d33944d37d5b1b833be6fd73d3033c","value":"1","type":"Integer"},{"name":"95f937652c869546ae950ce422fddbae","value":"7","type":"Integer"},{"name":"2219253adcecfae08b67c9c486fce6f2","value":"12","type":"Integer"},{"name":"be9dc3499e38754968f0ed1e2d88d815","value":"2","type":"Integer"}],"outputs":[{"name":"Result","operation_id":4372391568,"party":"Party1","type":"Integer","source_ref_index":9}],"operations":{"4372386064":{"Not":{"id":4372386064,"this":4372391574,"type":"SecretBoolean","source_ref_index":3}},"4372391572":{"LessThan":{"id":4372391572,"left":4372332240,"right":4372383440,"type":"SecretBoolean","source_ref_index":6}},"4372387920":{"IfElse":{"id":4372387920,"this":4372386064,"arg_0":4372387280,"arg_1":4372387792,"type":"SecretInteger","source_ref_index":3}},"4372386384":{"Not":{"id":4372386384,"this":4372391573,"type":"SecretBoolean","source_ref_index":3}},"4372385552":{"LiteralReference":{"id":4372385552,"refers_to":"0420609fa1d35394f41049df03ef341f","type":"Integer","source_ref_index":6}},"4372391571":{"LessThan":{"id":4372391571,"left":4372389392,"right":4372388304,"type":"SecretBoolean","source_ref_index":1}},"4372391573":{"LessThan":{"id":4372391573,"left":4372383696,"right":4372382800,"type":"SecretBoolean","source_ref_index":3}},"4372332240":{"InputReference":{"id":4372332240,"refers_to":"snp","type":"SecretInteger","source_ref_index":7}},"4372387792":{"LiteralReference":{"id":4372387792,"refers_to":"0420609fa1d35394f41049df03ef341f","type":"Integer","source_ref_index":3}},"4372387280":{"IfElse":{"id":4372387280,"this":4372386384,"arg_0":4372386832,"arg_1":4372387152,"type":"SecretInteger","source_ref_index":3}},"4372384656":{"LiteralReference":{"id":4372384656,"refers_to":"10d33944d37d5b1b833be6fd73d3033c","type":"Integer","source_ref_index":6}},"4372383440":{"LiteralReference":{"id":4372383440,"refers_to":"2219253adcecfae08b67c9c486fce6f2","type":"Integer","source_ref_index":8}},"4372382800":{"InputReference":{"id":4372382800,"refers_to":"genotype","type":"SecretInteger","source_ref_index":4}},"4372383824":{"Not":{"id":4372383824,"this":4372391572,"type":"SecretBoolean","source_ref_index":6}},"4372388304":{"Addition":{"id":4372388304,"left":4372385680,"right":4372387920,"type":"SecretInteger","source_ref_index":2}},"4372391056":{"LiteralReference":{"id":4372391056,"refers_to":"0420609fa1d35394f41049df03ef341f","type":"Integer","source_ref_index":1}},"4372390416":{"LiteralReference":{"id":4372390416,"refers_to":"0420609fa1d35394f41049df03ef341f","type":"Integer","source_ref_index":1}},"4372386832":{"LiteralReference":{"id":4372386832,"refers_to":"10d33944d37d5b1b833be6fd73d3033c","type":"Integer","source_ref_index":3}},"4372389648":{"Not":{"id":4372389648,"this":4372391571,"type":"SecretBoolean","source_ref_index":1}},"4372390544":{"IfElse":{"id":4372390544,"this":4372389648,"arg_0":4372390096,"arg_1":4372390416,"type":"SecretInteger","source_ref_index":1}},"4372388880":{"Not":{"id":4372388880,"this":4372391570,"type":"SecretBoolean","source_ref_index":1}},"4372388752":{"LiteralReference":{"id":4372388752,"refers_to":"be9dc3499e38754968f0ed1e2d88d815","type":"Integer","source_ref_index":1}},"4372384208":{"Not":{"id":4372384208,"this":4372391569,"type":"SecretBoolean","source_ref_index":6}},"4372384976":{"LiteralReference":{"id":4372384976,"refers_to":"0420609fa1d35394f41049df03ef341f","type":"Integer","source_ref_index":6}},"4372391569":{"LessThan":{"id":4372391569,"left":4372383440,"right":4372332240,"type":"SecretBoolean","source_ref_index":6}},"4372391574":{"LessThan":{"id":4372391574,"left":4372382800,"right":4372383696,"type":"SecretBoolean","source_ref_index":3}},"4372391568":{"Reveal":{"id":4372391568,"this":4372391184,"type":"Integer","source_ref_index":0}},"4372387152":{"LiteralReference":{"id":4372387152,"refers_to":"0420609fa1d35394f41049df03ef341f","type":"Integer","source_ref_index":3}},"4372383696":{"LiteralReference":{"id":4372383696,"refers_to":"95f937652c869546ae950ce422fddbae","type":"Integer","source_ref_index":5}},"4372389392":{"LiteralReference":{"id":4372389392,"refers_to":"be9dc3499e38754968f0ed1e2d88d815","type":"Integer","source_ref_index":1}},"4372391570":{"LessThan":{"id":4372391570,"left":4372388304,"right":4372388752,"type":"SecretBoolean","source_ref_index":1}},"4372385104":{"IfElse":{"id":4372385104,"this":4372384208,"arg_0":4372384656,"arg_1":4372384976,"type":"SecretInteger","source_ref_index":6}},"4372385680":{"IfElse":{"id":4372385680,"this":4372383824,"arg_0":4372385104,"arg_1":4372385552,"type":"SecretInteger","source_ref_index":6}},"4372391184":{"IfElse":{"id":4372391184,"this":4372388880,"arg_0":4372390544,"arg_1":4372391056,"type":"SecretInteger","source_ref_index":1}},"4372390096":{"LiteralReference":{"id":4372390096,"refers_to":"10d33944d37d5b1b833be6fd73d3033c","type":"Integer","source_ref_index":1}}},"source_files":{"thrombosis.py":"from nada_dsl import *\n\n# Checks based on SNP rs6025 whether someone has risk for thrombosis\n# Genotype GG indicates normal risk of thrombosis\n# We arbitrarily assume elevated risk otherwise\n# This program returns 0 if normal risk, 1 if elevated risk\ndef nada_main():\n party1 = Party(name=\"Party1\")\n snp = SecretInteger(Input(name=\"snp\", party=party1))\n genotype = SecretInteger(Input(name=\"genotype\", party=party1))\n\n target_snp = Integer(12)\n target_genotype = Integer(7)\n\n eq1 = (snp >= target_snp).if_else((target_snp >= snp).if_else(Integer(1), Integer(0)), Integer(0))\n eq2 = (genotype >= target_genotype).if_else((target_genotype >= genotype).if_else(Integer(1), Integer(0)), Integer(0))\n total = eq1 + eq2\n\n isSuccess = (total >= Integer(2)).if_else((Integer(2) >= total).if_else(Integer(1), Integer(0)), Integer(0))\n result = isSuccess.reveal()\n\n return [Output(result, \"Result\", party1)]\n"},"source_refs":[{"file":"thrombosis.py","lineno":20,"offset":852,"length":31},{"file":"thrombosis.py","lineno":19,"offset":739,"length":112},{"file":"thrombosis.py","lineno":17,"offset":716,"length":21},{"file":"thrombosis.py","lineno":16,"offset":593,"length":122},{"file":"thrombosis.py","lineno":10,"offset":359,"length":66},{"file":"thrombosis.py","lineno":13,"offset":456,"length":32},{"file":"thrombosis.py","lineno":15,"offset":490,"length":102},{"file":"thrombosis.py","lineno":9,"offset":302,"length":56},{"file":"thrombosis.py","lineno":12,"offset":427,"length":28},{"file":"thrombosis.py","lineno":22,"offset":0,"length":0},{"file":"thrombosis.py","lineno":8,"offset":268,"length":33}]} \ No newline at end of file +{"functions":[],"parties":[{"name":"Party1","source_ref_index":10}],"inputs":[{"type":"SecretInteger","party":"Party1","name":"genotype","doc":"","source_ref_index":4},{"type":"SecretInteger","party":"Party1","name":"snp","doc":"","source_ref_index":7}],"literals":[{"name":"3","value":"0","type":"Integer"},{"name":"2","value":"1","type":"Integer"},{"name":"1","value":"7","type":"Integer"},{"name":"0","value":"12","type":"Integer"},{"name":"4","value":"2","type":"Integer"}],"outputs":[{"name":"Result","operation_id":28,"party":"Party1","type":"SecretInteger","source_ref_index":9}],"operations":{"1":{"InputReference":{"id":1,"refers_to":"snp","type":"SecretInteger","source_ref_index":7}},"2":{"InputReference":{"id":2,"refers_to":"genotype","type":"SecretInteger","source_ref_index":4}},"3":{"LiteralReference":{"id":3,"refers_to":"0","type":"Integer","source_ref_index":8}},"4":{"LiteralReference":{"id":4,"refers_to":"1","type":"Integer","source_ref_index":5}},"5":{"Not":{"id":5,"this":34,"type":"SecretBoolean","source_ref_index":1}},"6":{"Not":{"id":6,"this":33,"type":"SecretBoolean","source_ref_index":1}},"7":{"LiteralReference":{"id":7,"refers_to":"2","type":"Integer","source_ref_index":6}},"8":{"LiteralReference":{"id":8,"refers_to":"3","type":"Integer","source_ref_index":6}},"9":{"IfElse":{"id":9,"this":6,"arg_0":7,"arg_1":8,"type":"SecretInteger","source_ref_index":6}},"10":{"LiteralReference":{"id":10,"refers_to":"3","type":"Integer","source_ref_index":6}},"11":{"IfElse":{"id":11,"this":5,"arg_0":9,"arg_1":10,"type":"SecretInteger","source_ref_index":6}},"12":{"Not":{"id":12,"this":32,"type":"SecretBoolean","source_ref_index":1}},"13":{"Not":{"id":13,"this":31,"type":"SecretBoolean","source_ref_index":1}},"14":{"LiteralReference":{"id":14,"refers_to":"2","type":"Integer","source_ref_index":3}},"15":{"LiteralReference":{"id":15,"refers_to":"3","type":"Integer","source_ref_index":3}},"16":{"IfElse":{"id":16,"this":13,"arg_0":14,"arg_1":15,"type":"SecretInteger","source_ref_index":3}},"17":{"LiteralReference":{"id":17,"refers_to":"3","type":"Integer","source_ref_index":3}},"18":{"IfElse":{"id":18,"this":12,"arg_0":16,"arg_1":17,"type":"SecretInteger","source_ref_index":3}},"19":{"Addition":{"id":19,"left":11,"right":18,"type":"SecretInteger","source_ref_index":2}},"20":{"LiteralReference":{"id":20,"refers_to":"4","type":"Integer","source_ref_index":0}},"21":{"Not":{"id":21,"this":30,"type":"SecretBoolean","source_ref_index":1}},"22":{"LiteralReference":{"id":22,"refers_to":"4","type":"Integer","source_ref_index":0}},"23":{"Not":{"id":23,"this":29,"type":"SecretBoolean","source_ref_index":1}},"24":{"LiteralReference":{"id":24,"refers_to":"2","type":"Integer","source_ref_index":0}},"25":{"LiteralReference":{"id":25,"refers_to":"3","type":"Integer","source_ref_index":0}},"26":{"IfElse":{"id":26,"this":23,"arg_0":24,"arg_1":25,"type":"SecretInteger","source_ref_index":0}},"27":{"LiteralReference":{"id":27,"refers_to":"3","type":"Integer","source_ref_index":0}},"28":{"IfElse":{"id":28,"this":21,"arg_0":26,"arg_1":27,"type":"SecretInteger","source_ref_index":0}},"29":{"LessThan":{"id":29,"left":22,"right":19,"type":"SecretBoolean","source_ref_index":1}},"30":{"LessThan":{"id":30,"left":19,"right":20,"type":"SecretBoolean","source_ref_index":1}},"31":{"LessThan":{"id":31,"left":4,"right":2,"type":"SecretBoolean","source_ref_index":1}},"32":{"LessThan":{"id":32,"left":2,"right":4,"type":"SecretBoolean","source_ref_index":1}},"33":{"LessThan":{"id":33,"left":3,"right":1,"type":"SecretBoolean","source_ref_index":1}},"34":{"LessThan":{"id":34,"left":1,"right":3,"type":"SecretBoolean","source_ref_index":1}}},"source_files":{"thrombosis.py":"from nada_dsl import *\n\n# Checks based on SNP rs6025 whether someone has risk for thrombosis\n# Genotype GG indicates normal risk of thrombosis\n# We arbitrarily assume elevated risk otherwise\n# This program returns 0 if normal risk, 1 if elevated risk\ndef nada_main():\n party1 = Party(name=\"Party1\")\n snp = SecretInteger(Input(name=\"snp\", party=party1))\n genotype = SecretInteger(Input(name=\"genotype\", party=party1))\n\n target_snp = Integer(12)\n target_genotype = Integer(7)\n\n eq1 = (snp >= target_snp).if_else((target_snp >= snp).if_else(Integer(1), Integer(0)), Integer(0))\n eq2 = (genotype >= target_genotype).if_else((target_genotype >= genotype).if_else(Integer(1), Integer(0)), Integer(0))\n total = eq1 + eq2\n\n isSuccess = (total >= Integer(2)).if_else((Integer(2) >= total).if_else(Integer(1), Integer(0)), Integer(0))\n result = isSuccess\n\n return [Output(result, \"Result\", party1)]\n"},"source_refs":[{"file":"thrombosis.py","lineno":19,"offset":739,"length":112},{"file":"scalar_types.py","lineno":200,"offset":0,"length":0},{"file":"scalar_types.py","lineno":136,"offset":0,"length":0},{"file":"thrombosis.py","lineno":16,"offset":593,"length":122},{"file":"thrombosis.py","lineno":10,"offset":359,"length":66},{"file":"thrombosis.py","lineno":13,"offset":456,"length":32},{"file":"thrombosis.py","lineno":15,"offset":490,"length":102},{"file":"thrombosis.py","lineno":9,"offset":302,"length":56},{"file":"thrombosis.py","lineno":12,"offset":427,"length":28},{"file":"thrombosis.py","lineno":22,"offset":0,"length":0},{"file":"thrombosis.py","lineno":8,"offset":268,"length":33}]} \ No newline at end of file diff --git a/services/nillion-interactor/compile.sh b/services/nillion-interactor/compile.sh index a8a37ee..ec18f8b 100755 --- a/services/nillion-interactor/compile.sh +++ b/services/nillion-interactor/compile.sh @@ -7,8 +7,8 @@ time pynadac --target-dir binaries --generate-mir-json programs/thrombosis.py echo "Compiling muscle-perform.py" time pynadac --target-dir binaries --generate-mir-json programs/muscle-perform.py -echo "Compiling muscle-perform-array.py" -time pynadac --target-dir binaries --generate-mir-json programs/muscle-perform-array.py +# echo "Compiling muscle-perform-array.py" +# time pynadac --target-dir binaries --generate-mir-json programs/muscle-perform-array.py echo "Compiling double.py" time pynadac --target-dir binaries --generate-mir-json programs/double.py diff --git a/services/nillion-interactor/helpers/nillion_client_helper.py b/services/nillion-interactor/helpers/nillion_client_helper.py index 838817b..f1c6038 100644 --- a/services/nillion-interactor/helpers/nillion_client_helper.py +++ b/services/nillion-interactor/helpers/nillion_client_helper.py @@ -1,15 +1,16 @@ import os -import py_nillion_client as nillion -from helpers.nillion_payments_helper import create_payments_config +from nillion_client import (Network, NilChainPrivateKey, NilChainPayer, PrivateKey, VmClient) -def create_nillion_client(userkey, nodekey): - bootnodes = [os.getenv("NILLION_BOOTNODE_MULTIADDRESS")] - payments_config = create_payments_config() - - return nillion.NillionClient( - nodekey, - bootnodes, - nillion.ConnectionMode.relay(), - userkey, - payments_config, - ) \ No newline at end of file +async def create_nillion_client(priv_key): + network = Network( + chain_grpc_endpoint=os.getenv("NILLION_BLOCKCHAIN_RPC_ENDPOINT"), + chain_id=os.getenv("NILLION_CHAIN_ID"), + nilvm_grpc_endpoint=os.getenv("NILLION_BOOTNODE_MULTIADDRESS"), + ) + wallet_private_key=NilChainPrivateKey(priv_key) + payer = NilChainPayer( + network, + wallet_private_key=wallet_private_key, + gas_limit=10000000, + ) + return await VmClient.create(PrivateKey(priv_key), network, payer) \ No newline at end of file diff --git a/services/nillion-interactor/helpers/nillion_keypath_helper.py b/services/nillion-interactor/helpers/nillion_keypath_helper.py deleted file mode 100644 index 254f1ba..0000000 --- a/services/nillion-interactor/helpers/nillion_keypath_helper.py +++ /dev/null @@ -1,8 +0,0 @@ -import os -import py_nillion_client as nillion - -def getUserKeyFromFile(userkey_filepath): - return nillion.UserKey.from_file(userkey_filepath) - -def getNodeKeyFromFile(nodekey_filepath): - return nillion.NodeKey.from_file(nodekey_filepath) \ No newline at end of file diff --git a/services/nillion-interactor/helpers/nillion_payments_helper.py b/services/nillion-interactor/helpers/nillion_payments_helper.py deleted file mode 100644 index 858801e..0000000 --- a/services/nillion-interactor/helpers/nillion_payments_helper.py +++ /dev/null @@ -1,11 +0,0 @@ -import os -import py_nillion_client as nillion - -def create_payments_config(): - return nillion.PaymentsConfig( - os.getenv("NILLION_BLOCKCHAIN_RPC_ENDPOINT"), - os.getenv("NILLION_WALLET_PRIVATE_KEY"), - int(os.getenv("NILLION_CHAIN_ID")), - os.getenv("NILLION_PAYMENTS_SC_ADDRESS"), - os.getenv("NILLION_BLINDING_FACTORS_MANAGER_SC_ADDRESS"), - ) \ No newline at end of file diff --git a/services/nillion-interactor/node.key b/services/nillion-interactor/node.key deleted file mode 100644 index 3086408..0000000 --- a/services/nillion-interactor/node.key +++ /dev/null @@ -1 +0,0 @@ -23jhTewVfpjnWDH2XjxmtwgcQSG4F34Je6Ryoh7AmV4N4ga6FZwiPpPA6h75MoFgFZ8k434fpBAz3MdoMD82GE7JxgJm6 \ No newline at end of file diff --git a/services/nillion-interactor/programs/muscle-perform.py b/services/nillion-interactor/programs/muscle-perform.py index 25de340..63a7a5f 100644 --- a/services/nillion-interactor/programs/muscle-perform.py +++ b/services/nillion-interactor/programs/muscle-perform.py @@ -24,6 +24,6 @@ def nada_main(): is_successful = (total >= Integer(2)).if_else((Integer(2) >= total).if_else(Integer(1), Integer(0)), Integer(0)) - result = is_successful.reveal() + result = is_successful return [Output(result, "Result", party1)] diff --git a/services/nillion-interactor/programs/thrombosis.py b/services/nillion-interactor/programs/thrombosis.py index 9924b75..b7bad4d 100644 --- a/services/nillion-interactor/programs/thrombosis.py +++ b/services/nillion-interactor/programs/thrombosis.py @@ -17,6 +17,6 @@ def nada_main(): total = eq1 + eq2 isSuccess = (total >= Integer(2)).if_else((Integer(2) >= total).if_else(Integer(1), Integer(0)), Integer(0)) - result = isSuccess.reveal() + result = isSuccess return [Output(result, "Result", party1)] diff --git a/services/nillion-interactor/requirements.txt b/services/nillion-interactor/requirements.txt index 98a46ab..3dff825 100644 --- a/services/nillion-interactor/requirements.txt +++ b/services/nillion-interactor/requirements.txt @@ -1,6 +1,7 @@ python-dotenv==1.0.0 -nada-dsl==0.6.0 -py-nillion-client==0.6.0 pytest-asyncio>=0.23.6 -Flask[async]==3.0.3 -flask-cors==4.0.0 +Quart==0.20.0 +quart-cors==0.8.0 +cryptography>=44.0.0 +nillion-client==0.1.1 +nada-dsl==0.7.2 \ No newline at end of file diff --git a/services/nillion-interactor/user.key b/services/nillion-interactor/user.key deleted file mode 100644 index 6b90760..0000000 --- a/services/nillion-interactor/user.key +++ /dev/null @@ -1 +0,0 @@ -2qNbL7BPz2Nd9F2cDR7DS3xVSwFk3NN5A6YCHdjRUvdn \ No newline at end of file