Skip to content

platform-wallet: identity update gives every added key a wallet derivation breadcrumb, external keys included #5501

In progress

Description

@romchornyi

Expected Behavior

A key added through IdentityWallet::update_identity_with_external_signer (FFI platform_wallet_update_identity_with_signer[_at_revision], Swift ManagedPlatformWallet.updateIdentity) is stored with a (wallet_id, identity_index, key_index) derivation breadcrumb only when the wallet derived it at that path. A key supplied from outside, such as a browser session key registered by the share-login-key flow, is stored without one, so it stays external (watch-only).

Current Behavior

After the update lands, apply_landed_update (packages/rs-platform-wallet/src/wallet/identity/network/update.rs) gives every added key the breadcrumb (wallet_id, identity_index, key.id()) whenever the identity has an identity_index. The method does not derive or verify the keys it is given, so the breadcrumb is inferred from the identity's wallet membership, not from the key. v5.1-dev already does this on the regular path; #5487 kept the same rule for a cache already at or past the landed revision.

On iOS, the persister turns that breadcrumb into PersistentPublicKey.identityDerivationPath. KeychainSigner then reports the key as signable by deriving on demand from the seed at that path (resolverCanDeriveSign + breadcrumb + mnemonic). For an external key the derived scalar does not match the public key, so a signing path that selects it produces an invalid signature instead of treating the key as one the phone cannot sign with.

Possible Solution

Add explicit per-key provenance to the update API, decided by the caller that built the key (it knows whether the key came from the wallet's derivation at a given index):

  • IdentityPubkeyFFI (shared with registration) gains an optional derivation key index, or a "wallet-derived" flag.
  • Swift ManagedPlatformWallet.IdentityPubkey and the Kotlin counterpart marshal it.
  • update_identity_with_external_signer takes the added keys as KeyWithBreadcrumb, and apply_landed_update stores exactly that, None for external keys.
  • dashwallet-ios passes the derivation index for keys it derives and none for the share-login-key session key.

Rust cannot check this on its own here: identity authentication paths are hardened, and the call carries no mnemonic.

Steps to Reproduce (for bugs)

  1. On iOS, register an external key (e.g. a share-login-key browser session key) on a wallet-owned identity through updateIdentity(addPublicKeys:).
  2. Look at the stored PersistentPublicKey row of the new key: it has walletId and identityDerivationPath set.
  3. KeychainSigner.canSign reports the key as signable, and signing with it derives a scalar that does not match its public key.

Context

Raised by the review of #5487 (finding "Do not fabricate HD derivation breadcrumbs for externally supplied keys"). The behavior predates that PR, and the fix crosses the FFI, Swift and Kotlin SDKs and the apps, so it is tracked here instead of being widened into #5487.

Your Environment

  • Version used: v5.1-dev
  • Operating System and version (desktop, server, or mobile): iOS (dashwallet-ios), Android (Kotlin SDK) for parity

🤖 Generated with Claude Code

Activity

  1. added
    bug
    on Oct 20, 2026
  2. romchornyi commented on Oct 20, 2026

    @romchornyi
    ContributorAuthor

    Addressed in #5487 (4d1f50a, 2c31b5f): the update API takes external_key_ids through Rust, FFI, JNI, Kotlin and Swift, and disables no longer carry an inferred breadcrumb. 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