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

@ -715,6 +715,14 @@ class _Translations$profile$es extends Translations$profile$en {
@override String get copied => 'Copiado';
@override String get save => 'Guardar';
@override String get saved => 'Perfil guardado';
@override String get identities => 'Tus identidades';
@override String get identitiesHelp => 'Ten identidades separadas — cada una con sus mensajes y contactos. Todas salen de tu única copia de seguridad, así que cambiar no añade nada que recordar.';
@override String identityLabel({required Object n}) => 'Identidad ${n}';
@override String get current => 'En uso';
@override String get newIdentity => 'Nueva identidad';
@override String get switchTitle => '¿Cambiar de identidad?';
@override String get switchBody => 'Los mensajes y contactos se guardan por separado para cada identidad. Puedes volver cuando quieras.';
@override String get switchAction => 'Cambiar';
}
// Path: chatList
@ -1473,6 +1481,14 @@ extension on TranslationsEs {
'profile.copied' => 'Copiado',
'profile.save' => 'Guardar',
'profile.saved' => 'Perfil guardado',
'profile.identities' => 'Tus identidades',
'profile.identitiesHelp' => 'Ten identidades separadas — cada una con sus mensajes y contactos. Todas salen de tu única copia de seguridad, así que cambiar no añade nada que recordar.',
'profile.identityLabel' => ({required Object n}) => 'Identidad ${n}',
'profile.current' => 'En uso',
'profile.newIdentity' => 'Nueva identidad',
'profile.switchTitle' => '¿Cambiar de identidad?',
'profile.switchBody' => 'Los mensajes y contactos se guardan por separado para cada identidad. Puedes volver cuando quieras.',
'profile.switchAction' => 'Cambiar',
'chatList.title' => 'Mensajes',
'chatList.empty' => 'Aún no hay conversaciones. Escribe a alguien desde el mercado.',
'chat.title' => 'Chat',