Skip to content

BlockchainIdentity.addMissingKeys can register a duplicate key that the refreshed identity already has but the wallet hasn't issued #43

Open

Description

@HashEngineering

Summary

BlockchainIdentity.addMissingKeys (dash-sdk-kotlin 5.0.1) refetches the identity
(platform.identities.get(uniqueIdentifier)), assigns it to identity, and calls
determineMissingKeys right away. determineMissingKeys counts a key as present only when it
resolves on the wallet's issued identity key chain (for example, the CRITICAL authentication key
at index 4). Nothing between the refetch and the decision issues keys that the refreshed identity has
but the local chain has not issued yet.

Failure scenario

Two devices share one seed and both set up purchase signing at the same time:

  1. Device A's wallet repairs its local key chain against its current snapshot of the identity. That
    snapshot has no CRITICAL key, so the wallet issues nothing.
  2. Device B registers the CRITICAL key at index 4.
  3. On device A, addMissingKeys refetches and sees key 4. Index 4 is not issued locally, so
    determineMissingKeys reports the CRITICAL key as missing.
  4. Device A registers a second CRITICAL key at the next ID and spends identity credits on it.

dash-wallet already issues the identity's keys on its own side before calling addMissingKeys
(dashpay/dash-wallet#1693). That covers every case except a key registered between the wallet's
read and the SDK's refetch.

Proposed fix

In addMissingKeys, after identity = updatedIdentity and before determineMissingKeys, issue on
the identity key chain every wallet-controlled key of updatedIdentity that is not issued yet
(derive and match it on the wallet chain, using signer.keyParameter when the wallet is encrypted).
Alternatively, determineMissingKeys could derive and match up to a lookahead past the issued index
without needing the keys to be issued.

Regression test

The identity refetch returns a newly registered CRITICAL key at an index that is not issued
locally, and that key is wallet-controlled. Assert that no identity update is submitted.

Activity

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

Metadata

Metadata

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