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:
@@ -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
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user