From 89f7ae86e96a3e5fe8024eb7ede44e2dfdadb944 Mon Sep 17 00:00:00 2001 From: Jakub Porzuczek Date: Tue, 25 Jun 2024 10:36:39 +0200 Subject: [PATCH] changes after merge with main --- .../android/LinkConnectionStatusObserver.kt | 2 +- .../babylon/wallet/android/MainActivity.kt | 4 +- .../android/data/dapp/PeerdroidClient.kt | 4 +- .../ResolveAccountsLedgerStateRepository.kt | 1 - .../deriveaccounts/DeriveAccountsViewModel.kt | 1 - .../createaccount/CreateAccountViewModel.kt | 2 +- .../settings/AccountSettingsViewModel.kt | 2 +- .../IncompatibleProfileDialog.kt | 1 - .../backup/RestoreFromBackupViewModel.kt | 1 - .../presentation/settings/SettingsItem.kt | 4 +- .../settings/SettingsViewModel.kt | 1 - .../settings/debug/DebugSettingsViewModel.kt | 1 - .../scan/AccountRecoveryScanScreen.kt | 1 - .../scan/AccountRecoveryScanViewModel.kt | 1 - .../ImportLegacyWalletViewModel.kt | 4 +- .../presentation/wallet/WalletScreen.kt | 2 +- .../babylon/wallet/android/utils/Constants.kt | 10 --- core/build.gradle | 1 - .../java/rdx/works/core/EncryptionHelper.kt | 30 -------- .../wallet/core/EncryptionHelperTest.kt | 68 ------------------- gradle/libs.versions.toml | 6 +- 21 files changed, 14 insertions(+), 133 deletions(-) diff --git a/app/src/main/java/com/babylon/wallet/android/LinkConnectionStatusObserver.kt b/app/src/main/java/com/babylon/wallet/android/LinkConnectionStatusObserver.kt index 9b6db00cac..795f77dc2b 100644 --- a/app/src/main/java/com/babylon/wallet/android/LinkConnectionStatusObserver.kt +++ b/app/src/main/java/com/babylon/wallet/android/LinkConnectionStatusObserver.kt @@ -1,8 +1,8 @@ package com.babylon.wallet.android +import Constants import androidx.compose.ui.graphics.Color import com.babylon.wallet.android.di.coroutines.ApplicationScope -import com.babylon.wallet.android.utils.Constants import kotlinx.collections.immutable.ImmutableList import kotlinx.collections.immutable.persistentListOf import kotlinx.collections.immutable.toPersistentList diff --git a/app/src/main/java/com/babylon/wallet/android/MainActivity.kt b/app/src/main/java/com/babylon/wallet/android/MainActivity.kt index e71ffb876c..abe4e66273 100644 --- a/app/src/main/java/com/babylon/wallet/android/MainActivity.kt +++ b/app/src/main/java/com/babylon/wallet/android/MainActivity.kt @@ -98,9 +98,9 @@ class MainActivity : FragmentActivity() { } } - override fun onNewIntent(intent: Intent?) { + override fun onNewIntent(intent: Intent) { super.onNewIntent(intent) - intent?.data?.let { viewModel.handleDeepLink(it) } + intent.data?.let { viewModel.handleDeepLink(it) } } private fun setSplashExitAnimation(splashScreen: SplashScreen) { diff --git a/app/src/main/java/com/babylon/wallet/android/data/dapp/PeerdroidClient.kt b/app/src/main/java/com/babylon/wallet/android/data/dapp/PeerdroidClient.kt index d38c4d6767..7f74a43d3a 100644 --- a/app/src/main/java/com/babylon/wallet/android/data/dapp/PeerdroidClient.kt +++ b/app/src/main/java/com/babylon/wallet/android/data/dapp/PeerdroidClient.kt @@ -1,11 +1,11 @@ package com.babylon.wallet.android.data.dapp +import Constants import com.babylon.wallet.android.data.dapp.model.IncompatibleRequestVersionException import com.babylon.wallet.android.data.dapp.model.LedgerInteractionResponse import com.babylon.wallet.android.data.dapp.model.toDomainModel import com.babylon.wallet.android.domain.RadixWalletException import com.babylon.wallet.android.domain.model.IncomingMessage -import com.babylon.wallet.android.utils.Constants import com.radixdlt.sargon.DappToWalletInteractionUnvalidated import com.radixdlt.sargon.DappWalletInteractionErrorType import com.radixdlt.sargon.RadixConnectPassword @@ -146,7 +146,7 @@ class PeerdroidClientImpl @Inject constructor( if (interactionVersion != Constants.WALLET_INTERACTION_VERSION) { throw IncompatibleRequestVersionException( requestVersion = interactionVersion, - requestId = dappInteraction.interactionId.toString() + requestId = dappInteraction.interactionId ) } dappInteraction.toDomainModel(remoteEntityId = IncomingMessage.RemoteEntityID.ConnectorId(remoteConnectorId)).getOrThrow() diff --git a/app/src/main/java/com/babylon/wallet/android/data/repository/ResolveAccountsLedgerStateRepository.kt b/app/src/main/java/com/babylon/wallet/android/data/repository/ResolveAccountsLedgerStateRepository.kt index a5d8e8bbc3..4b973d610d 100644 --- a/app/src/main/java/com/babylon/wallet/android/data/repository/ResolveAccountsLedgerStateRepository.kt +++ b/app/src/main/java/com/babylon/wallet/android/data/repository/ResolveAccountsLedgerStateRepository.kt @@ -9,7 +9,6 @@ import com.babylon.wallet.android.data.gateway.generated.models.StateEntityDetai import com.babylon.wallet.android.data.gateway.generated.models.StateEntityDetailsRequest import com.babylon.wallet.android.di.ShortTimeoutStateApi import com.babylon.wallet.android.domain.model.AccountWithOnLedgerStatus -import com.babylon.wallet.android.utils.Constants import com.radixdlt.sargon.Account import com.radixdlt.sargon.AccountAddress import com.radixdlt.sargon.DepositRule diff --git a/app/src/main/java/com/babylon/wallet/android/presentation/accessfactorsources/deriveaccounts/DeriveAccountsViewModel.kt b/app/src/main/java/com/babylon/wallet/android/presentation/accessfactorsources/deriveaccounts/DeriveAccountsViewModel.kt index 540eb2453f..f2b59a79da 100644 --- a/app/src/main/java/com/babylon/wallet/android/presentation/accessfactorsources/deriveaccounts/DeriveAccountsViewModel.kt +++ b/app/src/main/java/com/babylon/wallet/android/presentation/accessfactorsources/deriveaccounts/DeriveAccountsViewModel.kt @@ -14,7 +14,6 @@ import com.babylon.wallet.android.presentation.common.OneOffEventHandler import com.babylon.wallet.android.presentation.common.OneOffEventHandlerImpl import com.babylon.wallet.android.presentation.common.StateViewModel import com.babylon.wallet.android.presentation.common.UiState -import com.babylon.wallet.android.utils.Constants import com.radixdlt.sargon.Account import com.radixdlt.sargon.DerivationPathScheme import com.radixdlt.sargon.DisplayName diff --git a/app/src/main/java/com/babylon/wallet/android/presentation/account/createaccount/CreateAccountViewModel.kt b/app/src/main/java/com/babylon/wallet/android/presentation/account/createaccount/CreateAccountViewModel.kt index 58f0cb9d16..63214d517c 100644 --- a/app/src/main/java/com/babylon/wallet/android/presentation/account/createaccount/CreateAccountViewModel.kt +++ b/app/src/main/java/com/babylon/wallet/android/presentation/account/createaccount/CreateAccountViewModel.kt @@ -1,5 +1,6 @@ package com.babylon.wallet.android.presentation.account.createaccount +import Constants.ACCOUNT_NAME_MAX_LENGTH import androidx.lifecycle.SavedStateHandle import androidx.lifecycle.viewModelScope import com.babylon.wallet.android.domain.usecases.CreateAccountUseCase @@ -14,7 +15,6 @@ import com.babylon.wallet.android.presentation.common.UiMessage import com.babylon.wallet.android.presentation.common.UiState import com.babylon.wallet.android.utils.AppEvent import com.babylon.wallet.android.utils.AppEventBus -import com.babylon.wallet.android.utils.Constants.ACCOUNT_NAME_MAX_LENGTH import com.radixdlt.sargon.Account import com.radixdlt.sargon.AccountAddress import com.radixdlt.sargon.DisplayName diff --git a/app/src/main/java/com/babylon/wallet/android/presentation/account/settings/AccountSettingsViewModel.kt b/app/src/main/java/com/babylon/wallet/android/presentation/account/settings/AccountSettingsViewModel.kt index d7724931b0..b269fa2216 100644 --- a/app/src/main/java/com/babylon/wallet/android/presentation/account/settings/AccountSettingsViewModel.kt +++ b/app/src/main/java/com/babylon/wallet/android/presentation/account/settings/AccountSettingsViewModel.kt @@ -1,5 +1,6 @@ package com.babylon.wallet.android.presentation.account.settings +import Constants.ACCOUNT_NAME_MAX_LENGTH import androidx.lifecycle.SavedStateHandle import androidx.lifecycle.viewModelScope import com.babylon.wallet.android.BuildConfig @@ -14,7 +15,6 @@ import com.babylon.wallet.android.presentation.common.UiMessage import com.babylon.wallet.android.presentation.common.UiState import com.babylon.wallet.android.utils.AppEvent import com.babylon.wallet.android.utils.AppEventBus -import com.babylon.wallet.android.utils.Constants.ACCOUNT_NAME_MAX_LENGTH import com.radixdlt.sargon.Account import com.radixdlt.sargon.AccountAddress import com.radixdlt.sargon.DepositRule diff --git a/app/src/main/java/com/babylon/wallet/android/presentation/incompatibleprofile/IncompatibleProfileDialog.kt b/app/src/main/java/com/babylon/wallet/android/presentation/incompatibleprofile/IncompatibleProfileDialog.kt index 5244b132d3..ec7d9927b9 100644 --- a/app/src/main/java/com/babylon/wallet/android/presentation/incompatibleprofile/IncompatibleProfileDialog.kt +++ b/app/src/main/java/com/babylon/wallet/android/presentation/incompatibleprofile/IncompatibleProfileDialog.kt @@ -31,7 +31,6 @@ import com.babylon.wallet.android.designsystem.composable.RadixTextButton import com.babylon.wallet.android.designsystem.theme.RadixTheme import com.babylon.wallet.android.presentation.incompatibleprofile.IncompatibleProfileViewModel.Event import com.babylon.wallet.android.presentation.ui.RadixWalletPreviewTheme -import com.babylon.wallet.android.utils.Constants import com.babylon.wallet.android.utils.openEmail const val ROUTE_INCOMPATIBLE_PROFILE = "incompatible_profile_route" diff --git a/app/src/main/java/com/babylon/wallet/android/presentation/onboarding/restore/backup/RestoreFromBackupViewModel.kt b/app/src/main/java/com/babylon/wallet/android/presentation/onboarding/restore/backup/RestoreFromBackupViewModel.kt index 8d08d69625..29066e1b08 100644 --- a/app/src/main/java/com/babylon/wallet/android/presentation/onboarding/restore/backup/RestoreFromBackupViewModel.kt +++ b/app/src/main/java/com/babylon/wallet/android/presentation/onboarding/restore/backup/RestoreFromBackupViewModel.kt @@ -10,7 +10,6 @@ import com.babylon.wallet.android.presentation.common.StateViewModel import com.babylon.wallet.android.presentation.common.UiMessage import com.babylon.wallet.android.presentation.common.UiState import com.babylon.wallet.android.utils.CanSignInToGoogle -import com.babylon.wallet.android.utils.Constants import com.radixdlt.sargon.Header import com.radixdlt.sargon.Timestamp import dagger.hilt.android.lifecycle.HiltViewModel diff --git a/app/src/main/java/com/babylon/wallet/android/presentation/settings/SettingsItem.kt b/app/src/main/java/com/babylon/wallet/android/presentation/settings/SettingsItem.kt index a3462848e8..cb6e1b3d84 100644 --- a/app/src/main/java/com/babylon/wallet/android/presentation/settings/SettingsItem.kt +++ b/app/src/main/java/com/babylon/wallet/android/presentation/settings/SettingsItem.kt @@ -1,12 +1,12 @@ package com.babylon.wallet.android.presentation.settings +import Constants.RADIX_SUPPORT_EMAIL_ADDRESS +import Constants.RADIX_SUPPORT_EMAIL_SUBJECT import androidx.annotation.DrawableRes import androidx.annotation.StringRes import com.babylon.wallet.android.R import com.babylon.wallet.android.domain.model.SecurityProblem import com.babylon.wallet.android.presentation.ui.composables.DSR -import com.babylon.wallet.android.utils.Constants.RADIX_SUPPORT_EMAIL_ADDRESS -import com.babylon.wallet.android.utils.Constants.RADIX_SUPPORT_EMAIL_SUBJECT import kotlinx.collections.immutable.ImmutableSet import kotlinx.collections.immutable.persistentSetOf diff --git a/app/src/main/java/com/babylon/wallet/android/presentation/settings/SettingsViewModel.kt b/app/src/main/java/com/babylon/wallet/android/presentation/settings/SettingsViewModel.kt index 001b6d25af..bf65c9dfc2 100644 --- a/app/src/main/java/com/babylon/wallet/android/presentation/settings/SettingsViewModel.kt +++ b/app/src/main/java/com/babylon/wallet/android/presentation/settings/SettingsViewModel.kt @@ -11,7 +11,6 @@ import com.babylon.wallet.android.presentation.settings.SettingsItem.TopLevelSet import com.babylon.wallet.android.presentation.settings.SettingsItem.TopLevelSettings.LinkToConnector import com.babylon.wallet.android.presentation.settings.SettingsItem.TopLevelSettings.Personas import com.babylon.wallet.android.presentation.settings.SettingsItem.TopLevelSettings.Preferences -import com.babylon.wallet.android.utils.Constants import com.radixdlt.sargon.SargonBuildInformation import com.radixdlt.sargon.extensions.Sargon import dagger.hilt.android.lifecycle.HiltViewModel diff --git a/app/src/main/java/com/babylon/wallet/android/presentation/settings/debug/DebugSettingsViewModel.kt b/app/src/main/java/com/babylon/wallet/android/presentation/settings/debug/DebugSettingsViewModel.kt index 9f12055132..ff6c8fda06 100644 --- a/app/src/main/java/com/babylon/wallet/android/presentation/settings/debug/DebugSettingsViewModel.kt +++ b/app/src/main/java/com/babylon/wallet/android/presentation/settings/debug/DebugSettingsViewModel.kt @@ -2,7 +2,6 @@ package com.babylon.wallet.android.presentation.settings.debug import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope -import com.babylon.wallet.android.utils.Constants import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.SharingStarted diff --git a/app/src/main/java/com/babylon/wallet/android/presentation/settings/troubleshooting/accountrecoveryscan/scan/AccountRecoveryScanScreen.kt b/app/src/main/java/com/babylon/wallet/android/presentation/settings/troubleshooting/accountrecoveryscan/scan/AccountRecoveryScanScreen.kt index a1b1778dbc..6ca8ea0533 100644 --- a/app/src/main/java/com/babylon/wallet/android/presentation/settings/troubleshooting/accountrecoveryscan/scan/AccountRecoveryScanScreen.kt +++ b/app/src/main/java/com/babylon/wallet/android/presentation/settings/troubleshooting/accountrecoveryscan/scan/AccountRecoveryScanScreen.kt @@ -54,7 +54,6 @@ import com.babylon.wallet.android.presentation.ui.composables.RadixSnackbarHost import com.babylon.wallet.android.presentation.ui.composables.SimpleAccountCard import com.babylon.wallet.android.presentation.ui.composables.SnackbarUIMessage import com.babylon.wallet.android.presentation.ui.modifier.throttleClickable -import com.babylon.wallet.android.utils.Constants import com.babylon.wallet.android.utils.biometricAuthenticateSuspend import com.babylon.wallet.android.utils.formattedSpans import com.radixdlt.sargon.Account diff --git a/app/src/main/java/com/babylon/wallet/android/presentation/settings/troubleshooting/accountrecoveryscan/scan/AccountRecoveryScanViewModel.kt b/app/src/main/java/com/babylon/wallet/android/presentation/settings/troubleshooting/accountrecoveryscan/scan/AccountRecoveryScanViewModel.kt index fcdee848b6..ceb0097657 100644 --- a/app/src/main/java/com/babylon/wallet/android/presentation/settings/troubleshooting/accountrecoveryscan/scan/AccountRecoveryScanViewModel.kt +++ b/app/src/main/java/com/babylon/wallet/android/presentation/settings/troubleshooting/accountrecoveryscan/scan/AccountRecoveryScanViewModel.kt @@ -15,7 +15,6 @@ import com.babylon.wallet.android.presentation.common.UiMessage import com.babylon.wallet.android.presentation.common.UiState import com.babylon.wallet.android.utils.AppEvent import com.babylon.wallet.android.utils.AppEventBus -import com.babylon.wallet.android.utils.Constants import com.radixdlt.sargon.Account import com.radixdlt.sargon.FactorSource import com.radixdlt.sargon.MnemonicWithPassphrase diff --git a/app/src/main/java/com/babylon/wallet/android/presentation/settings/troubleshooting/importlegacywallet/ImportLegacyWalletViewModel.kt b/app/src/main/java/com/babylon/wallet/android/presentation/settings/troubleshooting/importlegacywallet/ImportLegacyWalletViewModel.kt index c9bab5ed37..9a273dc3ec 100644 --- a/app/src/main/java/com/babylon/wallet/android/presentation/settings/troubleshooting/importlegacywallet/ImportLegacyWalletViewModel.kt +++ b/app/src/main/java/com/babylon/wallet/android/presentation/settings/troubleshooting/importlegacywallet/ImportLegacyWalletViewModel.kt @@ -2,6 +2,8 @@ package com.babylon.wallet.android.presentation.settings.troubleshooting.importlegacywallet +import Constants.ACCOUNT_NAME_MAX_LENGTH +import Constants.DELAY_300_MS import androidx.lifecycle.viewModelScope import com.babylon.wallet.android.data.dapp.LedgerMessenger import com.babylon.wallet.android.data.dapp.model.Curve @@ -22,8 +24,6 @@ import com.babylon.wallet.android.presentation.model.LedgerDeviceUiModel import com.babylon.wallet.android.presentation.settings.securitycenter.ledgerhardwarewallets.AddLedgerDeviceUiState import com.babylon.wallet.android.utils.AppEvent import com.babylon.wallet.android.utils.AppEventBus -import com.babylon.wallet.android.utils.Constants.ACCOUNT_NAME_MAX_LENGTH -import com.babylon.wallet.android.utils.Constants.DELAY_300_MS import com.radixdlt.sargon.FactorSource import com.radixdlt.sargon.FactorSourceId import com.radixdlt.sargon.HierarchicalDeterministicPublicKey diff --git a/app/src/main/java/com/babylon/wallet/android/presentation/wallet/WalletScreen.kt b/app/src/main/java/com/babylon/wallet/android/presentation/wallet/WalletScreen.kt index 02e3763b0a..420cef4886 100644 --- a/app/src/main/java/com/babylon/wallet/android/presentation/wallet/WalletScreen.kt +++ b/app/src/main/java/com/babylon/wallet/android/presentation/wallet/WalletScreen.kt @@ -1,5 +1,6 @@ package com.babylon.wallet.android.presentation.wallet +import Constants.RADIX_START_PAGE_URL import androidx.compose.foundation.Image import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box @@ -58,7 +59,6 @@ import com.babylon.wallet.android.presentation.ui.composables.actionableaddress. import com.babylon.wallet.android.presentation.ui.composables.assets.TotalFiatBalanceView import com.babylon.wallet.android.presentation.ui.composables.assets.TotalFiatBalanceViewToggle import com.babylon.wallet.android.presentation.ui.modifier.throttleClickable -import com.babylon.wallet.android.utils.Constants.RADIX_START_PAGE_URL import com.babylon.wallet.android.utils.biometricAuthenticateSuspend import com.babylon.wallet.android.utils.openUrl import com.radixdlt.sargon.Account diff --git a/app/src/main/java/com/babylon/wallet/android/utils/Constants.kt b/app/src/main/java/com/babylon/wallet/android/utils/Constants.kt index 2d61c85257..a649c1e952 100644 --- a/app/src/main/java/com/babylon/wallet/android/utils/Constants.kt +++ b/app/src/main/java/com/babylon/wallet/android/utils/Constants.kt @@ -1,5 +1,3 @@ -package com.babylon.wallet.android.utils - object Constants { const val SNACKBAR_SHOW_DURATION_MS = 2000L const val VM_STOP_TIMEOUT_MS = 5000L @@ -10,14 +8,6 @@ object Constants { const val MAX_ITEMS_PER_ENTITY_DETAILS_REQUEST = 20 const val WALLET_INTERACTION_VERSION = 2L - object RadixMobileConnect { - const val CONNECT_URL_PARAM_PUBLIC_KEY = "publicKey" - const val CONNECT_URL_PARAM_SESSION_ID = "sessionId" - const val CONNECT_URL_PARAM_ORIGIN = "origin" - const val CONNECT_URL_PARAM_INTERACTION_ID = "interactionId" - const val CONNECT_URL_PARAM_BROWSER = "browser" - } - const val RADIX_SUPPORT_EMAIL_ADDRESS = "hello@radixdlt.com" const val RADIX_SUPPORT_EMAIL_SUBJECT = "Customer Support Case" } diff --git a/core/build.gradle b/core/build.gradle index 83f0c92b8a..ee26fad267 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -52,7 +52,6 @@ dependencies { implementation libs.kotlinxSerialization implementation libs.firebaseCrashlytics implementation libs.immutableCollections - implementation libs.crypto // Datastore implementation libs.datastorePreferences diff --git a/core/src/main/java/rdx/works/core/EncryptionHelper.kt b/core/src/main/java/rdx/works/core/EncryptionHelper.kt index 2afcdfcf30..c410c431af 100644 --- a/core/src/main/java/rdx/works/core/EncryptionHelper.kt +++ b/core/src/main/java/rdx/works/core/EncryptionHelper.kt @@ -12,12 +12,6 @@ import android.security.keystore.KeyProperties.KEY_ALGORITHM_AES import android.security.keystore.KeyProperties.PURPOSE_DECRYPT import android.security.keystore.KeyProperties.PURPOSE_ENCRYPT import android.util.Base64 -import org.bouncycastle.crypto.AsymmetricCipherKeyPair -import org.bouncycastle.crypto.agreement.X25519Agreement -import org.bouncycastle.crypto.generators.X25519KeyPairGenerator -import org.bouncycastle.crypto.params.X25519KeyGenerationParameters -import org.bouncycastle.crypto.params.X25519PrivateKeyParameters -import org.bouncycastle.crypto.params.X25519PublicKeyParameters import rdx.works.core.KeystoreManager.Companion.KEY_ALIAS_MNEMONIC import rdx.works.core.KeystoreManager.Companion.KEY_ALIAS_PROFILE import rdx.works.core.KeystoreManager.Companion.PROVIDER @@ -200,27 +194,3 @@ fun String.decodeHex(): ByteArray { .map { it.toInt(16).toByte() } .toByteArray() } - -fun generateX25519KeyPair(): Result> { - return runCatching { - val generator = X25519KeyPairGenerator() - val params = X25519KeyGenerationParameters(SecureRandom()) - generator.init(params) - val keypair1: AsymmetricCipherKeyPair = generator.generateKeyPair() - val priv1 = keypair1.private as X25519PrivateKeyParameters - val pub1 = keypair1.public as X25519PublicKeyParameters - Pair(priv1.encoded.toHexString(), pub1.encoded.toHexString()) - } -} - -fun generateX25519SharedSecret(privateKeyCompressed: ByteArray, publicKeyCompressed: ByteArray): Result { - return runCatching { - val agreement = X25519Agreement().apply { - init(X25519PrivateKeyParameters(privateKeyCompressed)) - } - - val secret = ByteArray(agreement.agreementSize) - agreement.calculateAgreement(X25519PublicKeyParameters(publicKeyCompressed), secret, 0) - secret.toHexString() - } -} diff --git a/core/src/test/java/com/babylon/wallet/core/EncryptionHelperTest.kt b/core/src/test/java/com/babylon/wallet/core/EncryptionHelperTest.kt index 3fc7bcdc81..4387d407db 100644 --- a/core/src/test/java/com/babylon/wallet/core/EncryptionHelperTest.kt +++ b/core/src/test/java/com/babylon/wallet/core/EncryptionHelperTest.kt @@ -1,16 +1,10 @@ package com.babylon.wallet.core import com.radixdlt.sargon.extensions.hexToBagOfBytes -import kotlinx.serialization.Serializable -import kotlinx.serialization.encodeToString -import kotlinx.serialization.json.Json import org.junit.Assert import org.junit.Test -import rdx.works.core.decodeHex import rdx.works.core.decrypt import rdx.works.core.encrypt -import rdx.works.core.generateX25519KeyPair -import rdx.works.core.generateX25519SharedSecret import rdx.works.core.toByteArray import rdx.works.core.toHexString import java.nio.ByteBuffer @@ -57,37 +51,6 @@ class EncryptionHelperTest { Assert.assertNotEquals(encryptedMessage1, encryptedMessage2) } - @Test - fun `test x25519 key exchange and using shared secret with AES`() { - val testString = "Hello Android" - val x25519TestVectors = generateX25519TestVectors() - - val testVectors = Json.decodeFromString>(x25519TestVectors) - - testVectors.forEach { - val sharedSecret1 = generateX25519SharedSecret( - it.privateKey1.decodeHex(), - it.publicKey2.decodeHex() - ).getOrThrow() - - val sharedSecret2 = generateX25519SharedSecret( - it.privateKey2.decodeHex(), - it.publicKey1.decodeHex() - ).getOrThrow() - - Assert.assertEquals(it.sharedSecret, sharedSecret1) - Assert.assertEquals(it.sharedSecret, sharedSecret2) - val encryptedTestString = testString.toByteArray().encrypt( - withEncryptionKey = sharedSecret1.decodeHex() - ).getOrThrow().toHexString() - - val decryptedTestString = encryptedTestString.decodeHex().decrypt( - withEncryptionKey = sharedSecret2.decodeHex() - ).getOrThrow().toString(UTF_8) - Assert.assertEquals(testString, decryptedTestString) - } - } - private fun getEncryptionKeyData(): ByteBuffer { val byteBuffer = ByteBuffer.allocate(32) for (i in 0..31) { @@ -102,35 +65,4 @@ class EncryptionHelperTest { return copy } - private fun generateX25519TestVectors(): String { - val result = mutableListOf() - repeat(10) { - val kp1 = generateX25519KeyPair().getOrThrow() - val kp2 = generateX25519KeyPair().getOrThrow() - val secret1 = generateX25519SharedSecret(kp1.first.decodeHex(), kp2.second.decodeHex()).getOrThrow() - val secret2 = generateX25519SharedSecret(kp2.first.decodeHex(), kp1.second.decodeHex()).getOrThrow() - if (secret1 != secret2) { - throw IllegalStateException("Secrets do not match") - } - result.add( - X25519TestVector( - kp1.first, - kp1.second, - kp2.first, - kp2.second, - secret1 - ) - ) - } - return Json.encodeToString(result) - } - - @Serializable - data class X25519TestVector( - val privateKey1: String, - val publicKey1: String, - val privateKey2: String, - val publicKey2: String, - val sharedSecret: String - ) } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 9073588e0c..95a139355a 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -51,7 +51,7 @@ turbine = "1.1.0" zxing = "3.5.3" apacheCommonsValidator = "1.9.0" jsonAssert = "1.5.1" -firebaseCrashlytics = "19.0.1" +firebaseCrashlytics = "19.0.2" appsFlyer = "6.14.2" installReferrer = "2.2" playServicesAuth = "21.2.0" @@ -66,7 +66,7 @@ kotlinJvmPlugin = "2.0.0" benManesVersionsPlugin = "0.51.0" versionCatalogUpdatePlugin = "0.8.4" googleServicesPlugin = "4.4.2" -firebaseCrashlyticsPlugin = "3.0.1" +firebaseCrashlyticsPlugin = "3.0.2" hiltPlugin = "2.51.1" sonarqubePlugin = "5.0.0.4638" kspPlugin = "2.0.0-1.0.22" @@ -95,7 +95,6 @@ splash = { module = "androidx.core:core-splashscreen", version.ref = "splash" } immutableCollections = { module = "org.jetbrains.kotlinx:kotlinx-collections-immutable", version.ref = "immutableCollections" } accompanistPagerIndicators = { module = "com.google.accompanist:accompanist-pager-indicators", version.ref = "accompanist" } accompanistDrawablePainter = { module = "com.google.accompanist:accompanist-drawablepainter", version.ref = "accompanist" } -accompanistNavigationAnimation = { module = "com.google.accompanist:accompanist-navigation-animation", version.ref = "accompanist" } accompanistPermissions = { module = "com.google.accompanist:accompanist-permissions", version.ref = "accompanist" } accompanistSystemUiController = { module = "com.google.accompanist:accompanist-systemuicontroller", version.ref = "accompanist" } accompanistPlaceholder = { module = "com.google.accompanist:accompanist-placeholder", version.ref = "accompanist" } @@ -117,7 +116,6 @@ coilComposeGif = { module = "io.coil-kt:coil-gif", version.ref = "coilCompose" } kotlinxSerialization = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinxSerialization" } sargonAndroid = { module = "com.radixdlt.sargon:sargon-android", version.ref = "sargon" } sargonDesktop = { module = "com.radixdlt.sargon:sargon-desktop-bins", version.ref = "sargon" } -crypto = { module = "org.bouncycastle:bcprov-jdk15to18", version.ref = "crypto" } okhttpBom = { module = "com.squareup.okhttp3:okhttp-bom", version.ref = "okhttpBom" } okhttp = { module = "com.squareup.okhttp3:okhttp" } okhttpInterceptor = { module = "com.squareup.okhttp3:logging-interceptor" }