I have just found out about the homomorphic encryption and I was wondering how is it possible to perform an addition for more than two parties?
More concretely, I want to have several parties $P_i$, each of which picks a value $p_i$ only known to themselves. Now I want another party $R$ to only learn $r=\sum p_i$, that is the sum of all the private values, but $R$ must not learn any specific $p_i$ and $P_i$ may not learn $p_j$ unless $i=j$.
From my understanding so far, the way the Homomorphic Encryption works is that you have $A=2$ and $B=3$ as values then you get the encrypted values $E(A)$ and $E(B)$. Then $E(A+B)$ it's computed and when you decrypt $E(A+B)$, one gets the correct result which is $5$.
What if you would like to do $A+B+C$, where $C=4$, with the homomorphic encryption? How will the private keys be allocated so that $A,B$ and $C$ can receive the final result ($9$), while they don't know the values of each other?
(P.S.: I am a student and I am asking this only for my academic curiosity. I am not currently taking any crypto course, so that's why I would really appreciate your help!)