How can four employees calculate the average of their salaries without knowing other's salary using RSA?

10.6k Views Asked by At

I know of a solution. But this has a limitation that information is partially passed around and there needs some trust level. I'm wondering if any variant of public-private key (e.g. RSA) algorithm can solve this.

--Spoiler Alert: solution without RSA--

Salary of A:  x
Salary of B:  y
Salary of C:  z
Salary of D: u

A passes to B  (x + a) where a is a number that A knows
B takes this a passes to C (x + y + a + b)
C takes this and passes to D (x + y + z + a + b + c)
D takes this and passes to A (x  + y + z + u + a + b + c + d)

Now one after another they strip their constants. Ex: A now passes to B:  x + y + z + u + b + c + d (She has stripped of A) and B passes to C after stripping of her constant (b).

Thus Finally D gets x + y + z + u + d. She takes away her constant and now she has x + y + z + u.
So she can publish the average (x + y + z + u) /4.
2

There are 2 best solutions below

2
On

Look up homomorphic encryption on Wikipedia.

2
On

Why not do it this way?

Get four randomly generated numbers, $m, n, l, k.$

Four persons' salaries are $a, b, c, d.$

Write the $4$ random numbers in four pieces of paper, put the paper into a jar. People draw the paper, substract her own salary with the random number, submit the answers. Then they together can add the answers together and add back $(m+n+l+k)$. This will give them the sum of their salaries and so the average.

Since the numbers are randomly distributed, no one would know exactly what numbers others get so they cannot recover from the substracted numbers to the original salaries of others.