Skip to content

platform-wallet: key-origin provenance across wallets and composed rejections #5525

Open

Description

@romchornyi

Expected Behavior

A key row's derivation breadcrumb is cleared only by a rejection of exactly that derivation: the same coordinates under the same wallet's seed. This should hold when:

  • one identity has keys derived from two wallets' seeds held in the same app;
  • several rejections of one key are combined before they reach the store (buffered SQLite segments, the refused-row retry queue).

Current Behavior

#5487 gives each key row a three-state origin: a verified breadcrumb, a rejection of specific coordinates, or unknown. Persisters clear a stored breadcrumb only when a rejection names exactly its coordinates, and only for the persisting wallet. Two cases are still open.

  1. Kotlin persister across wallets. Kotlin key rows record no wallet for their breadcrumb, so the persister decides by the identity's owning wallet. A full load or discovery through wallet B first upserts the identity scalar with walletId = B, then the key rows. A rejection by B at numeric coordinates that match wallet A's verified breadcrumb for the same public key therefore passes the check and clears A's breadcrumb and pending repair. Swift and SQLite compare the row's own wallet and are not affected.
  2. Composed rejections. IdentityKeyEntry::derivation_rejected holds one set of coordinates. When two rejections of the same key at different coordinates (say (0, 3) and (1, 3)) are merged before persistence (IdentityKeysChangeSet::merge, store_with_queued_key_rows), only the later one survives. A legacy inferred breadcrumb at the earlier coordinates is then kept, whereas applying the two writes one at a time would clear it.

Both need an identity whose keys come from two seeds, or one sighted at two different identity indices, before a store commits. Neither is a flow the apps have today.

Possible Solution

  1. Store the breadcrumb's wallet on the Kotlin PublicKeyEntity (a Room migration), written from the entry's wallet_id, and compare that wallet instead of the identity's.
  2. Make the rejection a set of scoped coordinates (BTreeSet<(WalletId, IdentityKeyDerivationIndices)>) that merges by union. Carry it through the retry queue, the SQLite writer, and the FFI/JNI key row as an array, with the Swift and Kotlin persisters clearing any matching stored breadcrumb.
  3. Regressions: a complete begin → identity upsert (B) → key rejection (B) → end round in Kotlin, starting from A's breadcrumb; buffered and immediate SQLite persistence of two distinct rejections; a failed-store retry carrying two distinct rejections.

Steps to Reproduce (for bugs)

  1. Hold an identity in wallet A with a verified breadcrumb for key K at (0, 3).
  2. Load the same identity through wallet B, whose candidate at (0, 3) does not reproduce K.
  3. On Kotlin, the stored breadcrumb for K is cleared.

Context

Raised by the review of #5487 (findings "Reject only the derivation path that was actually checked" and "Preserve earlier coordinate rejections when combining key writes"), after the per-wallet and per-coordinate rules there landed.

Your Environment

🤖 Generated with Claude Code

Activity

  1. added
    bug
    on Oct 21, 2026
  2. added a commit that references this issue on Oct 21, 2026
    18bc03f
  3. romchornyi commented on Oct 21, 2026

    @romchornyi
    ContributorAuthor

    Implemented in #5487 (18bc03f, a683ade): the wallet-scoped breadcrumb on Kotlin key rows (Room 16 + migration), the rejection set merged by union through the queue, SQLite, FFI/JNI and both mobile persisters, and the three regressions. This closes when #5487 merges.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions