Skip to content

Commit 788f951

Browse files
committed
fix: save cached keys to correct index
1 parent c8535d4 commit 788f951

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

findmy/accessory.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ class _AccessoryKeyGenerator(KeyGenerator[KeyPair]):
396396
# cache enough keys for an entire week.
397397
# every interval'th key is cached.
398398
_CACHE_SIZE = 4 * 24 * 7 # 4 keys / hour
399-
_CACHE_INTERVAL = 10
399+
_CACHE_INTERVAL = 1 # cache every key
400400

401401
def __init__(
402402
self,
@@ -460,7 +460,7 @@ def _get_sk(self, ind: int) -> bytes:
460460
cur_sk = self._sk_cache[cached_ind]
461461

462462
# compute and update cache
463-
for cur_ind in range(start_ind, ind):
463+
for cur_ind in range(start_ind + 1, ind + 1):
464464
cur_sk = crypto.x963_kdf(cur_sk, b"update", 32)
465465

466466
# insert intermediate result into cache and evict oldest entry if necessary

0 commit comments

Comments
 (0)