Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Two wallets #233

Merged
merged 72 commits into from
Jan 13, 2025
Merged

Two wallets #233

merged 72 commits into from
Jan 13, 2025

Conversation

Radiokot
Copy link
Member

@Radiokot Radiokot commented Jan 13, 2025

Purpose

Add ability to have two wallets of different types (1 seed, 1 file) in the same app.

Changes

Overall

  • Added the concept of an app wallet and the corresponding code and UI to create the second wallet and switch between them
  • Split persistence into app-wide and wallet-wide
  • Modernized the data encryption strategy
  • Disabled the ability to create new accounts and identities in file-based wallets
  • Added storage migrations for full backward compatibility

In details

  • Introduced the app-wide database, AppDatabase, while the current one, wallet-wide, is called WalletDatabase
  • Introduced the concept of app wallet, which is stored in AppDatabase and accessible through AppWalletRepository
  • Introduced the concept of the active wallet, which is defined by Session
  • AppCore.session now can be reinitialized with the startNewSession() method
  • All the wallet-wide persistence classes (DB, preferences) now have Wallet prefix (WalletNotificationsPreferences, WalletSendFundsPreferences, etc.)
  • Instances of wallet-wide persistence classes are now managed by WalletStorage, which is accessible through Session and is aware of the current active wallet. Instances are no longer created in ViewModels
  • All the wallet-wide persistence files now have name suffixes. The suffix corresponds to the related app wallet. This way, files and databases for different wallets can be stored independently within the same directory
  • Encryption IV reuse is ended – now, all the encrypted data is stored in a container (EncryptedData) which holds not only the ciphertext, but also the cipher transformation and IV
  • Use of AES CBC for identity and account secrets is ended – from now on, GCM mode is used
  • From now on, all the data is encrypted with a randomly generated master key, which is stored encrypted with a password-derived key. Therefore, when the password is being changed, only the master key gets re-encrypred
  • Cleaned up, refactored, documented AuthenticationManager and turned it into AppAuth, which handles app-wide password auth and encryption
  • Cleaned up and refactored EncryptionHelper
  • Passcode setup screens are now also used to change the passcode. Old passcode/password change screens have been removed
  • AuthPreferences split into AppSetupPreferences and WalletSetupPreferences
  • Implemented TwoWalletsMigration which migrates existing DB and preferences for full backward compatibility

Checklist

  • My code follows the style of this project.
  • The code compiles without warnings.
  • I have performed a self-review of the changes.
  • I have documented my code, in particular the intent of the
    hard-to-understand areas.
  • (If necessary) I have updated the CHANGELOG.

Use EncryptedData container to store ciphertext, IV and transformation.
Use AES in GCM mode for futher encryptions.
We no longer re-encrypt data in DB, so the restriction is no longer
relevant.
Also rename AuthenticationManager to AppAuth
Radiokot and others added 22 commits November 18, 2024 16:54
* Add a comma as a separator for large numbers

* Update Changelog

* Update DecimalTextWatcher

* Fix format GTU function
* Fix inconsistent transaction fee for invoke smart contract

* Update CHANGELOG
# Conflicts:
#	app/src/main/AndroidManifest.xml
#	app/src/main/java/com/concordium/wallet/core/notifications/UpdateNotificationsSubscriptionUseCase.kt
#	app/src/main/java/com/concordium/wallet/ui/MainActivity.kt
#	app/src/main/res/layout/fragment_welcome_promo_more.xml
# Conflicts:
#	CHANGELOG.md
#	app/src/main/java/com/concordium/wallet/core/notifications/TransactionNotificationsManager.kt
#	app/src/main/java/com/concordium/wallet/ui/account/accountsoverview/AccountsOverviewFragment.kt
#	app/src/main/res/layout/fragment_accounts_overview.xml
@Radiokot Radiokot marked this pull request as ready for review January 13, 2025 12:49
@Radiokot Radiokot merged commit 75bd046 into main Jan 13, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants