feat(identity): switch social identity, all from the one backup

Adds pseudonymous, switchable social identities derived from the SAME root
seed via an account index (NostrKeyDerivation.deriveFromSeed(seed, account)).
HKDF is one-way so accounts are unlinkable to the Ğ1 key; account 0 is the
original identity, byte-for-byte unchanged (no rotation for current users),
and every account regenerates from the single seed — so switching adds
nothing to back up.

- SocialAccountStore: keystore-backed active account + max created.
- Per-identity stores (chats, profile, name cache) namespaced by account
  scope (account 0 = legacy keys, no migration) so identities never mix.
- switchSocialAccount() re-derives the identity, re-scopes the stores and
  restarts the inbox listener; RestartWidget rebuilds the tree to pick up
  the new social singletons. DB/inventory untouched.
- Profile 'Your identities' switcher: list, create, switch (with a note
  that messages/contacts are kept separate per identity). i18n en/es/pt/ast.

Tests: account-indexed derivation (legacy 0 unchanged, accounts distinct
yet deterministic, negatives rejected); SocialAccountStore; per-identity
store scope isolation. Resolves the flagged 'change identity' decision
(open-decisions §B).

Known: switching resets navigation to home (full tree rebuild).
This commit is contained in:
vjrj 2026-07-10 20:20:04 +02:00
parent d36fd05741
commit 993f7b37ab
25 changed files with 597 additions and 33 deletions

View file

@ -1330,6 +1330,30 @@ class Translations$profile$en {
/// en: 'Profile saved'
String get saved => 'Profile saved';
/// en: 'Your identities'
String get identities => 'Your identities';
/// en: 'Keep separate identities — each with its own messages and contacts. They all come from your one backup, so switching adds nothing to remember.'
String get identitiesHelp => 'Keep separate identities — each with its own messages and contacts. They all come from your one backup, so switching adds nothing to remember.';
/// en: 'Identity {n}'
String identityLabel({required Object n}) => 'Identity ${n}';
/// en: 'In use'
String get current => 'In use';
/// en: 'New identity'
String get newIdentity => 'New identity';
/// en: 'Switch identity?'
String get switchTitle => 'Switch identity?';
/// en: 'Messages and contacts are kept separate for each identity. You can switch back anytime.'
String get switchBody => 'Messages and contacts are kept separate for each identity. You can switch back anytime.';
/// en: 'Switch'
String get switchAction => 'Switch';
}
// Path: chatList
@ -2233,6 +2257,14 @@ extension on Translations {
'profile.copied' => 'Copied',
'profile.save' => 'Save',
'profile.saved' => 'Profile saved',
'profile.identities' => 'Your identities',
'profile.identitiesHelp' => 'Keep separate identities — each with its own messages and contacts. They all come from your one backup, so switching adds nothing to remember.',
'profile.identityLabel' => ({required Object n}) => 'Identity ${n}',
'profile.current' => 'In use',
'profile.newIdentity' => 'New identity',
'profile.switchTitle' => 'Switch identity?',
'profile.switchBody' => 'Messages and contacts are kept separate for each identity. You can switch back anytime.',
'profile.switchAction' => 'Switch',
'chatList.title' => 'Messages',
'chatList.empty' => 'No conversations yet. Message someone from the market.',
'chat.title' => 'Chat',