From ff7b7cd0b9d35e6842d19cebb75593dd26804ec8 Mon Sep 17 00:00:00 2001 From: Morgan Pretty Date: Fri, 2 Jun 2023 15:32:31 +1000 Subject: [PATCH] Fixed an issue where the group keyPair was getting encoded incorrectly --- .../main/java/org/thoughtcrime/securesms/database/Storage.kt | 4 ++-- .../org/thoughtcrime/securesms/groups/ClosedGroupManager.kt | 5 +++-- .../securesms/util/ConfigurationMessageUtilities.kt | 3 ++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/database/Storage.kt b/app/src/main/java/org/thoughtcrime/securesms/database/Storage.kt index ecfbc31648..4a305ac5a8 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/database/Storage.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/database/Storage.kt @@ -833,7 +833,7 @@ open class Storage(context: Context, helper: SQLCipherOpenHelper, private val co name = name, members = members, priority = ConfigBase.PRIORITY_VISIBLE, - encPubKey = encryptionKeyPair.publicKey.serialize(), + encPubKey = (encryptionKeyPair.publicKey as DjbECPublicKey).publicKey, // 'serialize()' inserts an extra byte encSecKey = encryptionKeyPair.privateKey.serialize(), disappearingTimer = 0L, joinedAt = (formationTimestamp / 1000L) @@ -866,7 +866,7 @@ open class Storage(context: Context, helper: SQLCipherOpenHelper, private val co val groupInfo = userGroups.getOrConstructLegacyGroupInfo(groupPublicKey).copy( name = name, members = membersMap, - encPubKey = latestKeyPair.publicKey.serialize(), + encPubKey = (latestKeyPair.publicKey as DjbECPublicKey).publicKey, // 'serialize()' inserts an extra byte encSecKey = latestKeyPair.privateKey.serialize(), priority = if (isPinned(threadID)) PRIORITY_PINNED else ConfigBase.PRIORITY_VISIBLE, disappearingTimer = recipientSettings.expireMessages.toLong() diff --git a/app/src/main/java/org/thoughtcrime/securesms/groups/ClosedGroupManager.kt b/app/src/main/java/org/thoughtcrime/securesms/groups/ClosedGroupManager.kt index aab09fcf36..8b362d70d1 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/groups/ClosedGroupManager.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/groups/ClosedGroupManager.kt @@ -9,6 +9,7 @@ import org.session.libsession.utilities.Address import org.session.libsession.utilities.GroupRecord import org.session.libsession.utilities.GroupUtil import org.session.libsession.utilities.recipients.Recipient +import org.session.libsignal.crypto.ecc.DjbECPublicKey import org.thoughtcrime.securesms.ApplicationContext import org.thoughtcrime.securesms.dependencies.ConfigFactory @@ -54,8 +55,8 @@ object ClosedGroupManager { name = group.title, disappearingTimer = groupRecipientSettings.expireMessages.toLong(), priority = if (storage.isPinned(threadId)) ConfigBase.PRIORITY_PINNED else ConfigBase.PRIORITY_VISIBLE, - encSecKey = latestKeyPair.privateKey.serialize(), - encPubKey = latestKeyPair.publicKey.serialize() + encPubKey = (latestKeyPair.publicKey as DjbECPublicKey).publicKey, // 'serialize()' inserts an extra byte + encSecKey = latestKeyPair.privateKey.serialize() ) groups.set(toSet) } diff --git a/app/src/main/java/org/thoughtcrime/securesms/util/ConfigurationMessageUtilities.kt b/app/src/main/java/org/thoughtcrime/securesms/util/ConfigurationMessageUtilities.kt index 1848080c2f..9ea15d0af5 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/util/ConfigurationMessageUtilities.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/util/ConfigurationMessageUtilities.kt @@ -23,6 +23,7 @@ import org.session.libsession.utilities.Address import org.session.libsession.utilities.GroupUtil import org.session.libsession.utilities.TextSecurePreferences import org.session.libsession.utilities.WindowDebouncer +import org.session.libsignal.crypto.ecc.DjbECPublicKey import org.session.libsignal.utilities.Hex import org.session.libsignal.utilities.toHexString import org.thoughtcrime.securesms.database.GroupDatabase @@ -254,7 +255,7 @@ object ConfigurationMessageUtilities { name = group.title, members = admins + members, priority = if (isPinned) ConfigBase.PRIORITY_PINNED else ConfigBase.PRIORITY_VISIBLE, - encPubKey = encryptionKeyPair.publicKey.serialize(), + encPubKey = (encryptionKeyPair.publicKey as DjbECPublicKey).publicKey, // 'serialize()' inserts an extra byte encSecKey = encryptionKeyPair.privateKey.serialize(), disappearingTimer = recipient.expireMessages.toLong(), joinedAt = (group.formationTimestamp / 1000L)