rename attribute to property

This commit is contained in:
2025-03-14 09:20:49 -05:00
parent acc5780dc4
commit c6bf401bc5
11 changed files with 225 additions and 241 deletions

View File

@@ -34,46 +34,46 @@ class Customer:
user.enciphered_passcode.mask, self.cipher.set_key, passcode_len)
set_vals_idx = [self.cipher.get_set_index(set_val) for set_val in passcode_set_vals]
presumed_selected_attributes_idx = []
presumed_property_idxs = []
for idx in range(passcode_len):
key_numb = selected_keys[idx]
set_idx = set_vals_idx[idx]
selected_attr_idx = user.user_keypad.get_attr_idx_by_keynumb_setidx(key_numb, set_idx)
presumed_selected_attributes_idx.append(selected_attr_idx)
selected_attr_idx = user.user_keypad.get_prop_idx_by_keynumb_setidx(key_numb, set_idx)
presumed_property_idxs.append(selected_attr_idx)
enciphered_attr = user.cipher.encipher_salt_hash_code(presumed_selected_attributes_idx, self.cipher)
enciphered_attr = user.cipher.encipher_salt_hash_code(presumed_property_idxs, self.cipher)
if enciphered_attr != user.enciphered_passcode.code:
return False
if user.renew:
user.refresh_passcode(presumed_selected_attributes_idx, self.cipher)
user.refresh_passcode(presumed_property_idxs, self.cipher)
return True
def renew_keys(self) -> bool:
old_attrs = self.cipher.prop_key.copy()
old_props = self.cipher.prop_key.copy()
old_sets = self.cipher.set_key.copy()
self.cipher.renew()
new_attrs = self.cipher.prop_key
new_props = self.cipher.prop_key
new_sets = self.cipher.set_key
attrs_xor = np.bitwise_xor(new_attrs, old_attrs)
props_xor = np.bitwise_xor(new_props, old_props)
set_xor = np.bitwise_xor(new_sets, old_sets)
for user in self.users.values():
user.renew_keys(set_xor, attrs_xor)
user.renew_keys(set_xor, props_xor)
self.users[user.username] = user
return True
def valid_new_nkode(self, passcode_attr_idx: list[int]) -> bool:
nkode_len = len(passcode_attr_idx)
def valid_new_nkode(self, passcode_prop_idx: list[int]) -> bool:
nkode_len = len(passcode_prop_idx)
passcode_set_values = [
self.cipher.get_prop_set_val(int(self.cipher.prop_key[attr_idx])) for attr_idx in passcode_attr_idx
self.cipher.get_prop_set_val(int(self.cipher.prop_key[prop_idx])) for prop_idx in passcode_prop_idx
]
distinct_sets = len(set(passcode_set_values))
distinct_attributes = len(set(passcode_attr_idx))
distinct_properties = len(set(passcode_prop_idx))
if (
self.nkode_policy.min_nkode_len <= nkode_len <= self.nkode_policy.max_nkode_len and
distinct_sets >= self.nkode_policy.distinct_sets and
distinct_attributes >= self.nkode_policy.distinct_attributes
distinct_properties >= self.nkode_policy.distinct_properties
):
return True
return False