rename attribute to property

This commit is contained in:
2025-03-14 09:35:19 -05:00
parent 1e2dfa9c9c
commit 1162bd54e1
12 changed files with 187 additions and 188 deletions

View File

@@ -12,12 +12,12 @@
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2025-03-14T14:18:14.423890Z",
"start_time": "2025-03-14T14:18:14.420788Z"
"end_time": "2025-03-14T14:35:01.634660Z",
"start_time": "2025-03-14T14:35:01.631713Z"
}
},
"outputs": [],
"execution_count": 23
"execution_count": 67
},
{
"cell_type": "code",
@@ -26,26 +26,26 @@
" return \"test_username\" + \"\".join([choice(ascii_lowercase) for _ in range(6)])\n",
"\n",
"\n",
"def select_keys_with_passcode_values(user_passcode: list[int], keypad: np.ndarray, attrs_per_key: int) -> list[int]:\n",
" indices = [np.where(keypad == attr)[0][0] for attr in user_passcode]\n",
" return [int(index // attrs_per_key) for index in indices]\n",
"def select_keys_with_passcode_values(user_passcode: list[int], keypad: np.ndarray, props_per_key: int) -> list[int]:\n",
" indices = [np.where(keypad == prop)[0][0] for prop in user_passcode]\n",
" return [int(index // props_per_key) for index in indices]\n",
"\n",
"\n",
"def keypad_view(keypad: np.ndarray, attrs_per_key: int):\n",
"def keypad_view(keypad: np.ndarray, props_per_key: int):\n",
" print(\"Keypad View\")\n",
" interface_keypad = keypad.reshape(-1, attrs_per_key)\n",
" interface_keypad = keypad.reshape(-1, props_per_key)\n",
" for idx, key_vals in enumerate(interface_keypad):\n",
" print(f\"Key {idx}: {key_vals}\")\n"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2025-03-14T14:18:14.434459Z",
"start_time": "2025-03-14T14:18:14.430679Z"
"end_time": "2025-03-14T14:35:01.653961Z",
"start_time": "2025-03-14T14:35:01.650229Z"
}
},
"outputs": [],
"execution_count": 24
"execution_count": 68
},
{
"cell_type": "code",
@@ -55,12 +55,12 @@
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2025-03-14T14:18:14.453086Z",
"start_time": "2025-03-14T14:18:14.451030Z"
"end_time": "2025-03-14T14:35:01.663429Z",
"start_time": "2025-03-14T14:35:01.661723Z"
}
},
"outputs": [],
"execution_count": 25
"execution_count": 69
},
{
"cell_type": "markdown",
@@ -100,12 +100,12 @@
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2025-03-14T14:18:14.461793Z",
"start_time": "2025-03-14T14:18:14.457601Z"
"end_time": "2025-03-14T14:35:01.675378Z",
"start_time": "2025-03-14T14:35:01.671221Z"
}
},
"outputs": [],
"execution_count": 26
"execution_count": 70
},
{
"cell_type": "markdown",
@@ -138,8 +138,8 @@
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2025-03-14T14:18:14.472200Z",
"start_time": "2025-03-14T14:18:14.469516Z"
"end_time": "2025-03-14T14:35:01.692557Z",
"start_time": "2025-03-14T14:35:01.689797Z"
}
},
"outputs": [
@@ -147,17 +147,17 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Customer Set Key: [57513 39162 37238 40595 30029 8573]\n",
"Customer Set Key: [21871 61274 2713 19029 26505 50649]\n",
"Customer properties Key:\n",
"[14659 8841 6728 32702 39675 63074]\n",
"[19274 15250 33729 24532 34839 38348]\n",
"[ 2539 51139 60808 11045 55452 61221]\n",
"[55550 11904 10001 59259 26026 26740]\n",
"[59910 49698 45525 62003 49414 40644]\n"
"[42655 23174 1254 25551 11488 27210]\n",
"[60953 53938 20104 25057 1695 3339]\n",
"[32918 29164 48427 35503 41361 24040]\n",
"[44451 37655 36339 20189 49770 11581]\n",
"[31824 8094 2501 29432 12778 20956]\n"
]
}
],
"execution_count": 27
"execution_count": 71
},
{
"cell_type": "markdown",
@@ -171,14 +171,14 @@
"source": [
"set_properties_dict = dict(zip(customer.cipher.set_key, customer_prop_keypad.T))\n",
"print(f\"Set to Properties Map:\")\n",
"for set_val, attrs in set_properties_dict.items():\n",
" print(f\"{set_val}: {attrs}\")"
"for set_val, props in set_properties_dict.items():\n",
" print(f\"{set_val}: {props}\")"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2025-03-14T14:18:14.486583Z",
"start_time": "2025-03-14T14:18:14.484301Z"
"end_time": "2025-03-14T14:35:01.702167Z",
"start_time": "2025-03-14T14:35:01.699777Z"
}
},
"outputs": [
@@ -187,16 +187,16 @@
"output_type": "stream",
"text": [
"Set to Properties Map:\n",
"57513: [14659 19274 2539 55550 59910]\n",
"39162: [ 8841 15250 51139 11904 49698]\n",
"37238: [ 6728 33729 60808 10001 45525]\n",
"40595: [32702 24532 11045 59259 62003]\n",
"30029: [39675 34839 55452 26026 49414]\n",
"8573: [63074 38348 61221 26740 40644]\n"
"21871: [42655 60953 32918 44451 31824]\n",
"61274: [23174 53938 29164 37655 8094]\n",
"2713: [ 1254 20104 48427 36339 2501]\n",
"19029: [25551 25057 35503 20189 29432]\n",
"26505: [11488 1695 41361 49770 12778]\n",
"50649: [27210 3339 24040 11581 20956]\n"
]
}
],
"execution_count": 28
"execution_count": 72
},
{
"metadata": {},
@@ -218,8 +218,8 @@
{
"metadata": {
"ExecuteTime": {
"end_time": "2025-03-14T14:18:14.510067Z",
"start_time": "2025-03-14T14:18:14.507204Z"
"end_time": "2025-03-14T14:35:01.722470Z",
"start_time": "2025-03-14T14:35:01.719357Z"
}
},
"cell_type": "code",
@@ -232,15 +232,15 @@
"name": "stdout",
"output_type": "stream",
"text": [
"[[ 1 7 13 19 25]\n",
" [ 0 6 12 18 24]\n",
" [ 5 11 17 23 29]\n",
" [ 2 8 14 20 26]\n",
" [ 4 10 16 22 28]]\n"
"[[24 0 12 6 18]\n",
" [28 4 16 10 22]\n",
" [27 3 15 9 21]\n",
" [26 2 14 8 20]\n",
" [25 1 13 7 19]]\n"
]
}
],
"execution_count": 29
"execution_count": 73
},
{
"metadata": {},
@@ -253,8 +253,8 @@
{
"metadata": {
"ExecuteTime": {
"end_time": "2025-03-14T14:18:14.535581Z",
"start_time": "2025-03-14T14:18:14.531909Z"
"end_time": "2025-03-14T14:35:01.746158Z",
"start_time": "2025-03-14T14:35:01.742671Z"
}
},
"cell_type": "code",
@@ -266,8 +266,8 @@
"selected_keys_set = select_keys_with_passcode_values(user_passcode, signup_keypad, keypad_size.numb_of_keys)\n",
"print(f\"User Passcode: {user_passcode}\")\n",
"print(f\"Selected Keys\\n{selected_keys_set}\")\n",
"server_side_attr = [int(customer.cipher.prop_key[idx]) for idx in user_passcode]\n",
"print(f\"User Passcode Server-side properties: {server_side_attr}\")"
"server_side_prop = [int(customer.cipher.prop_key[idx]) for idx in user_passcode]\n",
"print(f\"User Passcode Server-side properties: {server_side_prop}\")"
],
"outputs": [
{
@@ -275,25 +275,25 @@
"output_type": "stream",
"text": [
"Keypad View\n",
"Key 0: [ 1 7 13 19 25]\n",
"Key 1: [ 0 6 12 18 24]\n",
"Key 2: [ 5 11 17 23 29]\n",
"Key 3: [ 2 8 14 20 26]\n",
"Key 4: [ 4 10 16 22 28]\n",
"User Passcode: [ 1 7 13 19]\n",
"Key 0: [24 0 12 6 18]\n",
"Key 1: [28 4 16 10 22]\n",
"Key 2: [27 3 15 9 21]\n",
"Key 3: [26 2 14 8 20]\n",
"Key 4: [25 1 13 7 19]\n",
"User Passcode: [24 0 12 6]\n",
"Selected Keys\n",
"[0, 0, 0, 0]\n",
"User Passcode Server-side properties: [8841, 15250, 51139, 11904]\n"
"User Passcode Server-side properties: [31824, 42655, 32918, 60953]\n"
]
}
],
"execution_count": 30
"execution_count": 74
},
{
"metadata": {
"ExecuteTime": {
"end_time": "2025-03-14T14:18:14.556541Z",
"start_time": "2025-03-14T14:18:14.553217Z"
"end_time": "2025-03-14T14:35:01.770157Z",
"start_time": "2025-03-14T14:35:01.766784Z"
}
},
"cell_type": "code",
@@ -309,23 +309,23 @@
"output_type": "stream",
"text": [
"Keypad View\n",
"Key 0: [ 0 11 16 20 25]\n",
"Key 1: [ 2 6 13 22 29]\n",
"Key 2: [ 4 8 17 19 24]\n",
"Key 3: [ 1 10 12 23 26]\n",
"Key 4: [ 5 7 14 18 28]\n",
"Key 0: [26 3 16 6 19]\n",
"Key 1: [27 0 13 10 20]\n",
"Key 2: [24 4 14 7 21]\n",
"Key 3: [28 1 15 8 18]\n",
"Key 4: [25 2 12 9 22]\n",
"Selected Keys\n",
"[3, 4, 1, 2]\n"
"[2, 1, 4, 0]\n"
]
}
],
"execution_count": 31
"execution_count": 75
},
{
"metadata": {
"ExecuteTime": {
"end_time": "2025-03-14T14:18:14.884832Z",
"start_time": "2025-03-14T14:18:14.575902Z"
"end_time": "2025-03-14T14:35:02.101712Z",
"start_time": "2025-03-14T14:35:01.792851Z"
}
},
"cell_type": "code",
@@ -343,7 +343,7 @@
]
}
],
"execution_count": 32
"execution_count": 76
},
{
"metadata": {},
@@ -362,8 +362,8 @@
{
"metadata": {
"ExecuteTime": {
"end_time": "2025-03-14T14:18:14.894865Z",
"start_time": "2025-03-14T14:18:14.889948Z"
"end_time": "2025-03-14T14:35:02.115075Z",
"start_time": "2025-03-14T14:35:02.110397Z"
}
},
"cell_type": "code",
@@ -389,22 +389,22 @@
" max_nkode_len=customer.nkode_policy.max_nkode_len, \n",
")\n",
"\n",
"passcode_server_attr = [int(customer.cipher.prop_key[idx]) for idx in user_passcode]\n",
"passcode_server_set = [int(customer.cipher.get_prop_set_val(attr)) for attr in passcode_server_attr]\n",
"passcode_server_prop = [int(customer.cipher.prop_key[idx]) for idx in user_passcode]\n",
"passcode_server_set = [int(customer.cipher.get_prop_set_val(prop)) for prop in passcode_server_prop]\n",
"print(f\"Passcode Set Vals: {passcode_server_set}\")\n",
"print(f\"Passcode Attr Vals: {passcode_server_attr}\")"
"print(f\"Passcode prop Vals: {passcode_server_prop}\")"
],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Passcode Set Vals: [39162, 39162, 39162, 39162]\n",
"Passcode Attr Vals: [8841, 15250, 51139, 11904]\n"
"Passcode Set Vals: [21871, 21871, 21871, 21871]\n",
"Passcode prop Vals: [31824, 42655, 32918, 60953]\n"
]
}
],
"execution_count": 33
"execution_count": 77
},
{
"metadata": {},
@@ -426,8 +426,8 @@
{
"metadata": {
"ExecuteTime": {
"end_time": "2025-03-14T14:18:14.917821Z",
"start_time": "2025-03-14T14:18:14.914851Z"
"end_time": "2025-03-14T14:35:02.132228Z",
"start_time": "2025-03-14T14:35:02.129307Z"
}
},
"cell_type": "code",
@@ -441,7 +441,7 @@
"mask = user_keys.encode_base64_str(ciphered_mask)"
],
"outputs": [],
"execution_count": 34
"execution_count": 78
},
{
"metadata": {},
@@ -450,16 +450,16 @@
"#### Encipher Passcode\n",
"UserCipherKeys.encipher_salt_hash_code:\n",
"\n",
"- ciphered_customer_attr = alpha_key ^ customer_attr\n",
"- ciphered_passcode_i = pass_key_i ^ ciphered_customer_attr_i\n",
"- ciphered_customer_prop = alpha_key ^ customer_prop\n",
"- ciphered_passcode_i = pass_key_i ^ ciphered_customer_prop_i\n",
"- code = hash(ciphered_passcode, salt)"
]
},
{
"metadata": {
"ExecuteTime": {
"end_time": "2025-03-14T14:18:15.243102Z",
"start_time": "2025-03-14T14:18:14.937865Z"
"end_time": "2025-03-14T14:35:02.448903Z",
"start_time": "2025-03-14T14:35:02.143953Z"
}
},
"cell_type": "code",
@@ -468,13 +468,13 @@
"import hashlib\n",
"import base64\n",
"\n",
"ciphered_customer_attrs = np.bitwise_xor(customer.cipher.prop_key, user_keys.prop_key)\n",
"passcode_ciphered_attrs = [ciphered_customer_attrs[idx] for idx in user_passcode]\n",
"ciphered_customer_props = np.bitwise_xor(customer.cipher.prop_key, user_keys.prop_key)\n",
"passcode_ciphered_props = [ciphered_customer_props[idx] for idx in user_passcode]\n",
"pad_len = customer.nkode_policy.max_nkode_len - passcode_len\n",
"\n",
"passcode_ciphered_attrs.extend([0 for _ in range(pad_len)])\n",
"passcode_ciphered_props.extend([0 for _ in range(pad_len)])\n",
"\n",
"ciphered_code = np.bitwise_xor(passcode_ciphered_attrs, user_keys.pass_key)\n",
"ciphered_code = np.bitwise_xor(passcode_ciphered_props, user_keys.pass_key)\n",
"\n",
"#passcode_bytes = int_array_to_bytes(ciphered_code)\n",
"passcode_bytes = ciphered_code.tobytes()\n",
@@ -483,13 +483,13 @@
"code = hashed_data.decode(\"utf-8\")"
],
"outputs": [],
"execution_count": 35
"execution_count": 79
},
{
"metadata": {
"ExecuteTime": {
"end_time": "2025-03-14T14:18:15.249186Z",
"start_time": "2025-03-14T14:18:15.247147Z"
"end_time": "2025-03-14T14:35:02.459349Z",
"start_time": "2025-03-14T14:35:02.457325Z"
}
},
"cell_type": "code",
@@ -502,7 +502,7 @@
")"
],
"outputs": [],
"execution_count": 36
"execution_count": 80
},
{
"metadata": {},
@@ -516,8 +516,8 @@
{
"metadata": {
"ExecuteTime": {
"end_time": "2025-03-14T14:18:15.563030Z",
"start_time": "2025-03-14T14:18:15.257823Z"
"end_time": "2025-03-14T14:35:02.775720Z",
"start_time": "2025-03-14T14:35:02.468856Z"
}
},
"cell_type": "code",
@@ -535,17 +535,17 @@
"output_type": "stream",
"text": [
"Keypad View\n",
"Key 0: [0 1 2 3 4 5]\n",
"Key 1: [ 6 7 8 9 10 11]\n",
"Key 0: [24 25 26 27 28 29]\n",
"Key 1: [0 1 2 3 4 5]\n",
"Key 2: [12 13 14 15 16 17]\n",
"Key 3: [18 19 20 21 22 23]\n",
"Key 4: [24 25 26 27 28 29]\n",
"Key 3: [ 6 7 8 9 10 11]\n",
"Key 4: [18 19 20 21 22 23]\n",
"Selected Keys: [0, 1, 2, 3]\n",
"True\n"
]
}
],
"execution_count": 37
"execution_count": 81
},
{
"metadata": {},
@@ -577,8 +577,8 @@
{
"metadata": {
"ExecuteTime": {
"end_time": "2025-03-14T14:18:15.574718Z",
"start_time": "2025-03-14T14:18:15.571571Z"
"end_time": "2025-03-14T14:35:02.787442Z",
"start_time": "2025-03-14T14:35:02.784207Z"
}
},
"cell_type": "code",
@@ -598,11 +598,11 @@
"name": "stdout",
"output_type": "stream",
"text": [
"[39162, 39162, 39162, 39162]\n"
"[21871, 21871, 21871, 21871]\n"
]
}
],
"execution_count": 38
"execution_count": 82
},
{
"metadata": {},
@@ -612,8 +612,8 @@
{
"metadata": {
"ExecuteTime": {
"end_time": "2025-03-14T14:18:15.591180Z",
"start_time": "2025-03-14T14:18:15.587992Z"
"end_time": "2025-03-14T14:35:02.805826Z",
"start_time": "2025-03-14T14:35:02.802523Z"
}
},
"cell_type": "code",
@@ -624,8 +624,8 @@
"for idx in range(passcode_len):\n",
" key_numb = selected_keys_login[idx]\n",
" set_idx = set_vals_idx[idx]\n",
" selected_attr_idx = customer.users[username].user_keypad.get_prop_idx_by_keynumb_setidx(key_numb, set_idx)\n",
" presumed_selected_properties_idx.append(selected_attr_idx)\n",
" selected_prop_idx = customer.users[username].user_keypad.get_prop_idx_by_keynumb_setidx(key_numb, set_idx)\n",
" presumed_selected_properties_idx.append(selected_prop_idx)\n",
"\n",
"print(user_passcode.tolist() == presumed_selected_properties_idx)"
],
@@ -638,7 +638,7 @@
]
}
],
"execution_count": 39
"execution_count": 83
},
{
"metadata": {},
@@ -648,8 +648,8 @@
{
"metadata": {
"ExecuteTime": {
"end_time": "2025-03-14T14:18:15.916787Z",
"start_time": "2025-03-14T14:18:15.610843Z"
"end_time": "2025-03-14T14:35:03.129079Z",
"start_time": "2025-03-14T14:35:02.822467Z"
}
},
"cell_type": "code",
@@ -666,7 +666,7 @@
]
}
],
"execution_count": 40
"execution_count": 84
},
{
"metadata": {},
@@ -682,8 +682,8 @@
{
"metadata": {
"ExecuteTime": {
"end_time": "2025-03-14T14:18:16.539065Z",
"start_time": "2025-03-14T14:18:15.926843Z"
"end_time": "2025-03-14T14:35:03.757448Z",
"start_time": "2025-03-14T14:35:03.142511Z"
}
},
"cell_type": "code",
@@ -708,14 +708,14 @@
"name": "stdout",
"output_type": "stream",
"text": [
"mask: 4NCIa/fFtx0udGaF1ub+O/6oU04=, code: $2b$12$XuGO.allDcb91peVIjwsq./Ba/TZI3wxAc0acgWkApzkzGWfwPQCC\n",
"mask: 4NCIa/fFtx0udGaF1ub+O/6oU04=, code: $2b$12$XuGO.allDcb91peVIjwsq./Ba/TZI3wxAc0acgWkApzkzGWfwPQCC\n",
"mask: QUR1wAPG8jJh/nG1LbgMIupAY1I=, code: $2b$12$0Ia665myY64l8.UyKRc4tu/OR.0BG6KFLyXcuDdIXrDkpP6cjo7xO\n",
"mask: QUR1wAPG8jJh/nG1LbgMIupAY1I=, code: $2b$12$0Ia665myY64l8.UyKRc4tu/OR.0BG6KFLyXcuDdIXrDkpP6cjo7xO\n",
"True\n",
"mask: ceaWZR+hNRpEkj3fq1cfPu1Zyok=, code: $2b$12$q7lqdTj6qBMDDGEog9Pq3.M2Wso0TI8cx4/PhOK/fE1mhsws2FGe.\n"
"mask: SB1G0mGYnu2Fy2usk08r9uTTugo=, code: $2b$12$pKJtlWu9gwXqA4b.Q/WEZ.yzz9ntnXnFSindkyVOWa3sNOoVd0LLK\n"
]
}
],
"execution_count": 41
"execution_count": 85
},
{
"metadata": {},
@@ -729,8 +729,8 @@
{
"metadata": {
"ExecuteTime": {
"end_time": "2025-03-14T14:18:16.551437Z",
"start_time": "2025-03-14T14:18:16.547371Z"
"end_time": "2025-03-14T14:35:03.770972Z",
"start_time": "2025-03-14T14:35:03.766802Z"
}
},
"cell_type": "code",
@@ -742,7 +742,7 @@
"new_sets = customer.cipher.set_key"
],
"outputs": [],
"execution_count": 42
"execution_count": 86
},
{
"metadata": {},
@@ -755,8 +755,8 @@
{
"metadata": {
"ExecuteTime": {
"end_time": "2025-03-14T14:18:16.568881Z",
"start_time": "2025-03-14T14:18:16.566223Z"
"end_time": "2025-03-14T14:35:03.781705Z",
"start_time": "2025-03-14T14:35:03.779309Z"
}
},
"cell_type": "code",
@@ -769,7 +769,7 @@
" user.cipher.prop_key = np.bitwise_xor(user.cipher.prop_key, props_xor)"
],
"outputs": [],
"execution_count": 43
"execution_count": 87
},
{
"metadata": {},
@@ -779,8 +779,8 @@
{
"metadata": {
"ExecuteTime": {
"end_time": "2025-03-14T14:18:16.884432Z",
"start_time": "2025-03-14T14:18:16.572989Z"
"end_time": "2025-03-14T14:35:04.107750Z",
"start_time": "2025-03-14T14:35:03.797025Z"
}
},
"cell_type": "code",
@@ -794,7 +794,7 @@
"user.renew = False"
],
"outputs": [],
"execution_count": 44
"execution_count": 88
}
],
"metadata": {