I'm trying to create an encrypted storage solution that uses IPFS as storage and Ethereum smart contracts for access control. Basically, each user can upload files to IPFS and they can choose Ethereum addresses that can view that data (sharing with others).
However, I cannot find a feasible way to provide encryption / decryption of that data. The approach I thought was in the following way. When user A wants to store a file, it is encrypted with a symmetric key Ks and a smart contract is created that contains the file hash in IPFS and a mapping that represents who can view the data. In the mapping, keys should be addresses of users that are allowed to see the file and the value is Ks encrpyted with the user's public key.
The download process should look like -> B goes to smart contract and asks for the file hash and they decryption key. If the contract has B in the access mappinng, it returns the information. B downloads the file from IPFS and uses its private key to decrypt Ks and then can see the file.
I would like my application to integrate with Metamask for example and I see there is no way I could use the private key of the wallet to do my particular decryption. I couldn't find any possible solutions for this.
Can anyone suggest other workarounds that could help solve the issue?