refactor; rename alpha to prop

This commit is contained in:
2025-03-10 10:05:49 -05:00
parent 571268b86a
commit dd0b496a21
7 changed files with 33 additions and 38 deletions

View File

@@ -165,7 +165,7 @@ set_key = generate_random_nonrepeating_list(keypad_size.attrs_per_key, max_numb=
set_key = xor_lists(set_key, customer_attr.set_vals)
UserCipherKeys(
alpha_key=generate_random_nonrepeating_list(keypad_size.attrs_per_key * keypad_size.numb_of_keys, max_numb=2**(8*numb_of_bytes)),
prop_key=generate_random_nonrepeating_list(keypad_size.attrs_per_key * keypad_size.numb_of_keys, max_numb=2**(8*numb_of_bytes)),
pass_key=generate_random_nonrepeating_list(max_nkode_len, max_numb=2**(8*numb_of_bytes)),
mask_key=generate_random_nonrepeating_list(max_nkode_len, max_numb=2**(8*numb_of_bytes)),
set_key=set_key,
@@ -177,7 +177,7 @@ UserCipherKeys(
##### User Cipher Keys Values
```
user_keys = UserCipherKeys(
alpha_key = {{ user_keys.alpha_key }},
prop_key = {{ user_keys.prop_key }},
pass_key = {{ user_keys.pass_key }},
mask_key = {{ user_keys.mask_key }},
set_key = {{ user_keys.set_key }},
@@ -233,12 +233,12 @@ Mask: {{ enciphered_nkode.mask }}
#### Passcode Enciphering and Hashing
- ciphered_customer_attr = alpha_key ^ customer_attr
- ciphered_customer_attr = prop_key ^ customer_attr
- ciphered_passcode_i = pass_key_i ^ ciphered_customer_attr_i
- code = hash(ciphered_passcode, salt)
```
ciphered_customer_attrs = xor_lists(customer.attributes.attr_vals, user_keys.alpha_key)
ciphered_customer_attrs = xor_lists(customer.attributes.attr_vals, user_keys.prop_key)
passcode_ciphered_attrs = [ciphered_customer_attrs[idx] for idx in passcode]
pad_len = customer.nkode_policy.max_nkode_len - passcode_len
@@ -389,17 +389,17 @@ sets_xor = xor_lists(new_sets, old_sets)
for user in customer.users.values():
user.renew = True
user.user_keys.set_key = xor_lists(user.user_keys.set_key, sets_xor)
user.user_keys.alpha_key = xor_lists(user.user_keys.alpha_key, attrs_xor)
user.user_keys.prop_key = xor_lists(user.user_keys.prop_key, attrs_xor)
```
##### User Alpha Key
The user's alpha key was a randomly generated list of length `numb_of_keys * attr_per_key`.
Now each value in the alpha key is `alpha_key_i = old_alpha_key_i ^ new_attr_i ^ old_attr_i`.
Recall in the login process, `ciphered_customer_attrs = alpha_key ^ customer_attr`.
##### User prop Key
The user's prop key was a randomly generated list of length `numb_of_keys * attr_per_key`.
Now each value in the prop key is `prop_key_i = old_prop_key_i ^ new_attr_i ^ old_attr_i`.
Recall in the login process, `ciphered_customer_attrs = prop_key ^ customer_attr`.
Since the customer_attr is now the new value, it gets canceled out, leaving:
```
new_alpha_key = old_alpha_key ^ old_attr ^ new_attr
ciphered_customer_attrs = new_alpha_key ^ new_attr
ciphered_customer_attrs = old_alpha_key ^ old_attr # since new_attr cancel out
new_prop_key = old_prop_key ^ old_attr ^ new_attr
ciphered_customer_attrs = new_prop_key ^ new_attr
ciphered_customer_attrs = old_prop_key ^ old_attr # since new_attr cancel out
```
Using the new customer attributes, we can validate the user's login attempt with the same hash.