I've been thinking about this situation for quite a while and I wonder if there is a way to solve this on the public Ethereum blockchain.
User A stores some data on the blockchain, encrypted in some way. (with A's private key, for instance). This data is thus only readable by A. Now, A wants to "transfer" the ownership of this data to B, again in an encrypted way, all while guaranteeing that the data isn't being tampered with during the process. This means that the encryption can't happen off-chain: first of all, B can't send his private key to A for obvious reasons, but more than that, if A would re-encrypt the data with B's key offchain, there would be no way to verify if the data is still the same.
I know there is no straightforward way to implement this logic with a smartcontract. The obvious issue here is that smartcontracts "can't" encrypt, because you need to provide them with the key to do so, thus rendering the encryption useless from the start.
That being said, is there a way to achieve this exact process with other tools, while preserving maximal security?