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

@@ -20,7 +20,7 @@ def test_create_new_user_and_renew_keys(nkode_api, keypad_size, passocode_len):
session_id, set_keypad = nkode_api.generate_signup_keypad(customer_id)
user_passcode = set_keypad[:passocode_len]
signup_key_selection = lambda keypad: [int(np.where(keypad == attr)[0][0]) // keypad_size.numb_of_keys for attr in user_passcode]
signup_key_selection = lambda keypad: [int(np.where(keypad == prop)[0][0]) // keypad_size.numb_of_keys for prop in user_passcode]
set_key_selection = signup_key_selection(set_keypad)
confirm_keypad = nkode_api.set_nkode(username, customer_id, set_key_selection, session_id)
@@ -33,7 +33,7 @@ def test_create_new_user_and_renew_keys(nkode_api, keypad_size, passocode_len):
)
assert successful_confirm
sign_in_key_selection = lambda keypad: [int(np.where(keypad ==attr)[0][0]) // keypad_size.props_per_key for attr in user_passcode]
sign_in_key_selection = lambda keypad: [int(np.where(keypad ==prop)[0][0]) // keypad_size.props_per_key for prop in user_passcode]
login_keypad = nkode_api.get_login_keypad(username, customer_id)
login_key_selection = sign_in_key_selection(login_keypad)
successful_login = nkode_api.login(customer_id, username, login_key_selection)

View File

@@ -7,9 +7,9 @@ from src.models import KeypadSize
"keypad_size",
[KeypadSize(numb_of_keys=10, props_per_key=11)]
)
def test_attr_set_idx(keypad_size):
def test_prop_set_idx(keypad_size):
user_keypad = UserKeypad.create(keypad_size)
for attr_idx in range(keypad_size.numb_of_props):
user_keypad_idx = user_keypad.keypad[attr_idx]
for prop_idx in range(keypad_size.numb_of_props):
user_keypad_idx = user_keypad.keypad[prop_idx]
assert (attr_idx % keypad_size.props_per_key == user_keypad_idx % keypad_size.props_per_key)
assert (prop_idx % keypad_size.props_per_key == user_keypad_idx % keypad_size.props_per_key)

View File

@@ -35,7 +35,7 @@ def test_decode_mask(keypad_size, max_nkode_len):
user_keys = UserCipher.create(keypad_size, set_vals, max_nkode_len)
passcode = user_keys.encipher_nkode(passcode_entry, customer)
orig_passcode_set_vals = [customer.get_prop_set_val(attr) for attr in passcode_values]
orig_passcode_set_vals = [customer.get_prop_set_val(prop) for prop in passcode_values]
passcode_set_vals = user_keys.decipher_mask(passcode.mask, set_vals, len(passcode_entry))
assert (len(passcode_set_vals) == len(orig_passcode_set_vals))
assert (all(orig_passcode_set_vals[idx] == passcode_set_vals[idx] for idx in range(len(passcode_set_vals))))

View File

@@ -13,15 +13,15 @@ def test_dispersion(user_keypad):
pre_dispersion_graph = user_keypad.property_adjacency_graph()
user_keypad.disperse_keypad()
post_dispersion_graph = user_keypad.property_adjacency_graph()
for attr, adj_graph in pre_dispersion_graph.items():
assert (adj_graph.isdisjoint(post_dispersion_graph[attr]))
for prop, adj_graph in pre_dispersion_graph.items():
assert (adj_graph.isdisjoint(post_dispersion_graph[prop]))
#def test_shuffle_attrs(user_keypad):
#def test_shuffle_props(user_keypad):
# """there's no easy way to test this. At some point we'll have to run this code thousands of time to see if we get
# expected statistical outcomes like:
# - every attribute gets to every key with a uniform distribution
# - every attribute is adjacent to every other attribute with uniform distribution
# - every property gets to every key with a uniform distribution
# - every property is adjacent to every other property with uniform distribution
# - the order in which the cipher move from key to key is random (i.e. the distance traveled is uniform)
# """
# pre_shuffle_keypad = user_keypad.keypad