[Extension] getTokenPrices re-derives the auth keypair (PBKDF2) on every 30s price poll

Open
#2,897 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
45/100
Issue type
Refactor
Clarity
Needs clarification
Activity status
Quiet
Tech stack
typescript

Research direction

Start with the v2 getTokenPrices path through callBackendV2, then trace deriveAuthKeypair and mnemonicToSeedSync after #2880 merges. Choose an approach that removes repeated PBKDF2 work while preserving the #2769 invariant: no key material persisted at rest, with eviction on lock, logout, or expiry.

Written by the indexing model from the issue text.

Description

Problem

getTokenPrices (v2 path) now routes through the freighter-backend-v2 authed chokepoint (callBackendV2) as of #2880 (#2879). It's the first high-frequency chokepoint caller: the Account view polls token prices every ~30s with useCache: false, so each poll triggers deriveAuthKeypair → mnemonicToSeedSync (bip39 PBKDF2, ~18ms of synchronous, main-thread blocking) to sign the per-request JWT.

Per #2769, the auth keypair is deliberately never cached at rest, so today every poll re-derives it. The other migrated call sites (getDiscoverData, fetchCollectibles, getLedgerKeyAccounts) are one-shot, so this hot-path cost only showed up once getTokenPrices was routed through the chokepoint.

This is correct (no security/functional bug) — just an avoidable recurring main-thread stall.

Options

  • A short-lived, in-background keypair memo (e.g. cache the derived keypair in the background service worker for a few seconds, cleared on lock/logout) so a burst of requests reuses one derivation without persisting key material at rest.
  • Let the price poll honor the popup cache / back off its interval.
  • Move derivation off the main thread.

Any option must preserve the #2769 invariant: no key material persisted at rest, and eviction on lock/logout/expiry.

Context

  • Surfaced by the pre-PR whole-system review of #2880.
  • Gated behind #2880 (merge that first).
Dominant language
TypeScript
Stars
122
Forks
62
Avg merge
4d 19h
Merged PRs (30d)
41

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from stellar/freighter

All issues in stellar/freighter

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.