rename functions and attributes

This commit is contained in:
2024-07-17 08:59:59 -05:00
parent c4d8233730
commit c907f159ab
9 changed files with 42 additions and 40 deletions

30
src/user.py Normal file
View File

@@ -0,0 +1,30 @@
from pydantic import BaseModel
from src.models import EncipheredNKode
from src.customer_interface import CustomerInterface
from src.user_cipher_keys import UserCipherKeys
from src.user_interface import UserInterface
from src.utils import xor_lists
class User(BaseModel):
username: str
enciphered_passcode: EncipheredNKode
user_keys: UserCipherKeys
user_interface: UserInterface
renew: bool = False
def renew_keys(self, sets_xor: list[int], attrs_xor: list[int]):
self.renew = True
self.user_keys.set_key = xor_lists(self.user_keys.set_key, sets_xor)
self.user_keys.alpha_key = xor_lists(self.user_keys.alpha_key, attrs_xor)
def refresh_passcode(self, passcode_attr_idx: list[int], customer_interface: CustomerInterface):
self.user_keys = UserCipherKeys.new(
customer_interface.numb_of_keys,
customer_interface.attrs_per_key,
customer_interface.set_vals,
self.user_keys.max_nkode_len
)
self.enciphered_passcode = self.user_keys.encipher_nkode(passcode_attr_idx, customer_interface)
self.renew = False