refactor code

This commit is contained in:
2024-07-16 12:52:44 -05:00
parent 533151ebde
commit ec398c064a
8 changed files with 126 additions and 186 deletions

View File

@@ -5,7 +5,7 @@ from secrets import choice
from pydantic import BaseModel
from src.models import EncipheredNKode
from src.nkode_interface import CustomerInterface
from src.customer_interface import CustomerInterface
from src.utils import generate_random_nonrepeating_list, xor_lists, int_array_to_bytes
@@ -16,7 +16,6 @@ class UserCipherKeys(BaseModel):
mask_key: list[int]
salt: bytes
max_nkode_len: int = 10
renew: bool = False
@staticmethod
def new_user_encipher_keys(numb_of_keys: int, attrs_per_key: int, set_values: list[int]):
@@ -40,11 +39,6 @@ class UserCipherKeys(BaseModel):
padded_user_mask.append(choice(set_vals))
return padded_user_mask
@staticmethod
def pad_user_code(user_code: list[int], max_nkode_len: int) -> list[int]:
assert (len(user_code) <= max_nkode_len)
return user_code + [0 for _ in range(max_nkode_len - len(user_code))]
@staticmethod
def encode_base64_str(data: list[int]) -> str:
return base64.b64encode(int_array_to_bytes(data)).decode("utf-8")