|
2 | 2 | "cells": [
|
3 | 3 | {
|
4 | 4 | "cell_type": "markdown",
|
5 |
| - "id": "genetic-shanghai", |
| 5 | + "id": "prostate-merit", |
6 | 6 | "metadata": {},
|
7 | 7 | "source": [
|
8 | 8 | "# Hospital 1\n",
|
|
13 | 13 | {
|
14 | 14 | "cell_type": "code",
|
15 | 15 | "execution_count": 1,
|
16 |
| - "id": "democratic-worthy", |
| 16 | + "id": "sonic-protocol", |
17 | 17 | "metadata": {},
|
18 | 18 | "outputs": [],
|
19 | 19 | "source": [
|
|
26 | 26 | {
|
27 | 27 | "cell_type": "code",
|
28 | 28 | "execution_count": 2,
|
29 |
| - "id": "heard-coach", |
| 29 | + "id": "streaming-digest", |
30 | 30 | "metadata": {},
|
31 | 31 | "outputs": [],
|
32 | 32 | "source": [
|
|
36 | 36 | {
|
37 | 37 | "cell_type": "code",
|
38 | 38 | "execution_count": 3,
|
39 |
| - "id": "alien-checklist", |
| 39 | + "id": "historical-stationery", |
40 | 40 | "metadata": {},
|
41 | 41 | "outputs": [],
|
42 | 42 | "source": [
|
|
56 | 56 | {
|
57 | 57 | "cell_type": "code",
|
58 | 58 | "execution_count": 4,
|
59 |
| - "id": "psychological-wrapping", |
| 59 | + "id": "french-duncan", |
60 | 60 | "metadata": {},
|
61 | 61 | "outputs": [
|
62 | 62 | {
|
|
73 | 73 | },
|
74 | 74 | {
|
75 | 75 | "cell_type": "markdown",
|
76 |
| - "id": "oriented-heart", |
| 76 | + "id": "micro-argument", |
77 | 77 | "metadata": {},
|
78 | 78 | "source": [
|
79 |
| - "## Copy from Researcher" |
| 79 | + "## Get Hospital Credential\n", |
| 80 | + "\n", |
| 81 | + "Copy connection invite from the NHS trust to receive the hospital credential. [NHS Trust Notebooks are here](http://localhost:8888/tree)" |
| 82 | + ] |
| 83 | + }, |
| 84 | + { |
| 85 | + "cell_type": "code", |
| 86 | + "execution_count": null, |
| 87 | + "id": "persistent-listing", |
| 88 | + "metadata": {}, |
| 89 | + "outputs": [], |
| 90 | + "source": [ |
| 91 | + "nhs_invite = {'@type': 'did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/connections/1.0/invitation', '@id': '21aaaf46-7526-448e-a692-1becf370e820', 'label': 'NHS Lothian', 'serviceEndpoint': 'http://172.17.0.1:8020', 'recipientKeys': ['E6rysFzG3TNo3Hz2ZdLqswA92TPgbdm7DUSuYyMzEuPh']}" |
| 92 | + ] |
| 93 | + }, |
| 94 | + { |
| 95 | + "cell_type": "code", |
| 96 | + "execution_count": null, |
| 97 | + "id": "round-folder", |
| 98 | + "metadata": {}, |
| 99 | + "outputs": [], |
| 100 | + "source": [ |
| 101 | + "response =await hospital1.agent_controller.connections.accept_connection(nhs_invite)\n", |
| 102 | + "print(response)" |
| 103 | + ] |
| 104 | + }, |
| 105 | + { |
| 106 | + "cell_type": "markdown", |
| 107 | + "id": "fourth-audit", |
| 108 | + "metadata": {}, |
| 109 | + "source": [ |
| 110 | + "## Optional: Configure Research Authentication Policy\n", |
| 111 | + "\n", |
| 112 | + "This is a proof request that the hospital will automatically challenge the researcher for" |
80 | 113 | ]
|
81 | 114 | },
|
82 | 115 | {
|
83 | 116 | "cell_type": "code",
|
84 | 117 | "execution_count": 5,
|
85 |
| - "id": "another-cosmetic", |
| 118 | + "id": "bulgarian-reasoning", |
86 | 119 | "metadata": {},
|
87 | 120 | "outputs": [],
|
88 | 121 | "source": [
|
89 |
| - "research_invite = {\"@type\": \"did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/connections/1.0/invitation\", \"@id\": \"200407a5-068c-4064-afe2-ef43d31dcd25\", \"serviceEndpoint\": \"http://172.17.0.1:8040\", \"recipientKeys\": [\"7vtM4totFusGjo2H7AYE3dZkxcw2tMWCtHSnwFXqGKmQ\"], \"label\": \"Health Researcher\"}" |
| 122 | + "schema_id = \"FWyJ74b38bCF1QbYF7tWMM:2:Authorised Research:0.0.1\"\n", |
| 123 | + "# cred_def = \"WfntKNFwXMQfgmU9ofbxPM:3:CL:156569:default\"\n", |
| 124 | + "\n", |
| 125 | + "revocation = False\n", |
| 126 | + "exchange_tracing = False\n", |
| 127 | + "\n", |
| 128 | + "#Enable this to ask for attributes to identity a user\n", |
| 129 | + "#TODO - change restriction to schemaId or credentialId\n", |
| 130 | + "\n", |
| 131 | + "req_attrs = [\n", |
| 132 | + " {\"name\": \"scope\", \"restrictions\": [{\"schema_id\": schema_id}]},#, \"cred_def_id\": cred_def}]},\n", |
| 133 | + "]\n", |
| 134 | + "\n", |
| 135 | + "global indy_proof_request\n", |
| 136 | + "indy_proof_request = {\n", |
| 137 | + " \"name\": \"Proof of Hospital\",\n", |
| 138 | + " \"version\": \"1.0\",\n", |
| 139 | + " \"requested_attributes\": {\n", |
| 140 | + " f\"0_{req_attr['name']}_uuid\":\n", |
| 141 | + " req_attr for req_attr in req_attrs\n", |
| 142 | + " },\n", |
| 143 | + " \"requested_predicates\": {\n", |
| 144 | + "# f\"0_{req_pred['name']}_GE_uuid\":\n", |
| 145 | + "# req_pred for req_pred in req_preds\n", |
| 146 | + " },\n", |
| 147 | + "}\n", |
| 148 | + "\n" |
90 | 149 | ]
|
91 | 150 | },
|
92 | 151 | {
|
93 | 152 | "cell_type": "code",
|
94 | 153 | "execution_count": 6,
|
95 |
| - "id": "consolidated-broadcasting", |
| 154 | + "id": "statistical-electricity", |
| 155 | + "metadata": {}, |
| 156 | + "outputs": [], |
| 157 | + "source": [ |
| 158 | + "hospital1.set_authentication_policy(indy_proof_request)" |
| 159 | + ] |
| 160 | + }, |
| 161 | + { |
| 162 | + "cell_type": "markdown", |
| 163 | + "id": "viral-diana", |
| 164 | + "metadata": {}, |
| 165 | + "source": [ |
| 166 | + "## Copy from Researcher" |
| 167 | + ] |
| 168 | + }, |
| 169 | + { |
| 170 | + "cell_type": "code", |
| 171 | + "execution_count": 7, |
| 172 | + "id": "prerequisite-tablet", |
| 173 | + "metadata": {}, |
| 174 | + "outputs": [], |
| 175 | + "source": [ |
| 176 | + "research_invite ={\"@type\": \"did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/connections/1.0/invitation\", \"@id\": \"df76459d-7a65-462e-ae5d-bc1f96a7674f\", \"serviceEndpoint\": \"http://172.17.0.1:8040\", \"label\": \"Health Researcher\", \"recipientKeys\": [\"9QkEnGGQHUNp95rRdsf2GxyGzGniuApqGmoQuXT5UvCC\"]}" |
| 177 | + ] |
| 178 | + }, |
| 179 | + { |
| 180 | + "cell_type": "code", |
| 181 | + "execution_count": 8, |
| 182 | + "id": "accurate-education", |
96 | 183 | "metadata": {},
|
97 | 184 | "outputs": [
|
98 | 185 | {
|
99 | 186 | "name": "stdout",
|
100 | 187 | "output_type": "stream",
|
101 | 188 | "text": [
|
102 | 189 | "Connection Handler Called\n",
|
103 |
| - "Connection 5b995cd7-cdbf-44a5-951d-3ec538feeec9 in State invitation\n", |
| 190 | + "Connection c49d22a1-d306-4278-b955-63c098ffc529 in State invitation\n", |
104 | 191 | "Connection Handler Called\n",
|
105 |
| - "Connection 5b995cd7-cdbf-44a5-951d-3ec538feeec9 in State request\n", |
| 192 | + "Connection c49d22a1-d306-4278-b955-63c098ffc529 in State request\n", |
106 | 193 | "Establishing connection\n",
|
107 | 194 | "Connection Handler Called\n",
|
108 |
| - "Connection 5b995cd7-cdbf-44a5-951d-3ec538feeec9 in State response\n", |
| 195 | + "Connection c49d22a1-d306-4278-b955-63c098ffc529 in State response\n", |
109 | 196 | "Connection Handler Called\n",
|
110 |
| - "Connection 5b995cd7-cdbf-44a5-951d-3ec538feeec9 in State active\n", |
| 197 | + "Connection c49d22a1-d306-4278-b955-63c098ffc529 in State active\n", |
111 | 198 | "Pending connection moved to active. Challenging with auth policy if set\n",
|
112 |
| - "No Auth Policy set\n", |
113 |
| - "Trusted Research Connection Established - 5b995cd7-cdbf-44a5-951d-3ec538feeec9\n", |
114 |
| - "ML Message from 5b995cd7-cdbf-44a5-951d-3ec538feeec9\n", |
| 199 | + "Handle present proof\n", |
| 200 | + "Role verifier, Exchange babbffa0-f5fc-49e3-ac20-c69eee1480ac in state request_sent\n", |
| 201 | + "Handle present proof\n", |
| 202 | + "Role prover, Exchange 62bb0164-6076-40ad-b269-87ec43ccdf85 in state request_received\n", |
| 203 | + "Received Authentication Challenge\n", |
| 204 | + "Credentials [{'cred_info': {'referent': 'NHS Hosptial 1e5044b7-e6c7-4ec6-88ea-49df91e19dd5', 'attrs': {'name': 'Royal Infirmary of Edinburgh'}, 'schema_id': 'BvRKFu1fdzGdJzQcKb8e8p:2:NHS Hosptial:0.0.1', 'cred_def_id': 'RiUq77qGfmFmAHxj1NQcSY:3:CL:156569:default', 'rev_reg_id': None, 'cred_rev_id': None}, 'interval': None, 'presentation_referents': ['0_name_uuid']}, {'cred_info': {'referent': 'NHS Hosptial 434e2d8f-89ad-4a4a-a77e-e6a3b33fac0f', 'attrs': {'name': 'Royal Infirmary of Edinburgh'}, 'schema_id': 'BvRKFu1fdzGdJzQcKb8e8p:2:NHS Hosptial:0.0.1', 'cred_def_id': 'RiUq77qGfmFmAHxj1NQcSY:3:CL:156569:default', 'rev_reg_id': None, 'cred_rev_id': None}, 'interval': None, 'presentation_referents': ['0_name_uuid']}, {'cred_info': {'referent': 'NHS Hosptial 9a85ecc2-936a-451e-bad1-995b7b23b21b', 'attrs': {'name': 'Royal Infirmary of Edinburgh'}, 'schema_id': 'BvRKFu1fdzGdJzQcKb8e8p:2:NHS Hosptial:0.0.1', 'cred_def_id': 'RiUq77qGfmFmAHxj1NQcSY:3:CL:156569:default', 'rev_reg_id': None, 'cred_rev_id': None}, 'interval': None, 'presentation_referents': ['0_name_uuid']}]\n", |
| 205 | + "Revealed Credential {'cred_info': {'referent': 'NHS Hosptial 1e5044b7-e6c7-4ec6-88ea-49df91e19dd5', 'attrs': {'name': 'Royal Infirmary of Edinburgh'}, 'schema_id': 'BvRKFu1fdzGdJzQcKb8e8p:2:NHS Hosptial:0.0.1', 'cred_def_id': 'RiUq77qGfmFmAHxj1NQcSY:3:CL:156569:default', 'rev_reg_id': None, 'cred_rev_id': None}, 'interval': None, 'presentation_referents': ['0_name_uuid']}\n", |
| 206 | + "\n", |
| 207 | + "Generate the proof\n", |
| 208 | + "{'requested_predicates': {}, 'requested_attributes': {'0_name_uuid': {'cred_id': 'NHS Hosptial 1e5044b7-e6c7-4ec6-88ea-49df91e19dd5', 'revealed': True}}, 'self_attested_attributes': {}}\n", |
| 209 | + "\n", |
| 210 | + "XXX\n", |
| 211 | + "{}\n", |
| 212 | + "{'0_name_uuid': {'cred_id': 'NHS Hosptial 1e5044b7-e6c7-4ec6-88ea-49df91e19dd5', 'revealed': True}}\n", |
| 213 | + "{}\n", |
| 214 | + "Handle present proof\n", |
| 215 | + "Role verifier, Exchange babbffa0-f5fc-49e3-ac20-c69eee1480ac in state presentation_received\n", |
| 216 | + "Verifying DataOwner Presentation\n", |
| 217 | + "Handle present proof\n", |
| 218 | + "Role prover, Exchange 62bb0164-6076-40ad-b269-87ec43ccdf85 in state presentation_sent\n", |
| 219 | + "Handle present proof\n", |
| 220 | + "Role prover, Exchange 62bb0164-6076-40ad-b269-87ec43ccdf85 in state presentation_acked\n", |
| 221 | + "Handle present proof\n", |
| 222 | + "Role verifier, Exchange babbffa0-f5fc-49e3-ac20-c69eee1480ac in state verified\n", |
| 223 | + "Trusted Research Connection Established - c49d22a1-d306-4278-b955-63c098ffc529\n", |
| 224 | + "ML Message from c49d22a1-d306-4278-b955-63c098ffc529\n", |
115 | 225 | "Open file\n",
|
116 | 226 | "learning\n",
|
117 | 227 | "untrained_model.pt\n",
|
118 | 228 | "HOSPITAL MODEL LOADED\n",
|
119 | 229 | "HOSPITAL IS TRAINING\n",
|
120 |
| - "loss at epoch 0 : tensor(0.2495)\n" |
| 230 | + "loss at epoch 0 : tensor(0.2652)\n" |
121 | 231 | ]
|
122 | 232 | },
|
123 | 233 | {
|
|
132 | 242 | "name": "stdout",
|
133 | 243 | "output_type": "stream",
|
134 | 244 | "text": [
|
135 |
| - "loss at epoch 5000 : tensor(0.1277)\n", |
136 |
| - "loss at epoch 10000 : tensor(0.1135)\n", |
137 |
| - "loss at epoch 15000 : tensor(0.1081)\n", |
138 |
| - "loss at epoch 20000 : tensor(0.1011)\n", |
139 |
| - "loss at epoch 25000 : tensor(0.0980)\n", |
140 |
| - "loss at epoch 30000 : tensor(0.0955)\n", |
141 |
| - "loss at epoch 35000 : tensor(0.0931)\n", |
142 |
| - "loss at epoch 40000 : tensor(0.0911)\n", |
143 |
| - "loss at epoch 45000 : tensor(0.0894)\n", |
| 245 | + "loss at epoch 5000 : tensor(0.1328)\n", |
| 246 | + "loss at epoch 10000 : tensor(0.1152)\n", |
| 247 | + "loss at epoch 15000 : tensor(0.1115)\n", |
| 248 | + "loss at epoch 20000 : tensor(0.1068)\n", |
| 249 | + "loss at epoch 25000 : tensor(0.1006)\n", |
| 250 | + "loss at epoch 30000 : tensor(0.0973)\n", |
| 251 | + "loss at epoch 35000 : tensor(0.0955)\n", |
| 252 | + "loss at epoch 40000 : tensor(0.0943)\n", |
| 253 | + "loss at epoch 45000 : tensor(0.0934)\n", |
| 254 | + "Learnt \n", |
| 255 | + "Trained file open\n", |
| 256 | + "connection ID c49d22a1-d306-4278-b955-63c098ffc529\n", |
| 257 | + "ML Message from c49d22a1-d306-4278-b955-63c098ffc529\n", |
| 258 | + "Open file\n", |
| 259 | + "learning\n", |
| 260 | + "untrained_model.pt\n", |
| 261 | + "HOSPITAL MODEL LOADED\n", |
| 262 | + "HOSPITAL IS TRAINING\n", |
| 263 | + "loss at epoch 0 : tensor(0.2652)\n", |
| 264 | + "loss at epoch 5000 : tensor(0.1328)\n", |
| 265 | + "loss at epoch 10000 : tensor(0.1152)\n", |
| 266 | + "loss at epoch 15000 : tensor(0.1115)\n", |
| 267 | + "loss at epoch 20000 : tensor(0.1068)\n", |
| 268 | + "loss at epoch 25000 : tensor(0.1006)\n", |
| 269 | + "loss at epoch 30000 : tensor(0.0973)\n", |
| 270 | + "loss at epoch 35000 : tensor(0.0955)\n", |
| 271 | + "loss at epoch 40000 : tensor(0.0943)\n", |
| 272 | + "loss at epoch 45000 : tensor(0.0934)\n", |
144 | 273 | "Learnt \n",
|
145 | 274 | "Trained file open\n",
|
146 |
| - "connection ID 5b995cd7-cdbf-44a5-951d-3ec538feeec9\n" |
| 275 | + "connection ID c49d22a1-d306-4278-b955-63c098ffc529\n" |
147 | 276 | ]
|
148 | 277 | }
|
149 | 278 | ],
|
|
154 | 283 | {
|
155 | 284 | "cell_type": "code",
|
156 | 285 | "execution_count": null,
|
157 |
| - "id": "printable-rally", |
| 286 | + "id": "magnetic-firmware", |
158 | 287 | "metadata": {},
|
159 | 288 | "outputs": [],
|
160 | 289 | "source": []
|
|
0 commit comments