π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Documentation
Neeraj Gupta66f20598c2a1
diff --git a/pkg/secrets/key_holder.go b/pkg/secrets/key_holder.goindex d224f74698..3ceb5c779f 100644--- a/pkg/secrets/key_holder.go+++ b/pkg/secrets/key_holder.go@@ -21,6 +21,10 @@ func NewKeyHolder() *KeyHolder {}}+// LoadSecrets loads the secrets for a given account using the provided CLI key.+// It decrypts the token key, master key, and secret key using the CLI key.+// The decrypted keys and the decoded public key are stored in the AccountSecrets map using the account key as the map key.+// It returns the account secret information or an error if the decryption fails.func (k *KeyHolder) LoadSecrets(account model.Account, cliKey []byte) (*model.AccSecretInfo, error) {tokenKey := account.Token.MustDecrypt(cliKey)masterKey := account.MasterKey.MustDecrypt(cliKey)@@ -39,6 +43,11 @@ func (k *KeyHolder) GetAccountSecretInfo(ctx context.Context) *model.AccSecretInreturn k.AccountSecrets[accountKey]}+// GetCollectionKey retrieves the key for a given collection.+// It first fetches the account secret information from the context.+// If the collection owner's ID matches the user ID from the context, it decrypts the collection key using the master key.+// If the collection is shared (i.e., the owner's ID does not match the user ID), it decrypts the collection key using the public and secret keys.+// It returns the decrypted collection key or an error if the decryption fails.func (k *KeyHolder) GetCollectionKey(ctx context.Context, collection api.Collection) ([]byte, error) {accSecretInfo := k.GetAccountSecretInfo(ctx)userID := ctx.Value("user_id").(int64)