Encrypting files before uploading to IPFS

I’ve been studying this topic for several months (years?) now, and I still don’t have a clear perspective of how to approach it …
I want to encrypt a file before uploading it to IPFS.

My ideal proccess would be to use the user’s signature to encrypt the file and then transfer the permission access to this file through ownership transfer in an NFT.

  • asymetric encryption is kindof out of the table because its trivially broken.
  • I would like to do it all in js.
  • I guess I may need to regenerate keys to encrypt/decrypt the files before/after each NFT transfer…

Any thoughts out there would be very much appreciated!

what you mean by this part?

I mean that each NFT owner should be able to decrypt the file, and that the key to access the file should be attached to the owner of this NFT.
For example when a user buy this NFT he has access to the file. But then if he transfers this NFT to someone else, the key to access the file should be transfered aswell

Ok, no idea how you could do that, previous owner will still know how to decrypt the file

In an ideal way only NFT owners would have the key to decrypt the file.
But anyway, I didnt get that far yet.
I need, first, to be able to encrytp the file (using js) before uploading it to IPFS.
Any ideas to achive that only?

you could handle the encryption, and show the decrypted nft only to the right user

I believe Secret Network NFT’s can do this, very high on my list too: https://scrt.network/about/secret-nfts