Implement password verification and enhance BackupScreen UI

- Added password verification logic in MainActivity to decrypt the private key and seed phrase.
- Updated BackupScreen to handle password verification asynchronously using coroutines.
- Improved UI layout for displaying seed phrases in two columns with colored words.
- Added a copy button for the seed phrase with clipboard functionality.
- Introduced a new composable function, WordItem, for better visual representation of seed phrase words.
This commit is contained in:
k1ngsterr1
2026-01-21 16:44:35 +05:00
parent d443592435
commit 7d81dedfab
3 changed files with 176 additions and 33 deletions

View File

@@ -542,10 +542,35 @@ fun MainScreen(
showSafetyScreen = true
},
onVerifyPassword = { password ->
// TODO: Implement password verification
if (password == "test") {
"word1 word2 word3 word4 word5 word6 word7 word8 word9 word10 word11 word12"
} else null
// Verify password by trying to decrypt the private key
try {
val publicKey = account?.publicKey ?: return@BackupScreen null
val accountManager = AccountManager(context)
val encryptedAccount = accountManager.getAccount(publicKey)
if (encryptedAccount != null) {
// Try to decrypt private key with password
val decryptedPrivateKey = com.rosetta.messenger.crypto.CryptoManager.decryptWithPassword(
encryptedAccount.encryptedPrivateKey,
password
)
if (decryptedPrivateKey != null) {
// Password is correct, decrypt seed phrase
com.rosetta.messenger.crypto.CryptoManager.decryptWithPassword(
encryptedAccount.encryptedSeedPhrase,
password
)
} else {
null
}
} else {
null
}
} catch (e: Exception) {
Log.e("MainActivity", "Error verifying password", e)
null
}
}
)
}