element-x-ada/libraries
Cobb de2edafe61 feat(wallet): rewrite SSSS on account data + AES-256-GCM envelope
The Rust SDK removed the low-level SecretStoreWrapper.putSecret/getSecret
API between 26.03.x and 26.04.x — it was an escape hatch we were using
to pin arbitrary bytes into a Matrix 4S slot. The SDK maintainers never
contracted that primitive; locking it down lets their recovery code
evolve without worrying about third-party storage.

This commit replaces that dependency with a self-contained design we
own end-to-end, so future SDK moves no longer break our backup flow.

### Design
- Slot: `com.sulkta.wallet.seed.v1` in Matrix account data.
  Our namespace, not a Matrix-spec 4S slot — we are NOT impersonating
  Matrix secret storage, we are holding our own opaque blob.
- Envelope (JSON): version tag, algorithm tag, random 12-byte IV, GCM
  output (ciphertext || tag), AAD = slot name. AES-256-GCM via stock
  javax.crypto. AAD binds a blob to its slot so a blob can't be lifted
  from one namespace and successfully opened in another.
- Key: derived from the user's existing Matrix recovery key via
  HKDF-SHA256 with info label "sulkta.wallet.seed.v1". The info label
  guarantees we never produce the same key bytes Matrix uses for its
  own crypto — same secret, different domain.
- I/O: client.setAccountData(key, json) + client.accountData(key)
  via the SDK; the homeserver only ever sees the opaque encrypted blob.

### Files
- api/walletsecretstorage/WalletSecretStorage.kt — new interface
- impl/walletsecretstorage/WalletSecretEnvelope.kt — AES-GCM envelope
  (with unit tests: round-trip, wrong key, tampered ct, tampered iv,
  wrong AAD, wrong version, malformed JSON)
- impl/walletsecretstorage/RecoveryKeyDerivation.kt — base58 decode
  + parity check + HKDF-SHA256 (with unit tests: determinism,
  whitespace tolerance, distinct info labels → distinct keys)
- impl/walletsecretstorage/MatrixAccountDataWalletSecretStorage.kt —
  WalletSecretStorage impl wrapping Client account data
- test/walletsecretstorage/FakeWalletSecretStorage.kt — in-memory fake
- api/MatrixClient.kt: old .secretStorage → .walletSecretStorage
- features/wallet/.../WalletBackupServiceImpl.kt — rewired to use the
  new interface; hasBackupWithoutKey now goes through the same path
  instead of manually poking the raw Matrix HTTP API.
- DELETED: api/secretstorage/SecretStorage.kt, SecretStore.kt, impl/
  secretstorage/RustSecretStorage.kt — the old SDK-dependent path.

### Backward compat note
Users who backed up a wallet seed on the OLD SDK have a blob in Matrix's
4S at `com.sulkta.cardano.wallet_seed`. This branch cannot read those.
Since the prior integration was only tested internally, acceptable
today — anyone with an old backup re-enters their mnemonic.
2026-04-17 10:16:53 -07:00
..
accountselect Copyright: Add Element Creations Ltd. copyright 2025-11-10 11:05:05 +01:00
androidutils Sign in with Classic 2026-04-13 11:16:05 +02:00
architecture Sign in with Classic 2026-04-13 11:16:05 +02:00
audio Fix voice recording being interrupted by notifications sounds (#6438) 2026-03-24 13:53:42 +01:00
compound Update screenshots 2026-04-02 07:52:20 +00:00
core Improve Kover setup by using only convention plugins (#6213) 2026-03-16 14:41:07 +00:00
cryptography Copyright: Add Element Creations Ltd. copyright 2025-11-10 11:05:05 +01:00
dateformatter Sync Strings from Localazy 2026-04-13 00:48:40 +00:00
deeplink Use the raw expected string for DefaultDeepLinkCreatorTest cases 2025-12-10 15:58:41 +01:00
designsystem Use WindowSizeClass instead of just checking portrait/landscape orientation 2026-04-15 15:51:06 +02:00
di Improve Kover setup by using only convention plugins (#6213) 2026-03-16 14:41:07 +00:00
encrypted-db Copyright: Add Element Creations Ltd. copyright 2025-11-10 11:05:05 +01:00
eventformatter Merge branch 'main' into wallet 2026-04-16 22:05:16 -07:00
featureflag Feature: add room threads list (#6575) 2026-04-15 12:14:22 +00:00
fullscreenintent Detekt: enable rule exceptions.SwallowedException and fix existing issue. 2025-12-05 09:45:23 +01:00
indicator Copyright: Add Element Creations Ltd. copyright 2025-11-10 11:05:05 +01:00
matrix feat(wallet): rewrite SSSS on account data + AES-256-GCM envelope 2026-04-17 10:16:53 -07:00
matrixmedia Apply suggestion: 2026-02-27 09:52:17 +01:00
matrixui Merge branch 'main' into wallet 2026-04-16 22:05:16 -07:00
mediapickers API modules do not need to setup dependency injection. 2025-11-12 19:05:39 +01:00
mediaplayer Merge branch 'develop' into feat/variable-playback-speed 2025-12-30 21:29:18 +01:00
mediaupload Fix portrait image metadata when uploading without media optimization (#6362) 2026-04-08 11:01:54 +02:00
mediaviewer Merge branch 'main' into wallet 2026-04-16 22:05:16 -07:00
network Enable logging OkHttp traffic based on the current log level (#5750) 2025-11-18 15:18:27 +01:00
oidc Copyright: Add Element Creations Ltd. copyright 2025-11-10 11:05:05 +01:00
permissions Sync Strings from Localazy 2026-04-13 00:48:40 +00:00
preferences Copyright: Add Element Creations Ltd. copyright 2025-11-10 11:05:05 +01:00
previewutils Copyright: Add Element Creations Ltd. copyright 2025-11-10 11:05:05 +01:00
push Fix isInAirGappedEnvironment check for older APIs (#6573) 2026-04-14 15:52:41 +02:00
pushproviders Sync Strings from Localazy 2026-04-13 00:48:40 +00:00
pushstore Copyright: Add Element Creations Ltd. copyright 2025-11-10 11:05:05 +01:00
qrcode Link new device using QrCode. 2025-12-16 16:14:04 +01:00
recentemojis API modules do not need to setup dependency injection. 2025-11-12 19:05:39 +01:00
roomselect Add tests and clean code after RoomList Filter rework 2026-01-30 15:33:51 +01:00
rustsdk
session-storage It seems that SqlDelight v2.3.1 does not like unnecessary file 2026-03-13 18:53:08 +01:00
slashcommands Take into account homeserver capabilities (#6507) 2026-04-15 12:29:41 +00:00
testtags Copyright: Add Element Creations Ltd. copyright 2025-11-10 11:05:05 +01:00
textcomposer Merge branch 'main' into wallet 2026-04-16 22:05:16 -07:00
troubleshoot Sync Strings from Localazy 2026-04-13 00:48:40 +00:00
ui-common Copyright: Add Element Creations Ltd. copyright 2025-11-10 11:05:05 +01:00
ui-strings Sync Strings from Localazy 2026-04-13 00:48:40 +00:00
ui-utils Fix long messages not being clickable (#6356) 2026-03-23 18:11:55 +01:00
usersearch Copyright: Add Element Creations Ltd. copyright 2025-11-10 11:05:05 +01:00
voiceplayer Depend on api not impl module. 2026-04-08 18:04:46 +02:00
voicerecorder Add unit test to ensure that number of levels is limited. 2025-11-27 09:30:22 +01:00
wellknown Let enterprise build be able to use a different notification channel for noisy notification. 2026-02-11 11:57:01 +01:00
workmanager Simplify push notification flow by using locally stored values for pending pushes (#6258) 2026-03-03 15:14:36 +00:00