Skip to content

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

Description

@piyalbasu

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 deriveAuthKeypairmnemonicToSeedSync (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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions