Parcourir la source

Minor refactor

Vishnu Mohandas il y a 4 ans
Parent
commit
241cfe5478
1 fichiers modifiés avec 4 ajouts et 7 suppressions
  1. 4 7
      lib/services/collections_service.dart

+ 4 - 7
lib/services/collections_service.dart

@@ -130,19 +130,16 @@ class CollectionsService {
   Uint8List getCollectionKey(int collectionID) {
     if (!_cachedKeys.containsKey(collectionID)) {
       final collection = _collectionIDToCollections[collectionID];
-      var key;
+      final encryptedKey = Sodium.base642bin(collection.encryptedKey);
       if (collection.owner.id == _config.getUserID()) {
-        final encryptedKey = Sodium.base642bin(collection.encryptedKey);
-        key = CryptoUtil.decryptSync(encryptedKey, _config.getKey(),
-            Sodium.base642bin(collection.keyDecryptionNonce));
+        _cachedKeys[collectionID] = CryptoUtil.decryptSync(encryptedKey,
+            _config.getKey(), Sodium.base642bin(collection.keyDecryptionNonce));
       } else {
-        final encryptedKey = Sodium.base642bin(collection.encryptedKey);
-        key = CryptoUtil.openSealSync(
+        _cachedKeys[collectionID] = CryptoUtil.openSealSync(
             encryptedKey,
             Sodium.base642bin(_config.getKeyAttributes().publicKey),
             _config.getSecretKey());
       }
-      _cachedKeys[collectionID] = key;
     }
     return _cachedKeys[collectionID];
   }