From 3a89ecf04b90ecc0f2c9cd7d4d1787cdcf979c9f Mon Sep 17 00:00:00 2001 From: Valere Date: Tue, 2 Apr 2024 15:23:11 +0200 Subject: [PATCH 1/2] Add own device creation ts in crypto API --- MatrixSDK/Crypto/MXCrypto.h | 6 ++++++ MatrixSDK/Crypto/MXCrypto.m | 6 ++++++ MatrixSDK/Crypto/MXCryptoV2.swift | 5 +++++ 3 files changed, 17 insertions(+) diff --git a/MatrixSDK/Crypto/MXCrypto.h b/MatrixSDK/Crypto/MXCrypto.h index 3f12cdd45..0d26df375 100644 --- a/MatrixSDK/Crypto/MXCrypto.h +++ b/MatrixSDK/Crypto/MXCrypto.h @@ -95,6 +95,12 @@ extern NSString *const MXDeviceListDidUpdateUsersDevicesNotification; */ @property (nullable, nonatomic, readonly) NSString *deviceEd25519Key; + +/** +* The user device creation in local timestamp, milliseconds since epoch. +*/ +@property (nonatomic) UInt64 deviceCreationTs; + /** The key backup manager. */ diff --git a/MatrixSDK/Crypto/MXCrypto.m b/MatrixSDK/Crypto/MXCrypto.m index fc599496f..c75c39b8d 100644 --- a/MatrixSDK/Crypto/MXCrypto.m +++ b/MatrixSDK/Crypto/MXCrypto.m @@ -1422,6 +1422,12 @@ - (NSString *)olmVersion #endif } +- (uint64_t)deviceCreationTs +{ + // Device creation timestamp is not support in legacy crypto + return 0; +} + #pragma mark - Gossipping diff --git a/MatrixSDK/Crypto/MXCryptoV2.swift b/MatrixSDK/Crypto/MXCryptoV2.swift index 2e5c642b7..adea4ac92 100644 --- a/MatrixSDK/Crypto/MXCryptoV2.swift +++ b/MatrixSDK/Crypto/MXCryptoV2.swift @@ -56,6 +56,11 @@ class MXCryptoV2: NSObject, MXCrypto { return machine.deviceEd25519Key } + var deviceCreationTs: UInt64 { + // own device always exists + return machine.device(userId: machine.userId, deviceId: machine.deviceId)!.firstTimeSeenTs + } + let backup: MXKeyBackup? let keyVerificationManager: MXKeyVerificationManager let crossSigning: MXCrossSigning From e74124ec0c1f368a57826ac67603a9f7b3fdcaca Mon Sep 17 00:00:00 2001 From: Valere Date: Tue, 2 Apr 2024 18:12:29 +0200 Subject: [PATCH 2/2] deviceCreationTs should be readonly --- MatrixSDK/Crypto/MXCrypto.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MatrixSDK/Crypto/MXCrypto.h b/MatrixSDK/Crypto/MXCrypto.h index 0d26df375..348edddd0 100644 --- a/MatrixSDK/Crypto/MXCrypto.h +++ b/MatrixSDK/Crypto/MXCrypto.h @@ -99,7 +99,7 @@ extern NSString *const MXDeviceListDidUpdateUsersDevicesNotification; /** * The user device creation in local timestamp, milliseconds since epoch. */ -@property (nonatomic) UInt64 deviceCreationTs; +@property (nonatomic, readonly) UInt64 deviceCreationTs; /** The key backup manager.