From 9e3f528d447c42246c26f1f0dcb4a17884c244ef Mon Sep 17 00:00:00 2001 From: spaced4ndy <8711996+spaced4ndy@users.noreply.github.com> Date: Mon, 22 Apr 2024 20:50:52 +0400 Subject: [PATCH] android: remove experimental PQ toggle (#4060) --- .../chat/simplex/common/model/SimpleXAPI.kt | 18 +------- .../chat/simplex/common/platform/Core.kt | 1 - .../simplex/common/views/chat/ChatInfoView.kt | 46 +------------------ .../views/usersettings/DeveloperView.kt | 8 ---- 4 files changed, 3 insertions(+), 70 deletions(-) diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/model/SimpleXAPI.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/model/SimpleXAPI.kt index 71ab78634e..0bf3f23d2c 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/model/SimpleXAPI.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/model/SimpleXAPI.kt @@ -163,7 +163,6 @@ class AppPreferences { val confirmDBUpgrades = mkBoolPreference(SHARED_PREFS_CONFIRM_DB_UPGRADES, false) val selfDestruct = mkBoolPreference(SHARED_PREFS_SELF_DESTRUCT, false) val selfDestructDisplayName = mkStrPreference(SHARED_PREFS_SELF_DESTRUCT_DISPLAY_NAME, null) - val pqExperimentalEnabled = mkBoolPreference(SHARED_PREFS_PQ_EXPERIMENTAL_ENABLED, false) val currentTheme = mkStrPreference(SHARED_PREFS_CURRENT_THEME, DefaultTheme.SYSTEM.name) val systemDarkTheme = mkStrPreference(SHARED_PREFS_SYSTEM_DARK_THEME, DefaultTheme.SIMPLEX.name) @@ -328,7 +327,7 @@ class AppPreferences { private const val SHARED_PREFS_CONFIRM_DB_UPGRADES = "ConfirmDBUpgrades" private const val SHARED_PREFS_SELF_DESTRUCT = "LocalAuthenticationSelfDestruct" private const val SHARED_PREFS_SELF_DESTRUCT_DISPLAY_NAME = "LocalAuthenticationSelfDestructDisplayName" - private const val SHARED_PREFS_PQ_EXPERIMENTAL_ENABLED = "PQExperimentalEnabled" + private const val SHARED_PREFS_PQ_EXPERIMENTAL_ENABLED = "PQExperimentalEnabled" // no longer used private const val SHARED_PREFS_CURRENT_THEME = "CurrentTheme" private const val SHARED_PREFS_SYSTEM_DARK_THEME = "SystemDarkTheme" private const val SHARED_PREFS_THEMES = "Themes" @@ -680,15 +679,6 @@ object ChatController { throw Exception("failed to get app settings: ${r.responseType} ${r.details}") } - suspend fun apiSetPQEncryption(enable: Boolean) = sendCommandOkResp(null, CC.ApiSetPQEncryption(enable)) - - suspend fun apiSetContactPQ(rh: Long?, contactId: Long, enable: Boolean): Contact? { - val r = sendCmd(rh, CC.ApiSetContactPQ(contactId, enable)) - if (r is CR.ContactPQAllowed) return r.contact - apiErrorAlert("apiSetContactPQ", "Error allowing contact PQ", r) - return null - } - suspend fun apiExportArchive(config: ArchiveConfig) { val r = sendCmd(null, CC.ApiExportArchive(config)) if (r is CR.CmdOk) return @@ -2393,8 +2383,6 @@ sealed class CC { class SetFilesFolder(val filesFolder: String): CC() class SetRemoteHostsFolder(val remoteHostsFolder: String): CC() class ApiSetEncryptLocalFiles(val enable: Boolean): CC() - class ApiSetPQEncryption(val enable: Boolean): CC() - class ApiSetContactPQ(val contactId: Long, val enable: Boolean): CC() class ApiExportArchive(val config: ArchiveConfig): CC() class ApiImportArchive(val config: ArchiveConfig): CC() class ApiDeleteStorage: CC() @@ -2532,8 +2520,6 @@ sealed class CC { is SetFilesFolder -> "/_files_folder $filesFolder" is SetRemoteHostsFolder -> "/remote_hosts_folder $remoteHostsFolder" is ApiSetEncryptLocalFiles -> "/_files_encrypt ${onOff(enable)}" - is ApiSetPQEncryption -> "/pq ${onOff(enable)}" - is ApiSetContactPQ -> "/_pq @$contactId ${onOff(enable)}" is ApiExportArchive -> "/_db export ${json.encodeToString(config)}" is ApiImportArchive -> "/_db import ${json.encodeToString(config)}" is ApiDeleteStorage -> "/_db delete" @@ -2676,8 +2662,6 @@ sealed class CC { is SetFilesFolder -> "setFilesFolder" is SetRemoteHostsFolder -> "setRemoteHostsFolder" is ApiSetEncryptLocalFiles -> "apiSetEncryptLocalFiles" - is ApiSetPQEncryption -> "apiSetPQEncryption" - is ApiSetContactPQ -> "apiSetContactPQ" is ApiExportArchive -> "apiExportArchive" is ApiImportArchive -> "apiImportArchive" is ApiDeleteStorage -> "apiDeleteStorage" diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/platform/Core.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/platform/Core.kt index 00370f5231..0d447a4a5a 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/platform/Core.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/platform/Core.kt @@ -94,7 +94,6 @@ suspend fun initChatController(useKey: String? = null, confirmMigrations: Migrat controller.apiSetRemoteHostsFolder(remoteHostsDir.absolutePath) } controller.apiSetEncryptLocalFiles(controller.appPrefs.privacyEncryptLocalFiles.get()) - controller.apiSetPQEncryption(controller.appPrefs.pqExperimentalEnabled.get()) // If we migrated successfully means previous re-encryption process on database level finished successfully too if (appPreferences.encryptionStartedAt.get() != null) appPreferences.encryptionStartedAt.set(null) val user = chatController.apiGetActiveUser(null) diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/ChatInfoView.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/ChatInfoView.kt index 42257cf723..dcd36e026b 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/ChatInfoView.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/ChatInfoView.kt @@ -58,7 +58,6 @@ fun ChatInfoView( val currentUser = remember { chatModel.currentUser }.value val connStats = remember(contact.id, connectionStats) { mutableStateOf(connectionStats) } val developerTools = chatModel.controller.appPrefs.developerTools.get() - val pqExperimentalEnabled = chatModel.controller.appPrefs.pqExperimentalEnabled.get() if (chat != null && currentUser != null) { val contactNetworkStatus = remember(chatModel.networkStatuses.toMap(), contact) { mutableStateOf(chatModel.contactNetworkStatus(contact)) @@ -81,7 +80,6 @@ fun ChatInfoView( localAlias, connectionCode, developerTools, - pqExperimentalEnabled, onLocalAliasChanged = { setContactAlias(chat, it, chatModel) }, @@ -140,17 +138,6 @@ fun ChatInfoView( } }) }, - allowContactPQ = { - showAllowContactPQAlert(allowContactPQ = { - withBGApi { - val ct = chatModel.controller.apiSetContactPQ(chatRh, contact.contactId, true) - if (ct != null) { - chatModel.updateContact(chatRh, ct) - } - close.invoke() - } - }) - }, verifyClicked = { ModalManager.end.showModalCloseable { close -> remember { derivedStateOf { (chatModel.getContactChat(contact.contactId)?.chatInfo as? ChatInfo.Direct)?.contact } }.value?.let { ct -> @@ -301,7 +288,6 @@ fun ChatInfoLayout( localAlias: String, connectionCode: String?, developerTools: Boolean, - pqExperimentalEnabled: Boolean, onLocalAliasChanged: (String) -> Unit, openPreferences: () -> Unit, deleteContact: () -> Unit, @@ -310,7 +296,6 @@ fun ChatInfoLayout( abortSwitchContactAddress: () -> Unit, syncContactConnection: () -> Unit, syncContactConnectionForce: () -> Unit, - allowContactPQ: () -> Unit, verifyClicked: () -> Unit, ) { val cStats = connStats.value @@ -360,13 +345,9 @@ fun ChatInfoLayout( } val conn = contact.activeConn - if (pqExperimentalEnabled && conn != null) { - SectionView("Quantum resistant E2E encryption") { + if (conn != null) { + SectionView { InfoRow("E2E encryption", if (conn.connPQEnabled) "Quantum resistant" else "Standard") - if (!conn.pqEncryption) { - AllowContactPQButton(allowContactPQ) - SectionTextFooter("After allowing quantum resistant e2e encryption, it will be enabled after several messages if your contact also allows it.") - } SectionDividerSpaced() } } @@ -627,17 +608,6 @@ fun SynchronizeConnectionButtonForce(syncConnectionForce: () -> Unit) { ) } -@Composable -fun AllowContactPQButton(allowContactPQ: () -> Unit) { - SettingsActionItem( - painterResource(MR.images.ic_warning), - "Allow PQ encryption", - click = allowContactPQ, - textColor = WarningOrange, - iconColor = WarningOrange - ) -} - @Composable fun VerifyCodeButton(contactVerified: Boolean, onClick: () -> Unit) { SettingsActionItem( @@ -741,16 +711,6 @@ fun showSyncConnectionForceAlert(syncConnectionForce: () -> Unit) { ) } -fun showAllowContactPQAlert(allowContactPQ: () -> Unit) { - AlertManager.shared.showAlertDialog( - title = "Allow quantum resistant encryption?", - text = "This is an experimental feature, it is not recommended to enable it for important chats.", - confirmText = "Allow", - onConfirm = allowContactPQ, - destructive = true, - ) -} - @Preview @Composable fun PreviewChatInfoLayout() { @@ -768,7 +728,6 @@ fun PreviewChatInfoLayout() { localAlias = "", connectionCode = "123", developerTools = false, - pqExperimentalEnabled = false, connStats = remember { mutableStateOf(null) }, contactNetworkStatus = NetworkStatus.Connected(), onLocalAliasChanged = {}, @@ -780,7 +739,6 @@ fun PreviewChatInfoLayout() { abortSwitchContactAddress = {}, syncContactConnection = {}, syncContactConnectionForce = {}, - allowContactPQ = {}, verifyClicked = {}, ) } diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/usersettings/DeveloperView.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/usersettings/DeveloperView.kt index a03a015207..ef8c30b43a 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/usersettings/DeveloperView.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/usersettings/DeveloperView.kt @@ -57,14 +57,6 @@ fun DeveloperView( SettingsPreferenceItem(painterResource(MR.images.ic_report), stringResource(MR.strings.show_internal_errors), appPreferences.showInternalErrors) SettingsPreferenceItem(painterResource(MR.images.ic_avg_pace), stringResource(MR.strings.show_slow_api_calls), appPreferences.showSlowApiCalls) } - - SectionSpacer() - SectionView("Experimental".uppercase()) { - SettingsPreferenceItem(painterResource(MR.images.ic_vpn_key_filled), "Post-quantum E2EE", m.controller.appPrefs.pqExperimentalEnabled, onChange = { enable -> - withBGApi { m.controller.apiSetPQEncryption(enable) } - }) - SectionTextFooter("In this version applies only to new contacts.") - } } SectionBottomSpacer() }