refactor: rename entropy length parameter

This commit is contained in:
thePR0M3TH3AN
2025-08-12 09:41:37 -04:00
parent 5109f96ce7
commit a21efa91db
16 changed files with 130 additions and 57 deletions

View File

@@ -9,10 +9,10 @@ class SlowBIP85:
def __init__(self):
self.calls = 0
def derive_entropy(self, index: int, bytes_len: int, app_no: int = 39) -> bytes:
def derive_entropy(self, index: int, entropy_bytes: int, app_no: int = 39) -> bytes:
self.calls += 1
time.sleep(0.01)
return b"\x00" * bytes_len
return b"\x00" * entropy_bytes
def _setup_manager(bip85: SlowBIP85) -> PasswordManager:
@@ -21,10 +21,12 @@ def _setup_manager(bip85: SlowBIP85) -> PasswordManager:
pm.bip85 = bip85
orig = bip85.derive_entropy
def cached(index: int, bytes_len: int, app_no: int = 39) -> bytes:
def cached(index: int, entropy_bytes: int, app_no: int = 39) -> bytes:
key = (app_no, index)
if key not in pm._bip85_cache:
pm._bip85_cache[key] = orig(index=index, bytes_len=bytes_len, app_no=app_no)
pm._bip85_cache[key] = orig(
index=index, entropy_bytes=entropy_bytes, app_no=app_no
)
return pm._bip85_cache[key]
bip85.derive_entropy = cached