I am working on an app where the goal is to upload user data, store it, do some processing on that data and present it to user when asked. We want to follow end to end encryption model where the system has no way to decrypt the data an user uploaded. I haven’t dealt with security this way before and in the presented architecture I have a few questions/concerns which I want to share with you all.


  1. When a user registers we generate a public private key for him, private key is called master key here.

  2. When a user adds information we encrypt it using session key. Only the data processing unit(DPU) of our system should be able to decrypt this data. Since the data size might be larger than RSA-3072 the data is first encrypted using AES-256 and then encrypted with RSA session key.

  3. Uploaded data goes to DPU, it decrypts it, does its processing and encrypts again.

  4. When user wants access to this information we encrypt the master key with session key and send it to DPU in order to decrypt that data.

  5. Post decryption DPU gathers all the data requested, generates a new data key, encrypts response using this data key, encrypts data key with client’s session public key and assemble both encrypted key and response and returns it.

  6. Client app decrypts key with client’s session private key and the response is decrypted with data key.


  1. This model is theoretical as of now, is this do able ?

  2. Who generates these keys(session keys, data keys), do developers(Java and Python) generate these keys and where do we store them?

  3. Is there a library we can use to make life easy for us? Again, we don’t want our system to be able to access user data without user’s master key which is on his device. We plan on using AWS Cognito for authentication and authorization and as far as I know it doesn't provide any session keys so how can we achieve whats mentioned?

  4. Sending private key over wire to decrypt the data, is this a good idea?

I know this is lot of information please let me know if you have more question, looking forward to suggestions/comments.

closed as unclear what you're asking by Anders, ThoriumBR, schroeder Sep 20 '18 at 15:15

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 3
    IMHO, this looks like a programming design question. 1. what you describe is kinda complicate as everyone is using standard module to do encryption/decryption. The strength of the key is irrelevant, unless there is some sort of proprietary requirements. 2. Please study PKI before go further – mootmoot Sep 20 '18 at 14:08
  • "upload user data, store it, do some processing on that data and present it to user when asked" but "the system has no way to decrypt the data" but "the DPU should be able to decrypt the data" -- it will be impossible to answer when you provide contradictions like that. I think that you are either not using clear terms or you have not performed a data flow analysis. – schroeder Sep 20 '18 at 15:15
  • It would also help if you explained why you want to do e2e encryption and what threats you want the encryption scheme to protect against. – schroeder Sep 20 '18 at 15:16
  • @schroeder Sorry for the confusion, the idea is that only DPU can decrypt data and it would ask for master key from user to decrypt. I hope this helps. This is not my architecture, I am just trying to wrap my head around this. The main goal of our architect is to make sure that we cant access decrypted data without user's key and hence my concern to send master key to DPU. – APZ Sep 20 '18 at 17:43
  • So the data is only processed when the user asks for it to be processed, and the user supplies a decryption key at that time? – schroeder Sep 20 '18 at 17:47

End to End encryption is when 2 systems communicate thru a 3rd party, and this 3rd party cannot decrypt the contents. Like the Signal chat app, or Whatsapp, or when you encrypt your email with the recipient's public key before sending it. In this cases, the message leaves your system encrypted and nobody but the recipient can decrypt and read it.

Your case can be solved using TLS and client side certificates. When the user signs up, let it create its own certificates (on your app) or send him one created server-side, and use this certificate on every communication. Create one certificate for the DPU and encrypt data client-side using it. This way only the DPU and the client can access the data.


What you are describing is not end-to-end encryption (e2ee). In fact, e2ee is in general not possible when the data is being processed, as your servers would not have access to the data.

What you describe is hard to follow and seems useless. If the attacker compromises either of the servers, he can get access to the data. If you are worried about the transit between the servers, you can use standard TLS. If you are worried about the data at rest, you can use FDE or some ratchet encryption scheme (if you only want the client to be able to decrypt it after the processing is done).

Either way, there is no point in doing the encryption as you describe it before the data is processed.

  • Not really an answer, more of a comment and advice. – zaph Sep 20 '18 at 14:46
  • 1
    @zaph Okey, strictly speaking, I did not answer the questions. Then again, in light of this scheme not being effective, I don't think the questions asked are relevant. Is it doable? Technically yes, but it is useless. Who generats the keys? The Sicilian Mafia for all anyone cares, the keys are useless. Is sending the keys over the wire a good idea? You can publish them in the newspapers, does not matter. They are useless. Does this answer the questions? :D – Peter Harmann Sep 20 '18 at 14:53

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