# What is an example of elgamal homomorphic double encryption?

I am looking for such an cipher algorithm that is based on assymetric cryptography where the order of encrypting is irrelevant.

For example: There is a message "x", Bob encrypt that message with his key and passes result "zz" to Alice. Alice encrypt that message with her key and receives: "xyz". There is a message "x". Alice encrypt that message with her key and passes result "ui" to Bob. Bob encrypts with his key and receives "xyz".

What is the most important, is that resulting encrypted text is the same.

I have heard that maybe homomorfic ciphers have such properties and have tried with elgamal but no results were ok.

I would be glad if someone could help me with some example that matches my problem.

• You are looking for commutative encryption rather than homomorphic encryption. Also Elgamal is probabilistic, which means in each encryption a fresh randomness is added to the ciphertext, which means if the same plaintext is encrypted twice, the ciphertexts will be different. – Changyu Dong Jun 25 '18 at 10:44
• @ChangyuDong Thank you for your answer. I have made some further reading and discovered SRA encryption algorithm that does his job. asecuritysite.com/encryption/comm2 I need to be sure that one of generated keys is only one way - decryption isn't possible. Is it correct to select encryption key e, which share some factors with PHI? It looks to me thet it will be impossible to generate decryption key then but i'm not sure if it is safe method. – mroknocy Jun 25 '18 at 17:44
• @mroknocy what do you mean? For Alice and Bob, they each has a key pair $(e_i,d_i)$ in which $e_i$ is the encryption key and $d_i$ is the decryption key. Do you mean you don't want one of the parties to have the decryption key? This is easy but then the doubly encrypted ciphertext ('xyz' in your question) cannot be decrypted. – Changyu Dong Jun 25 '18 at 20:03

## 1 Answer

You are looking for commutative encryption rather than homomorphic encryption. Also Elgamal is probabilistic, which means in each encryption a fresh randomness is added to the ciphertext, which means if the same plaintext is encrypted twice, the ciphertexts will be different.

For a deterministic commutative encryption scheme, you can use RSA encryption (SRA in your comment).