Is this related to that one algorithm where 3 people can find out who makes the most money without any of them knowing what the other makes, and without consulting a 4th person? That one always felt like black magic to me.
[0] https://en.wikipedia.org/wiki/Yao%27s_Millionaires%27_proble...