From 541494613fe35d2de0fcd642b023670a5f4f490f Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Tue, 24 Jun 2025 12:19:55 +0530 Subject: [PATCH] Use CF for file key derivation --- mobile/lib/utils/file_key.dart | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/mobile/lib/utils/file_key.dart b/mobile/lib/utils/file_key.dart index 345c6f6b1d..085c2e1575 100644 --- a/mobile/lib/utils/file_key.dart +++ b/mobile/lib/utils/file_key.dart @@ -6,21 +6,25 @@ import "package:photos/models/file/file.dart"; import "package:photos/services/collections_service.dart"; Uint8List getFileKey(EnteFile file) { - final encryptedKey = CryptoUtil.base642bin(file.encryptedKey!); - final nonce = CryptoUtil.base642bin(file.keyDecryptionNonce!); + final cf = file.cf!; final collectionKey = - CollectionsService.instance.getCollectionKey(file.collectionID!); - return CryptoUtil.decryptSync(encryptedKey, collectionKey, nonce); + CollectionsService.instance.getCollectionKey(cf.collectionID); + return CryptoUtil.decryptSync( + cf.encFileKey, + collectionKey, + cf.encFileKeyNonce, + ); } Future getFileKeyUsingBgWorker(EnteFile file) async { + final cf = file.cf!; final collectionKey = - CollectionsService.instance.getCollectionKey(file.collectionID!); + CollectionsService.instance.getCollectionKey(cf.collectionID); return await Computer.shared().compute( _decryptFileKey, param: { - "encryptedKey": file.encryptedKey, - "keyDecryptionNonce": file.keyDecryptionNonce, + "encryptedKey": cf.encFileKey, + "keyDecryptionNonce": cf.encFileKeyNonce, "collectionKey": collectionKey, }, );