feat(keyring-controller): add keyring.fingerprint support#8341
feat(keyring-controller): add keyring.fingerprint support#8341
keyring.fingerprint support#8341Conversation
keyring.fingerprint support
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
| const fingerprint = this.#getSafeFingerprint(builder, keyring); | ||
| if (fingerprint !== undefined) { | ||
| metadata = { ...metadata, fingerprint }; | ||
| } |
There was a problem hiding this comment.
Stale fingerprint not cleared during keyring restore
Low Severity
In #restoreKeyring, the comment says "We recompute the fingerprint," but if the builder no longer provides getFingerprint (or it throws), #getSafeFingerprint returns undefined and the conditional if (fingerprint !== undefined) skips the update — leaving any previously-persisted fingerprint from the vault intact in metadata. This means a stale fingerprint survives restoration and remains usable via withKeyring({ fingerprint: '...' }), even though the builder can no longer produce it. To truly "recompute," the old fingerprint would need to be explicitly cleared when the builder no longer supports fingerprinting.


Explanation
Adding a new way of identifying keyring with a "fingerprint". This would allow to have keyring-defined identifiers (determinist identifiers), that can be used to retrieve the keyring afterward (e.g Snap ID once we start splitting the Snap keyring in multiple keyrings, Money keyring that are sort-of proxy around HD keyrings).
References
N/A
Checklist
Note
Medium Risk
Touches keyring creation/restore and selection logic; incorrect fingerprint implementations or collisions could affect keyring lookup behavior, though failures are guarded by skipping and logging.
Overview
Adds optional, builder-defined keyring fingerprinting:
KeyringBuildercan now exposegetFingerprint(keyring)andKeyringMetadatagains an optionalfingerprintfield populated on keyring creation and recomputed during vault restore (errors are caught and logged, leaving it unset).Extends
withKeyringto support selecting a keyring via{ fingerprint: string }in addition to existing selectors, and adds test coverage for fingerprint storage, restore recomputation, error handling, and fingerprint-based selection.Updates the package changelog to document the new fingerprint capability and selector variant.
Written by Cursor Bugbot for commit 59bab8d. This will update automatically on new commits. Configure here.