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

Bugfix/check entropy #5169

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/src/main/java/one/mixin/android/crypto/CryptoUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ fun storeValueInEncryptedPreferences(context: Context, alias: String, entropy: B
)

val encodedKey = entropy.toHex()
encryptedPrefs.edit().putString(alias, encodedKey).apply()
encryptedPrefs.edit().putString(alias, encodedKey).commit()
}

fun removeValueFromEncryptedPreferences(context: Context, alias: String) {
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/java/one/mixin/android/tip/Tip.kt
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,9 @@ class Tip
fun getSpendPriv(context: Context, seed: ByteArray): ByteArray {
var entropy = getMnemonicFromEncryptedPreferences(context)
if (entropy == null) { // Register safe must generate mnemonic, Only once
if (Session.getAccount() != null && !Session.hasPhone() && !Session.saltExported()) {
throw IllegalStateException("Entropy lost")
}
entropy = generateEntropyAndStore(context)
}
return getSpendPriv(seed, entropy)
Expand Down
Loading