diff --git a/native/android/app/src/main/java/app/comm/android/fbjni/NotificationsInboundKeysProvider.java b/native/android/app/src/main/java/app/comm/android/fbjni/NotificationsInboundKeysProvider.java --- a/native/android/app/src/main/java/app/comm/android/fbjni/NotificationsInboundKeysProvider.java +++ b/native/android/app/src/main/java/app/comm/android/fbjni/NotificationsInboundKeysProvider.java @@ -1,5 +1,6 @@ package app.comm.android.fbjni; +import android.util.Log; import app.comm.android.commservices.CommAndroidServicesClient; import java.io.IOException; import org.json.JSONException; @@ -12,13 +13,6 @@ CommAndroidServicesClient.getInstance() .getNotifsInboundKeysForDeviceSync(deviceID); String curve25519 = notifInboundKeys.getString("curve25519"); - // There are several reason to return JSON with curve25519 only: - // 1. We only need curve25519 to create inbound session. - // 2. In Session.cpp there is a convention to pass curve25519 - // key as JSON and then add offset length to advance - // the string pointer. - // 3. There is a risk that stringification might not preserve - // the order. - return new JSONObject().put("curve25519", curve25519).toString(); + return curve25519; } } diff --git a/native/cpp/CommonCpp/Notifications/BackgroundDataStorage/NotificationsCryptoModule.cpp b/native/cpp/CommonCpp/Notifications/BackgroundDataStorage/NotificationsCryptoModule.cpp --- a/native/cpp/CommonCpp/Notifications/BackgroundDataStorage/NotificationsCryptoModule.cpp +++ b/native/cpp/CommonCpp/Notifications/BackgroundDataStorage/NotificationsCryptoModule.cpp @@ -715,9 +715,19 @@ // At this point we either face race condition or session reset attempt or // session initialization attempt. For each of this scenario new inbound // session must be created in order to decrypt message - std::string notifInboundKeys = + std::string notifsCurve25519 = NotificationsInboundKeysProvider::getNotifsInboundKeysForDeviceID( deviceID); + // There are several reason to create JSON with curve25519 only: + // 1. We only need curve25519 to create inbound session. + // 2. In Session.cpp there is a convention to pass curve25519 + // key as JSON and then add offset length to advance + // the string pointer. + // 3. There is a risk that stringification might not preserve + // the order. + + std::string notifInboundKeys = + folly::toJson(folly::dynamic::object("curve25519", notifsCurve25519)); if (!maybeAccountWithPicklingKey.has_value()) { throw std::runtime_error("Notifications account not initialized."); diff --git a/native/ios/Comm/NotificationsInboundKeysProvider.mm b/native/ios/Comm/NotificationsInboundKeysProvider.mm --- a/native/ios/Comm/NotificationsInboundKeysProvider.mm +++ b/native/ios/Comm/NotificationsInboundKeysProvider.mm @@ -19,13 +19,6 @@ std::string curve25519 = std::string([notifInboundKeys[@"curve25519"] UTF8String]); - // There are several reason to return JSON with curve25519 only: - // 1. We only need curve25519 to create inbound session. - // 2. In Session.cpp there is a convention to pass curve25519 - // key as JSON and then add offset length to advance - // the string pointer. - // 3. There is a risk that stringification might not preserve - // the order. - return folly::toJson(folly::dynamic::object("curve25519", curve25519)); + return curve25519; } } // namespace comm