You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
BlockchainIdentity.addMissingKeys can register a duplicate key that the refreshed identity already has but the wallet hasn't issued #43
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:
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.
Device B registers the CRITICAL key at index 4.
On device A, addMissingKeys refetches and sees key 4. Index 4 is not issued locally, so determineMissingKeys reports the CRITICAL key as missing.
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