Repository navigation
Conversation
clearKeysStorage only removed the persisted item. The store kept its state, so getFheKey/getCrs still returned the cleared keys and the next setFheKey/setCrs persisted the whole state again, bringing them back. Reset the store state before removing the persisted item. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: d870ed1 The changes in this PR will be included in the next version bump. This PR includes changesets to release 9 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
clearKeysStorage()on a store fromcreateKeysStoreonly callsstorage.removeItem(...). The zustand store keeps its state, so after a clear:getFheKey/getCrsstill return the cleared key and CRS, andfetchKeyskeeps using them instead of refetching.setFheKeyorsetCrs(for any chain or zone) persists the whole state again, so the cleared entries are written back to storage.With an in-memory
IStorage, onmaster:Changes
packages/sdk/core/keyStore.ts:clearKeysStorageresets the store to{ fhe: {}, crs: {} }before removing the persisted item. A store created without storage is cleared too (it was a no-op).packages/sdk/core/test/keyStore.test.ts: two tests, one with an in-memory storage checking that the cleared keys are gone from memory and are not written back by the next set, one for a store without storage. The existing test only checked thatremoveItemwas called.@cofhe/sdkpatch.Testing
pnpm exec vitest run --project nodeinpackages/sdkon Node 22.23.4:core/test/keyStore.test.ts: 19 passed. Onmasterthe two new tests fail withexpected '0xoldkey' to be undefined.@cofhe/test-setupfail to load on my machine on both branches (Windows,tsupspawn, see fix(test-setup): run builds and command fixtures on Windows #494); unrelated.🤖 Generated with Claude Code
Note
Low Risk
Small behavioral fix in key cache clearing with targeted tests; no auth or crypto logic changes beyond making clear actually empty memory and storage.
Overview
clearKeysStorageoncreateKeysStorenow resets the Zustand store to emptyfheandcrsmaps, not onlystorage.removeItem. Before this fix, cleared keys still came back fromgetFheKey/getCrs, and the nextsetFheKeyorsetCrscould re-persist the old entries with new ones.Stores created without persistence (
createKeysStore(null)) are cleared in memory as well; previouslyclearKeysStoragewas effectively a no-op there.Tests cover that cleared keys stay gone after a subsequent set (with in-memory storage) and that non-persisted stores lose keys after clear.
@cofhe/sdkpatch changeset.Reviewed by Cursor Bugbot for commit d870ed1. Bugbot is set up for automated code reviews on this repo. Configure here.