numpy refactor

This commit is contained in:
2025-03-13 04:40:45 -05:00
parent facd9ee318
commit f6bf731186
12 changed files with 261 additions and 140 deletions

View File

@@ -1,9 +1,11 @@
from dataclasses import dataclass, field
import numpy as np
from src.models import EncipheredNKode
from src.customer_cipher import CustomerCipher
from src.user_cipher import UserCipher
from src.user_keypad import UserKeypad
from src.utils import xor_lists
@dataclass
@@ -14,10 +16,10 @@ class User:
user_keypad: UserKeypad
renew: bool = field(default=False)
def renew_keys(self, set_xor: list[int], prop_xor: list[int]):
def renew_keys(self, set_xor: np.ndarray, prop_xor: np.ndarray):
self.renew = True
self.cipher.set_key = xor_lists(self.cipher.set_key, set_xor)
self.cipher.prop_key = xor_lists(self.cipher.prop_key, prop_xor)
self.cipher.set_key = np.bitwise_xor(self.cipher.set_key, set_xor)
self.cipher.prop_key = np.bitwise_xor(self.cipher.prop_key, prop_xor)
def refresh_passcode(self, passcode_attr_idx: list[int], customer_attributes: CustomerCipher):
self.cipher = UserCipher.create(