Score:1

Encrypting messages with two different public keys

hk flag

The problem I have is next:

  • There's the centralized DataBase app which has its own private key and sends its public key to its customers.
  • Each customer has its own private key and should be able to use the combination of his own key and DB app's public key to encrypt its own data.
  • The encrypted data will be visible/available on the network to all third parties.
  • Both DB app and customer should be able to decrypt the data. Each customer only its own data.

What's the best solution to achieve something like this?

Ievgeni avatar
cn flag
Does it make sense if the DB app have the secret keys of all users?
kr flag
@levgeni: The app does not need to know the secret keys of the users.
Score:3
kr flag

"best" is opinion based. "best" from the performance view? "best" from the data size view? "best" from the usability point of view? "best" from some other point of view?

One possible solution can be following.

  1. For each message generate a random key for symmetric encryption, e.g. AES, ChaCha20, Threefish, whatever you like. Encrypt message using this key.
  2. Encrypt the symmetric key using user's public key and add it to the encrypted data.
  3. Encrypt the symmetric key using app public key and add it to the encrypted data.

Then user will be able to decrypt the symmetric key and the decrypt the message. Also the app will be able to do that.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.