1
$\begingroup$

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?

$\endgroup$
2
  • $\begingroup$ Does it make sense if the DB app have the secret keys of all users? $\endgroup$
    – Ievgeni
    Dec 16, 2022 at 13:51
  • $\begingroup$ @levgeni: The app does not need to know the secret keys of the users. $\endgroup$
    – mentallurg
    Dec 16, 2022 at 13:53

1 Answer 1

3
$\begingroup$

"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.

$\endgroup$
2
  • $\begingroup$ Hey @mentallurg. Few clarifications regarding my question: The app is a kind of Ethereum centralized app, so it can have only one private key and publicly disclosures only one public key (which would be available to all users on that platform). On the other side each Ethereum user would use its own set of keys. There will not be a third party involved here. As for the "best" question, I'm currently hoping to find at least one option which would work. $\endgroup$ Mar 4 at 14:15
  • $\begingroup$ @DusanMarkovic: In the answer I have already described one of the possible solutions. The title of your question says "messages". That's why in the answer I use word "message". In the question itself you are speaking about DB and customer data. Just apply my answer to these data. The approach is the same: Each data set has its own symmetric key. Encrypt symmetric key with using public key of the client. Encrypt symmetric key with using public key of the application. Then every client will be able to decrypt the of client data. Application will be able to decrypt keys of every data set. $\endgroup$
    – mentallurg
    Mar 4 at 22:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.