diff --git a/notebooks/Experimental/enclave_permissions.ipynb b/notebooks/Experimental/enclave_permissions.ipynb new file mode 100644 index 00000000000..7c54cd10eaf --- /dev/null +++ b/notebooks/Experimental/enclave_permissions.ipynb @@ -0,0 +1,1617 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 44, + "id": "804939cd-41cb-4807-8c9f-9cb95832865e", + "metadata": {}, + "outputs": [], + "source": [ + "# stdlib\n", + "from dataclasses import dataclass\n", + "import uuid\n", + "from uuid import UUID as uuid_type\n", + "\n", + "# third party\n", + "from nacl.encoding import HexEncoder\n", + "from nacl.signing import SigningKey" + ] + }, + { + "cell_type": "code", + "execution_count": 80, + "id": "9900ce60-e887-41e8-bf97-cab06ef0bfc4", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 81, + "id": "badcc00f-fbf9-4e7c-9ce8-d35dacbbbd8b", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 69, + "id": "3bbb3296-a8dd-4959-903c-47828ad47414", + "metadata": {}, + "outputs": [], + "source": [ + "@dataclass\n", + "class Domain:\n", + " node_uid: uuid_type" + ] + }, + { + "cell_type": "code", + "execution_count": 120, + "id": "c319b28b-1132-48aa-bff6-99684ba6b592", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 74, + "id": "b34ee89f-dfd8-4f44-b101-bbcf521d52ae", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "Domain(node_uid=UUID('81d4b35d-68ca-47d1-8b24-4e60d77cfeec'))" + ] + }, + "execution_count": 74, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "d1 = Domain(uuid.uuid4())\n", + "d1" + ] + }, + { + "cell_type": "code", + "execution_count": 75, + "id": "995ada7c-b6cc-4f24-8710-07b1a4d18c0e", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "Domain(node_uid=UUID('fd34b9fc-9424-4aa7-ade3-270fa7f25b56'))" + ] + }, + "execution_count": 75, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "d2 = Domain(uuid.uuid4())\n", + "d2" + ] + }, + { + "cell_type": "code", + "execution_count": 76, + "id": "2abffae9-9f2b-436f-8a8b-4bd1e8ac8b3a", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "Domain(node_uid=UUID('fe50eb36-37c9-439b-aec7-276e56092662'))" + ] + }, + "execution_count": 76, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "8c496e1c-a577-4a04-ab90-ef95f6e58cb3", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 26, + "id": "3d976641-94aa-476d-81f7-78ef77a74684", + "metadata": {}, + "outputs": [], + "source": [ + "class NUID:\n", + " def __init__(self, node_uid, obj_uid) -> None:\n", + " self.node_uid = node_uid\n", + " self.obj_uid = obj_uid\n", + "\n", + " @classmethod\n", + " def new(cls) -> NUID:\n", + " return cls(node_uid=uuid.uuid4(), obj_uid=uuid.uuid4())\n", + "\n", + " def __repr__(self) -> str:\n", + " return f\"NUID: {self.obj_uid}@<{self.node_uid}>\"" + ] + }, + { + "cell_type": "code", + "execution_count": 60, + "id": "43fa506a-3ead-45eb-ac27-ea6b12756333", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 60, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "key2 = SigningKey.generate()\n", + "key2" + ] + }, + { + "cell_type": "code", + "execution_count": 39, + "id": "e86a15ac-0da1-4950-9795-0185dfa926d2", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 39, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "key = SigningKey.generate()\n", + "key" + ] + }, + { + "cell_type": "code", + "execution_count": 41, + "id": "e7016558-fa89-4725-ac43-11e7fefa8dc0", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 41, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "verify_key = key.verify_key\n", + "verify_key" + ] + }, + { + "cell_type": "code", + "execution_count": 62, + "id": "9caafc19-2b36-47d1-a154-26463c3a9575", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 62, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "verify_key2 = key2.verify_key\n", + "verify_key2" + ] + }, + { + "cell_type": "code", + "execution_count": 47, + "id": "402bc2ff-fcd2-417a-960f-98444296d3fa", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'ef968740eb671fc17939b5560326f280339c208b962c7965ba4ec3137906f8e8'" + ] + }, + "execution_count": 47, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "verify_key_str = verify_key.encode(encoder=HexEncoder).decode(\"utf-8\")\n", + "verify_key_str" + ] + }, + { + "cell_type": "code", + "execution_count": 63, + "id": "3f9eae64-e9b2-48e3-bfde-af1acf7e8d50", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'8c675358c1b4ac08458cb94544a285351f5a3e255244d9a36338f001603f0662'" + ] + }, + "execution_count": 63, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "verify_key_str2 = verify_key2.encode(encoder=HexEncoder).decode(\"utf-8\")\n", + "verify_key_str2" + ] + }, + { + "cell_type": "code", + "execution_count": 304, + "id": "5ab2c3cd-130a-43e8-8e31-c90b0e8f4f1c", + "metadata": {}, + "outputs": [], + "source": [ + "@dataclass\n", + "class User:\n", + " verify_key: str\n", + "\n", + " def __hash__(self) -> str:\n", + " return hash(self.verify_key)" + ] + }, + { + "cell_type": "code", + "execution_count": 305, + "id": "74ae7318-a7b7-4436-a29a-cf511c3a6c1c", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "User(verify_key='ef968740eb671fc17939b5560326f280339c208b962c7965ba4ec3137906f8e8')" + ] + }, + "execution_count": 305, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "u1 = User(verify_key=verify_key_str)\n", + "u1" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "1a775ea8-686f-43b8-8155-bf01a9f46d1e", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 306, + "id": "e0cf419f-2fbf-4421-9969-8181536b7427", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "User(verify_key='8c675358c1b4ac08458cb94544a285351f5a3e255244d9a36338f001603f0662')" + ] + }, + "execution_count": 306, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "u2 = User(verify_key=verify_key_str2)\n", + "u2" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "5eb77d30-9ebc-4398-a81c-0b6e2c7df3f3", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 307, + "id": "903a73ae-16d1-498a-ba41-b1a72ca6343a", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "NUID: a11a5048-099a-4597-bda3-a1bd0f4d53ed@<81d4b35d-68ca-47d1-8b24-4e60d77cfeec>" + ] + }, + "execution_count": 307, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "data_nuid = NUID(d1.node_uid, uuid.uuid4())\n", + "data_nuid" + ] + }, + { + "cell_type": "code", + "execution_count": 308, + "id": "ce5bce2d-8e29-4288-ad13-a7ba740fd68d", + "metadata": {}, + "outputs": [], + "source": [ + "@dataclass\n", + "class SyftObject:\n", + " id: NUID\n", + " value: int" + ] + }, + { + "cell_type": "code", + "execution_count": 309, + "id": "b578c32b-09d6-40c6-a8ea-cef06a8a3f91", + "metadata": {}, + "outputs": [], + "source": [ + "t = SyftObject(id=data_nuid, value=1)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "46baa01c-23e9-44ec-8818-366891430fb1", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 310, + "id": "3965efa4-ee1d-40ea-9ec4-7f5eabf83bd2", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "NUID: b46acc56-4178-41ca-8426-874f968f1254@" + ] + }, + "execution_count": 310, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "model_nuid = NUID(d2.node_uid, uuid.uuid4())\n", + "model_nuid" + ] + }, + { + "cell_type": "code", + "execution_count": 311, + "id": "19a6b246-5d03-49c4-b782-97dcdb6fef6c", + "metadata": {}, + "outputs": [], + "source": [ + "m = SyftObject(id=model_nuid, value=2)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "7a717d75-7d57-4d07-ac28-9f02c117f3f3", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "43bd4658-ca20-448b-a79c-cb1f4deb3fe0", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "54814429-6948-4cff-82b0-ba943a2d18b2", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "d994257a-2b6a-4bdc-892e-42671e3729e0", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "2315a96c-e5d5-45ef-b24d-ab5bb7dd030b", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 312, + "id": "5b68f5cb-de0c-4bef-9d57-803c09f8213e", + "metadata": {}, + "outputs": [], + "source": [ + "store[m.id.obj_uid] = m" + ] + }, + { + "cell_type": "code", + "execution_count": 313, + "id": "b5914583-47e3-40f1-8799-a266ddc883be", + "metadata": {}, + "outputs": [], + "source": [ + "store[t.id.obj_uid] = t" + ] + }, + { + "cell_type": "code", + "execution_count": 314, + "id": "8e660d87-1851-4052-b6d8-9b5149d48d9a", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{UUID('6971d4ec-6b2b-4f36-8c37-ac18eeefcb45'): SyftObject(id=NUID: 6971d4ec-6b2b-4f36-8c37-ac18eeefcb45@<81d4b35d-68ca-47d1-8b24-4e60d77cfeec>, value=1),\n", + " UUID('af69c65b-55b5-4eab-aa4b-c47db9137b46'): SyftObject(id=NUID: af69c65b-55b5-4eab-aa4b-c47db9137b46@, value=2),\n", + " UUID('709cc26a-d7ea-4da6-ba86-f1895b5b4399'): Code(id=UUID('709cc26a-d7ea-4da6-ba86-f1895b5b4399'), func=),\n", + " UUID('b46acc56-4178-41ca-8426-874f968f1254'): SyftObject(id=NUID: b46acc56-4178-41ca-8426-874f968f1254@, value=2),\n", + " UUID('a11a5048-099a-4597-bda3-a1bd0f4d53ed'): SyftObject(id=NUID: a11a5048-099a-4597-bda3-a1bd0f4d53ed@<81d4b35d-68ca-47d1-8b24-4e60d77cfeec>, value=1)}" + ] + }, + "execution_count": 314, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "store" + ] + }, + { + "cell_type": "code", + "execution_count": 315, + "id": "5fdef3ac-305b-418e-aff8-520a45b9a2fd", + "metadata": {}, + "outputs": [ + { + "ename": "TypeError", + "evalue": "'NoneType' object does not support item assignment", + "output_type": "error", + "traceback": [ + "\u001b[0;31m------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[315], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mpermissions\u001b[49m\u001b[43m[\u001b[49m\u001b[43mt\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mid\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mobj_uid\u001b[49m\u001b[43m]\u001b[49m \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mset\u001b[39m()\n", + "\u001b[0;31mTypeError\u001b[0m: 'NoneType' object does not support item assignment" + ] + } + ], + "source": [ + "permissions[t.id.obj_uid] = set()" + ] + }, + { + "cell_type": "code", + "execution_count": 316, + "id": "1d44df50-6a73-4a85-979c-1bb72afe7de7", + "metadata": {}, + "outputs": [ + { + "ename": "TypeError", + "evalue": "'NoneType' object does not support item assignment", + "output_type": "error", + "traceback": [ + "\u001b[0;31m------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[316], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mpermissions\u001b[49m\u001b[43m[\u001b[49m\u001b[43mm\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mid\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mobj_uid\u001b[49m\u001b[43m]\u001b[49m \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mset\u001b[39m()\n", + "\u001b[0;31mTypeError\u001b[0m: 'NoneType' object does not support item assignment" + ] + } + ], + "source": [ + "permissions[m.id.obj_uid] = set()" + ] + }, + { + "cell_type": "code", + "execution_count": 317, + "id": "28eaea79-ac1d-4aa5-8657-71896be8bb98", + "metadata": {}, + "outputs": [], + "source": [ + "permissions" + ] + }, + { + "cell_type": "code", + "execution_count": 318, + "id": "7485d268-4255-475f-a904-df09238953af", + "metadata": {}, + "outputs": [], + "source": [ + "# stdlib\n", + "from enum import Enum" + ] + }, + { + "cell_type": "code", + "execution_count": 319, + "id": "372ad3a1-b15f-4583-b96c-2d16a85346c0", + "metadata": {}, + "outputs": [], + "source": [ + "class ActionPermission(Enum):\n", + " OWNER = 1\n", + " READ = 2\n", + " ALL_READ = 4\n", + " WRITE = 8\n", + " ALL_WRITE = 32\n", + " EXECUTE = 64\n", + " ALL_EXECUTE = 128" + ] + }, + { + "cell_type": "code", + "execution_count": 320, + "id": "18203182-df9f-4b10-9a1e-316935e4d143", + "metadata": {}, + "outputs": [ + { + "ename": "TypeError", + "evalue": "'NoneType' object is not subscriptable", + "output_type": "error", + "traceback": [ + "\u001b[0;31m------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[320], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mpermissions\u001b[49m\u001b[43m[\u001b[49m\u001b[43mt\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mid\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mobj_uid\u001b[49m\u001b[43m]\u001b[49m\u001b[38;5;241m.\u001b[39madd(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mActionPermission\u001b[38;5;241m.\u001b[39mOWNER\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m_\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mu1\u001b[38;5;241m.\u001b[39mverify_key\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m)\n", + "\u001b[0;31mTypeError\u001b[0m: 'NoneType' object is not subscriptable" + ] + } + ], + "source": [ + "permissions[t.id.obj_uid].add(f\"{ActionPermission.OWNER}_{u1.verify_key}\")" + ] + }, + { + "cell_type": "code", + "execution_count": 321, + "id": "c53639a5-b4c7-4de6-8550-f794342e8095", + "metadata": {}, + "outputs": [], + "source": [ + "permissions" + ] + }, + { + "cell_type": "code", + "execution_count": 322, + "id": "eafd9e90-ad6e-4f55-9110-07d89cd53a94", + "metadata": {}, + "outputs": [ + { + "ename": "TypeError", + "evalue": "'NoneType' object is not subscriptable", + "output_type": "error", + "traceback": [ + "\u001b[0;31m------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[322], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mpermissions\u001b[49m\u001b[43m[\u001b[49m\u001b[43mt\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mid\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mobj_uid\u001b[49m\u001b[43m]\u001b[49m\u001b[38;5;241m.\u001b[39madd(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mActionPermission\u001b[38;5;241m.\u001b[39mOWNER\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m_\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mu1\u001b[38;5;241m.\u001b[39mverify_key\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m)\n", + "\u001b[0;31mTypeError\u001b[0m: 'NoneType' object is not subscriptable" + ] + } + ], + "source": [ + "permissions[t.id.obj_uid].add(f\"{ActionPermission.OWNER}_{u1.verify_key}\")" + ] + }, + { + "cell_type": "code", + "execution_count": 323, + "id": "70ebf695-0d80-4bda-93fd-618487f0725b", + "metadata": {}, + "outputs": [], + "source": [ + "# stdlib\n", + "from typing import Callable" + ] + }, + { + "cell_type": "code", + "execution_count": 324, + "id": "ecbda64b-e98f-467e-926c-0b42b5bf9678", + "metadata": {}, + "outputs": [], + "source": [ + "@dataclass\n", + "class Code:\n", + " id: uuid_type\n", + " func: Callable\n", + "\n", + " def __call__(self, *args, **kwargs):\n", + " return self.func(*args, **kwargs)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "da3897de-13cc-41c1-9e44-8bf23cc77895", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "847ca1db-e22a-4796-a5e9-923644436751", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 325, + "id": "20dc4a31-7fa3-4a91-8f98-4dbb1419d93c", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "3" + ] + }, + "execution_count": 325, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "c(t, m)" + ] + }, + { + "cell_type": "code", + "execution_count": 326, + "id": "a8a6c561-3c18-4ff7-8f72-bef95c52e404", + "metadata": {}, + "outputs": [], + "source": [ + "store[c.id] = c" + ] + }, + { + "cell_type": "code", + "execution_count": 327, + "id": "20b8484d-b655-4f4c-b678-93de66822529", + "metadata": {}, + "outputs": [ + { + "ename": "TypeError", + "evalue": "'NoneType' object does not support item assignment", + "output_type": "error", + "traceback": [ + "\u001b[0;31m------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[327], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mpermissions\u001b[49m\u001b[43m[\u001b[49m\u001b[43mc\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mid\u001b[49m\u001b[43m]\u001b[49m \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mset\u001b[39m()\n", + "\u001b[0;31mTypeError\u001b[0m: 'NoneType' object does not support item assignment" + ] + } + ], + "source": [ + "permissions[c.id] = set()" + ] + }, + { + "cell_type": "code", + "execution_count": 328, + "id": "2726cd72-76da-427e-b426-5f68516b03d4", + "metadata": {}, + "outputs": [ + { + "ename": "TypeError", + "evalue": "'NoneType' object is not subscriptable", + "output_type": "error", + "traceback": [ + "\u001b[0;31m------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[328], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mpermissions\u001b[49m\u001b[43m[\u001b[49m\u001b[43mc\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mid\u001b[49m\u001b[43m]\u001b[49m\u001b[38;5;241m.\u001b[39madd(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mActionPermission\u001b[38;5;241m.\u001b[39mOWNER\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m_\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mu1\u001b[38;5;241m.\u001b[39mverify_key\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m 2\u001b[0m permissions[c\u001b[38;5;241m.\u001b[39mid]\u001b[38;5;241m.\u001b[39madd(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mActionPermission\u001b[38;5;241m.\u001b[39mOWNER\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m_\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mu2\u001b[38;5;241m.\u001b[39mverify_key\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m)\n", + "\u001b[0;31mTypeError\u001b[0m: 'NoneType' object is not subscriptable" + ] + } + ], + "source": [ + "permissions[c.id].add(f\"{ActionPermission.OWNER}_{u1.verify_key}\")\n", + "permissions[c.id].add(f\"{ActionPermission.OWNER}_{u2.verify_key}\")" + ] + }, + { + "cell_type": "code", + "execution_count": 329, + "id": "396d19e0-c750-4def-ac83-1b26ab8579e3", + "metadata": {}, + "outputs": [ + { + "ename": "TypeError", + "evalue": "'NoneType' object is not subscriptable", + "output_type": "error", + "traceback": [ + "\u001b[0;31m------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[329], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mpermissions\u001b[49m\u001b[43m[\u001b[49m\u001b[43mm\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mid\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mobj_uid\u001b[49m\u001b[43m]\u001b[49m\u001b[38;5;241m.\u001b[39madd(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mActionPermission\u001b[38;5;241m.\u001b[39mOWNER\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m_\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mu2\u001b[38;5;241m.\u001b[39mverify_key\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m)\n", + "\u001b[0;31mTypeError\u001b[0m: 'NoneType' object is not subscriptable" + ] + } + ], + "source": [ + "permissions[m.id.obj_uid].add(f\"{ActionPermission.OWNER}_{u2.verify_key}\")" + ] + }, + { + "cell_type": "code", + "execution_count": 330, + "id": "79449a32-58ac-4acd-8b3a-abe7dddddd0e", + "metadata": {}, + "outputs": [], + "source": [ + "permissions" + ] + }, + { + "cell_type": "code", + "execution_count": 331, + "id": "ac0b01f4-2809-4464-b9a1-2347f7f95e1a", + "metadata": {}, + "outputs": [], + "source": [ + "permissions" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "db0325e6-6460-455c-ad3c-3da36455fc48", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 332, + "id": "117c968c-e717-4843-9593-9bcef2114dbd", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'\\n- user 1 @ domain 1\\n - result that only they can see\\n - needs READ permission\\n - input to code requires object from user 1 / domain 1\\n - need WRITE permission for the UID of the store location\\n - enclave executes code against data\\n - requires all[n] parties EXECUTE permissions\\n\\n'" + ] + }, + "execution_count": 332, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "\"\"\"\n", + "- user 1 @ domain 1\n", + " - result that only they can see\n", + " - needs READ permission\n", + " - input to code requires object from user 1 / domain 1\n", + " - need WRITE permission for the UID of the store location\n", + " - enclave executes code against data\n", + " - requires all[n] parties EXECUTE permissions\n", + "\n", + "\"\"\"" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "ebd6e8e5-957b-43e9-8f82-e6ccb95c8aa6", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 333, + "id": "f9b72fbc-5c87-4e50-9b50-cd1f88eb2b38", + "metadata": {}, + "outputs": [], + "source": [ + "permissions" + ] + }, + { + "cell_type": "code", + "execution_count": 334, + "id": "43bec9f5-214b-4949-b886-c6c0c4da7adf", + "metadata": {}, + "outputs": [ + { + "ename": "AttributeError", + "evalue": "'NoneType' object has no attribute 'keys'", + "output_type": "error", + "traceback": [ + "\u001b[0;31m------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[334], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m a \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mlist\u001b[39m(\u001b[43mpermissions\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mkeys\u001b[49m())[\u001b[38;5;241m0\u001b[39m]\n\u001b[1;32m 2\u001b[0m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mActionPermission.OWNER_ef968740eb671fc17939b5560326f280339c208b962c7965ba4ec3137906f8e8\u001b[39m\u001b[38;5;124m'\u001b[39m \u001b[38;5;129;01min\u001b[39;00m permissions[a]\n", + "\u001b[0;31mAttributeError\u001b[0m: 'NoneType' object has no attribute 'keys'" + ] + } + ], + "source": [ + "a = list(permissions.keys())[0]\n", + "\"ActionPermission.OWNER_ef968740eb671fc17939b5560326f280339c208b962c7965ba4ec3137906f8e8\" in permissions[\n", + " a\n", + "]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "54e4a938-7195-408d-9188-2a151bbc4eee", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 335, + "id": "681bde1a-d7be-4931-b762-9c05fb0ba9ac", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'ActionPermission.OWNER'" + ] + }, + "execution_count": 335, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "str(ActionPermission.OWNER)" + ] + }, + { + "cell_type": "code", + "execution_count": 336, + "id": "20fb5396-7455-4aad-adb2-7e6629127334", + "metadata": {}, + "outputs": [], + "source": [ + "permissions = None" + ] + }, + { + "cell_type": "code", + "execution_count": 446, + "id": "945e325d-2bab-451a-8267-2f754c0465f1", + "metadata": {}, + "outputs": [], + "source": [ + "@dataclass\n", + "class PermissionChange:\n", + " uid: uuid_type\n", + " store_uid: uuid_type\n", + " permissions: list[str]\n", + " requester: User\n", + " shared_owners_approval: set[str]\n", + " shared_owners: set[User]\n", + "\n", + " def approve(user, enclave):\n", + " return enclave.approve_as_user(uid, user)" + ] + }, + { + "cell_type": "code", + "execution_count": 370, + "id": "1ac39805-b7e9-40ce-9592-76869ef856ad", + "metadata": {}, + "outputs": [], + "source": [ + "@dataclass\n", + "class Message:\n", + " message: str\n", + " linked_change_id: uuid_type | None\n", + " from_user: User\n", + " to_user: User" + ] + }, + { + "cell_type": "code", + "execution_count": 379, + "id": "69259692-82e4-4b52-8e76-7aab5e2c3f3a", + "metadata": {}, + "outputs": [], + "source": [ + "user_lookup = {\n", + " u1.verify_key: u1,\n", + " u2.verify_key: u2,\n", + "}" + ] + }, + { + "cell_type": "code", + "execution_count": 425, + "id": "e5e26fcf-a8f3-46b8-84dd-c2ebdb3d2f7d", + "metadata": {}, + "outputs": [], + "source": [ + "# domain keys versus user keys\n", + "@dataclass\n", + "class Enclave:\n", + " node_uid: uuid_type\n", + " owner_keys: list[uuid_type]\n", + " permissions: dict\n", + " store: dict\n", + " change_queue: dict\n", + " inbox: dict\n", + "\n", + " def obj_or_id(self, obj):\n", + " if isinstance(obj, SyftObject):\n", + " uid = obj.id.obj_uid\n", + " else:\n", + " uid = obj\n", + " return uid\n", + "\n", + " def get_owners(self, obj) -> list[User]:\n", + " uid = self.obj_or_id(obj)\n", + " if not uid in self.permissions.keys():\n", + " return []\n", + "\n", + " owners = []\n", + " if uid in self.permissions.keys():\n", + " for permission in self.permissions[uid]:\n", + " permission_str = str(ActionPermission.OWNER)\n", + " if permission_str in permission:\n", + " user_key = permission.split(\"_\")[-1]\n", + " owners.append(user_lookup[user_key])\n", + " return owners\n", + " \n", + " def has_multiple_owners(self, obj) -> bool:\n", + " uid = self.obj_or_id(obj)\n", + " if not uid in self.permissions.keys():\n", + " return False\n", + " \n", + " if uid in self.permissions.keys():\n", + " count = 0\n", + " for permission in self.permissions[uid]:\n", + " permission_str = str(ActionPermission.OWNER)\n", + " if permission_str in permission:\n", + " count += 1\n", + " return count > 1\n", + " \n", + " def check_owner(self, uid, user) -> bool:\n", + " if not uid in self.permissions.keys():\n", + " return True\n", + " if uid in self.permissions.keys():\n", + " return f\"{ActionPermission.OWNER}_{user.verify_key}\" in self.permissions[uid]\n", + "\n", + " def add_obj(self, obj, as_user):\n", + " uid = obj.id.obj_uid\n", + " if self.check_owner(uid, as_user):\n", + " self.store[uid] = obj\n", + " if uid not in self.permissions:\n", + " self.permissions[uid] = set()\n", + " self.permissions[uid].add(f\"{ActionPermission.OWNER}_{as_user.verify_key}\")\n", + " else:\n", + " print(\"cant add obj already exists or has a owner\")\n", + "\n", + " def add_permission(self, obj, as_user, for_user, permission):\n", + " uid = obj.id.obj_uid\n", + " if self.check_owner(uid, as_user):\n", + " if uid not in self.permissions:\n", + " print(\"here?\")\n", + " self.permissions[uid] = set()\n", + "\n", + " if not self.has_multiple_owners(uid):\n", + " print(\"permission added\")\n", + " self.permissions[uid].add(f\"{ActionPermission.OWNER}_{for_user.verify_key}\")\n", + " else:\n", + " print(\"multiple owners, joint permission requested\")\n", + " pc_uid = uuid.uuid4()\n", + " all_users = []\n", + " owners = self.get_owners(obj)\n", + " for owner in owners:\n", + " all_users.append(owner)\n", + "\n", + " all_keys = set()\n", + " all_keys.add(as_user.verify_key)\n", + "\n", + " pc = PermissionChange(uid=pc_uid, store_uid=uid, permissions=[f\"{ActionPermission.OWNER}_{for_user.verify_key}\"], requester=as_user, shared_owners=all_keys)\n", + " self.change_queue[pc_uid] = pc\n", + " \n", + " for owner in owners:\n", + " if owner is not as_user:\n", + " self.send_message(message=\"Allow change?\", from_user=as_user, to_user=owner, linked_change_id=pc_uid)\n", + " else:\n", + " print(\"cant change obj permissions you arent the owner\")\n", + "\n", + " def has_permission(self, uid, user, permission) -> bool:\n", + " if uid not in self.permissions:\n", + " return False\n", + " return f\"{permission}_{user.verify_key}\" in self.permissions[uid]\n", + "\n", + " def read(self, obj, as_user):\n", + " uid = self.obj_or_id(obj)\n", + " if self.has_permission(uid, as_user, ActionPermission.READ):\n", + " return self.store[uid]\n", + " return \"Error: you dont have permission\"\n", + "\n", + " def send_message(self, message, from_user, to_user, linked_change_id=None):\n", + " msg = Message(message, linked_change_id, from_user, to_user)\n", + " if to_user not in self.inbox:\n", + " self.inbox[to_user] = []\n", + " self.inbox[to_user].append(msg)\n", + "\n", + " def user_inbox(self, to_user):\n", + " if to_user not in self.inbox:\n", + " self.inbox[to_user] = []\n", + "\n", + " return self.inbox[to_user]\n", + "\n", + " def approve_as_user(self, uid, user):\n", + " uid = self.obj_or_id(uid)\n", + " change = change_queue[uid]\n", + " change.shared_owners.add()\n", + " if change" + ] + }, + { + "cell_type": "code", + "execution_count": 426, + "id": "56877c2f-07e8-428b-b3d2-c0fd706ea471", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "Enclave(node_uid=UUID('b5774e95-02ce-4e68-a400-ecaeb57900a1'), owner_keys=['ef968740eb671fc17939b5560326f280339c208b962c7965ba4ec3137906f8e8', '8c675358c1b4ac08458cb94544a285351f5a3e255244d9a36338f001603f0662'], permissions={}, store={}, change_queue={}, inbox={})" + ] + }, + "execution_count": 426, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# domain 1 creates enclave\n", + "e1 = Enclave(\n", + " uuid.uuid4(),\n", + " owner_keys=[u1.verify_key, u2.verify_key],\n", + " permissions={},\n", + " store={},\n", + " change_queue={},\n", + " inbox={},\n", + ")\n", + "e1" + ] + }, + { + "cell_type": "code", + "execution_count": 427, + "id": "b2ee006b-b64e-4b06-918d-301a2406b5ff", + "metadata": {}, + "outputs": [], + "source": [ + "e1.send_message(\"hi\", u1, u2)" + ] + }, + { + "cell_type": "code", + "execution_count": 428, + "id": "d6d5c2be-2b95-4068-89ce-184369277e6b", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "Message(message='hi', linked_change_id=None, from_user=User(verify_key='ef968740eb671fc17939b5560326f280339c208b962c7965ba4ec3137906f8e8'), to_user=User(verify_key='8c675358c1b4ac08458cb94544a285351f5a3e255244d9a36338f001603f0662'))" + ] + }, + "execution_count": 428, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "e1.user_inbox(u2)[0]" + ] + }, + { + "cell_type": "code", + "execution_count": 429, + "id": "932070b0-c835-4475-b0fb-06e4eda9dde4", + "metadata": {}, + "outputs": [], + "source": [ + "e1.add_obj(t, u1)" + ] + }, + { + "cell_type": "code", + "execution_count": 430, + "id": "00f1844f-fb3f-4e52-bcbe-b79b969e0cba", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "(User(verify_key='ef968740eb671fc17939b5560326f280339c208b962c7965ba4ec3137906f8e8'),\n", + " User(verify_key='8c675358c1b4ac08458cb94544a285351f5a3e255244d9a36338f001603f0662'))" + ] + }, + "execution_count": 430, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "u1, u2" + ] + }, + { + "cell_type": "code", + "execution_count": 431, + "id": "778108c5-f32c-45c6-a5f0-74227d85cbe0", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 431, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "e1.has_multiple_owners(t)" + ] + }, + { + "cell_type": "code", + "execution_count": 432, + "id": "168e15d0-9d70-4ea0-8814-f294fe0f880d", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "permission added\n" + ] + } + ], + "source": [ + "e1.add_permission(t, u1, u2, permission=ActionPermission.OWNER)" + ] + }, + { + "cell_type": "code", + "execution_count": 433, + "id": "9c5fedd2-0a28-4186-b3f9-37303e019535", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{UUID('a11a5048-099a-4597-bda3-a1bd0f4d53ed'): {'ActionPermission.OWNER_8c675358c1b4ac08458cb94544a285351f5a3e255244d9a36338f001603f0662',\n", + " 'ActionPermission.OWNER_ef968740eb671fc17939b5560326f280339c208b962c7965ba4ec3137906f8e8'}}" + ] + }, + "execution_count": 433, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "e1.permissions" + ] + }, + { + "cell_type": "code", + "execution_count": 434, + "id": "79acd27e-1960-4adb-89de-32fcf89b4b01", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'Error: you dont have permission'" + ] + }, + "execution_count": 434, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "e1.read(t, u1)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "b563a18e-6daa-4b58-b9c9-af9448e022e1", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 435, + "id": "e63e5dcd-418a-4161-8feb-f62fd2b95913", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{UUID('a11a5048-099a-4597-bda3-a1bd0f4d53ed'): {'ActionPermission.OWNER_8c675358c1b4ac08458cb94544a285351f5a3e255244d9a36338f001603f0662',\n", + " 'ActionPermission.OWNER_ef968740eb671fc17939b5560326f280339c208b962c7965ba4ec3137906f8e8'}}" + ] + }, + "execution_count": 435, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "e1.permissions" + ] + }, + { + "cell_type": "code", + "execution_count": 436, + "id": "f1c8a3df-20a4-4f78-88f0-61203b8d6426", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 436, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "e1.has_multiple_owners(t)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "ea5a70ac-f3ca-42c3-a5bc-51943d92967b", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 437, + "id": "c062e0bf-6457-4afe-a275-6ab3fbb10e81", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "multiple owners, joint permission requested\n" + ] + } + ], + "source": [ + "e1.add_permission(t, u1, u1, permission=ActionPermission.READ)" + ] + }, + { + "cell_type": "code", + "execution_count": 442, + "id": "04226f2e-369b-4ec9-a8e3-e2aaf2d130e6", + "metadata": {}, + "outputs": [], + "source": [ + "request = e1.user_inbox(u2)[0]" + ] + }, + { + "cell_type": "code", + "execution_count": 443, + "id": "9c2705f9-9a46-40d2-bd30-d690756b9403", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "Message(message='hi', linked_change_id=None, from_user=User(verify_key='ef968740eb671fc17939b5560326f280339c208b962c7965ba4ec3137906f8e8'), to_user=User(verify_key='8c675358c1b4ac08458cb94544a285351f5a3e255244d9a36338f001603f0662'))" + ] + }, + "execution_count": 443, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "request" + ] + }, + { + "cell_type": "code", + "execution_count": 444, + "id": "a45bc156-3ffd-46d6-a0ea-2f69aa75aaae", + "metadata": {}, + "outputs": [ + { + "ename": "AttributeError", + "evalue": "'Message' object has no attribute 'approve'", + "output_type": "error", + "traceback": [ + "\u001b[0;31m------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[444], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mrequest\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mapprove\u001b[49m()\n", + "\u001b[0;31mAttributeError\u001b[0m: 'Message' object has no attribute 'approve'" + ] + } + ], + "source": [ + "request.approve(e1)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "3547b9d9-2aa8-4d32-bcb8-d6961fb4eb61", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "4b2707dc-016c-4d0d-ab93-157f0a0039ab", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 441, + "id": "1918e718-fb50-48f6-83a2-8563f3008785", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{UUID('6caf614d-5830-488a-82f7-a9d12ff5b9b2'): PermissionChange(uid=UUID('6caf614d-5830-488a-82f7-a9d12ff5b9b2'), store_uid=UUID('a11a5048-099a-4597-bda3-a1bd0f4d53ed'), permissions=['ActionPermission.OWNER_ef968740eb671fc17939b5560326f280339c208b962c7965ba4ec3137906f8e8'], requester=User(verify_key='ef968740eb671fc17939b5560326f280339c208b962c7965ba4ec3137906f8e8'), shared_owners={'ef968740eb671fc17939b5560326f280339c208b962c7965ba4ec3137906f8e8'})}" + ] + }, + "execution_count": 441, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "e1.change_queue" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "803a978a-70c1-47d4-bf10-1de6164839a5", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 363, + "id": "1c47acc7-ef26-43f5-91b1-ec2df190378e", + "metadata": {}, + "outputs": [], + "source": [ + "a = list(e1.permissions.keys())[0]" + ] + }, + { + "cell_type": "code", + "execution_count": 246, + "id": "01d615fb-c7c2-4cfa-836c-d15a71453f4f", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "ActionPermission.OWNER_ef968740eb671fc17939b5560326f280339c208b962c7965ba4ec3137906f8e8\n", + "ActionPermission.OWNER_8c675358c1b4ac08458cb94544a285351f5a3e255244d9a36338f001603f0662\n" + ] + } + ], + "source": [ + "for a in e1.permissions[a]:\n", + " print(a)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "14df0415-6e8d-4170-b5d0-63b6752f0655", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 124, + "id": "d7a4c3c3-970d-4a99-a72f-6749a92c8cf8", + "metadata": {}, + "outputs": [], + "source": [ + "# domain 1 sends in code\n", + "\n", + "\n", + "def add(a, b) -> int:\n", + " return a.value + b.value\n", + "\n", + "\n", + "c = Code(id=uuid.uuid4(), func=add)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "2087b3bf-96c1-48cb-b9c9-995723c9ce6c", + "metadata": {}, + "outputs": [], + "source": [ + "# domain 1 populates initial permissions\n", + "# domain 2 confirms state agrees with their expectations" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "34f65769-c866-4cab-b1ce-4b4e6c480d15", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "c2ee48c2-b105-434c-8168-fd2dd3836f74", + "metadata": {}, + "outputs": [], + "source": [ + "# domain 2 data scientist tries to send in data" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "09311db6-941c-477e-83ce-4a1e9c51ce10", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "97823b86-bdfa-4696-9156-0bf74811381a", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "d088b3d8-b8b3-4fa2-87fa-52d4f940c327", + "metadata": {}, + "outputs": [], + "source": [ + "# system eval loop\n", + "# get submitted code job\n", + "# check if able to execute\n", + "# run" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "994dcbb0-eae4-402a-b01e-e1c5b1564c1c", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "c9292b0a-812c-4e34-bb52-d6eb076384f7", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.12.2" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +}