Skip to content

fix(react): scope the decrypt cache key to the account and active ACP - #380

Closed
kriss39 wants to merge 4 commits into
FhenixProtocol:masterfrom
kriss39:fix/decrypt-cache-context-isolation
Closed

kriss39 wants to merge 4 commits into
FhenixProtocol:masterfrom
kriss39:fix/decrypt-cache-context-isolation

Conversation

@kriss39

@kriss39 kriss39 commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

What changed

The decrypt query key now also carries the connected account and its active ACP hash: ['decryptCiphertext', chainId, ctHash, utype, account, acpHash].

#364 already added the chain to the key. The active ACP is stored per chain and per account, though, so after switching account (or ACP) on the same chain the same handle still resolved to the entry decrypted under the previous account. React Query returns cached data for a disabled query too, and the entry is persisted, so the new account saw that plaintext even without a valid ACP of its own.

The two fields are appended at the end, so useCofheDecryptionActivity still reads the ctHash from k[2]. useCofheReadContractAndDecrypt includes them in the key it evicts.

Testing

  • pnpm --filter @cofhe/react run check:types
  • pnpm --filter @cofhe/react test (45 passed)

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@changeset-bot

changeset-bot Bot commented Sep 13, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 3890a5a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 9 packages
Name Type
@cofhe/react Patch
@cofhe/example-react Patch
@cofhe/abi Patch
@cofhe/foundry-plugin Patch
@cofhe/hardhat-3-plugin Patch
@cofhe/hardhat-plugin Patch
@cofhe/mock-contracts Patch
@cofhe/sdk Patch
@cofhe/site Patch

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

@vercel

vercel Bot commented Sep 13, 2026

Copy link
Copy Markdown

@kriss39 is attempting to deploy a commit to the Fhenix Team on Vercel.

A member of the Team first needs to authorize it.

@vercel

vercel Bot commented Sep 13, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
cofhesdk-docs Ignored Ignored Sep 13, 2026 8:36am UTC

Request Review

@kriss39 kriss39 changed the title Fix decrypt cache context isolation fix(react): scope the decrypt cache key to chain, account and active ACP Sep 18, 2026
…-context-isolation

# Conflicts:
#	packages/react/src/hooks/useCofheDecrypt.ts
#	packages/react/src/hooks/useCofheDecryptionActivity.ts
#	packages/react/src/hooks/useCofheReadContractAndDecrypt.ts
Master now keys decrypts by chain. The active ACP is also per account, so the same handle decrypted under one account was still served from the cache after switching account or ACP on that chain. Append the account and ACP hash to the key; the activity hook's ctHash index is unchanged.
@kriss39 kriss39 changed the title fix(react): scope the decrypt cache key to chain, account and active ACP fix(react): scope the decrypt cache key to the account and active ACP Sep 22, 2026
@kriss39

kriss39 commented Sep 22, 2026

Copy link
Copy Markdown
Contributor Author

Merged master and reworked this on top of #364. The chain half of the fix is now covered there, so the PR only adds the account and ACP hash to the key (appended, so the activity hook's indices are unchanged).

@architect-dev

Copy link
Copy Markdown
Collaborator

Thanks for catching this! #388 has since fixed it: the decrypt cache key now includes the ACP hash, which already covers the account, so I'm closing this as superseded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants