# Finding sum of two encrypted numbers

Let's consider such process:

1. Two emitents emit two (integer) secret numbers independently
2. They encrypt (encode) these number in such a way that no-one (except emitent) can decode these numbers. Emitents also cannot decode/know numbers of each other.
3. Now having two block of decoded numbers we need to find the sum of these numbers

So, I need algorithms for achieving above

1. Number decoding (point 2 above)
2. Sum calculation (point 3 above)
• I can think of a couple of different solutions, depending on what the requirements actually are. In (2), you ask for "Number decoding"; who does the decoding? Is it the parties that generated the numbers (and if they knew the numbers they generated, why do they need to decode them?) In (3), the numbers are "decoded"; those that mean if Alice picks the secret integer 2, that in step (3), it appears as the value 2? If so, what's so difficult about adding two integers? Thirdly, will the sum be published (so, after the protocol, everyone knows the integers everyone else picked)? – poncho Mar 25 '16 at 16:17
• No one knows the integer except the one who emited it. I, as not emiter do not know those integers, but I have it in some decoded form. I need to find the sum of these integers. Which "decoded form" is actually the question – Solvek Mar 25 '16 at 16:29
• By 'decoded form', do you mean 'encoded' (that is, transformed in such a way that it's not obvious what it is)? And, in step (3), who needs to find the sum of these integers; is it the two parties, or is it a third party? And, is the third party supposed to know the sum, or is it acceptable if he learns the individual integers as well?. It might be helpful if you sketch out an example of what needs to happen (e.g. in step 1, Alice and Bob select integers; in step 2, they encrypt their integers, and send them to each other, in step 3, ...) – poncho Mar 25 '16 at 16:32
• Are you asking for Homomorphic Encryption? See : crypto.stackexchange.com/questions/30368/… – JonSG Jul 1 '16 at 17:27

Let $a$ and $b$ be the numbers emited rsp. by person A and person B. $E(x)$ means encoded form of $x$.
$E(a)$ and $E(b)$ are publicly known, right?
Note that if person A knows $a$, $E(a)$, $E(b)$ and person B knows $b$, $E(a)$, $E(b)$ and it is possible to calculate $a+b$ from $E(a)$ and $E(b)$ (that is what you want to do, right? So it must be possible) person A can calculate $a+b$ from the data he has. He also knows $a$ and calculating $b$ given $a+b$ and $a$ is trivial. Now person A knows the secret number of person B and person B can calculate the secret number of A same way.