Yao's Millionaires' problem is a secure multi-party computation problem which was introduced in 1982 by computer scientist and computational theorist Andrew Yao. The problem discusses two millionaires, Alice and Bob, who are interested in knowing which of them is richer without revealing their actual wealth. This problem is analogous to a more general problem where there are two numbers [math]\displaystyle{ a }[/math] and [math]\displaystyle{ b }[/math] and the goal is to determine whether the inequality [math]\displaystyle{ a \geq b }[/math] is true or false without revealing the actual values of [math]\displaystyle{ a }[/math] and [math]\displaystyle{ b }[/math]. The Millionaires' Problem is an important problem in cryptography, the solution of which is used in e-commerce and data mining. Commercial applications sometimes have to compare numbers which are confidential and whose security is important. Many solutions have been introduced for the problem, among which the first solution, presented by Yao himself, was exponential in time and space.
Let [math]\displaystyle{ s=s_{n}s_{n-1} \ldots s_1 \in \{0,1\}^n }[/math] be a binary string of length n.
Denote 0-encoding of s as [math]\displaystyle{ S_s^0 = \{s_{n}s_{n-1} \ldots s_{i+1}1 | ~s_i =0; 1\leq i \leq n \} \, }[/math] and 1-encoding of s as [math]\displaystyle{ S_s^1 = \{s_{n}s_{n-1} \ldots s_{i} | ~s_i =1 ; 1\leq i \leq n \} \,. }[/math]
Then, the protocol is based on the following claim: Assume a and b are binary strings of length n-bits. Then, [math]\displaystyle{ a\gt b }[/math] if the sets [math]\displaystyle{ S_a^1 }[/math] and [math]\displaystyle{ S_b^0 }[/math] have a common element (where here a and b are the binary encodings of the corresponding integers).
The protocol leverages this idea into a practical solution to Yao's Millionaires' problem by performing a private set intersection between [math]\displaystyle{ S_a^1 }[/math] and [math]\displaystyle{ S_b^0 }[/math].
The protocol uses a variant of oblivious transfer, called 1-2 oblivious transfer. In that transfer one bit is transferred in the following way: a sender has two bits [math]\displaystyle{ S_0 }[/math] and [math]\displaystyle{ S_1 }[/math]. The receiver chooses [math]\displaystyle{ i\in\{0,1\} }[/math] and the sender sends [math]\displaystyle{ S_i }[/math] with the oblivious transfer protocol such that
To describe the protocol, Alice's number is indicated as [math]\displaystyle{ a }[/math] and Bob's number as [math]\displaystyle{ b }[/math] and assume that the length of their binary representation is less than [math]\displaystyle{ d }[/math] for some [math]\displaystyle{ d\in N }[/math]. The protocol takes the following steps.
Bob calculates the final result from [math]\displaystyle{ N \oplus \bigoplus_{i=1}^d K'_{i(b_i+1)}=rol(\bigoplus_{i=1}^d K_{i(b_i+1)},u) }[/math] and the result depends on [math]\displaystyle{ c=\bigoplus_{i=1}^d K_{i(b_i+1)} }[/math]. K and therefore c as well, can be split into 3 parts. The left part doesn't affect the result. The right part has all the important information and in the middle there is a sequence of zeros what separate those two parts. The length of each partition of c is linked to the security scheme.
For every i, only one of [math]\displaystyle{ K_{i1},K_{i2} }[/math] has non zero right part and it is [math]\displaystyle{ K_{i1} }[/math] if [math]\displaystyle{ a_i=1 }[/math] and [math]\displaystyle{ K_{i2} }[/math] otherwise. In addition, if [math]\displaystyle{ i\gt j }[/math] and [math]\displaystyle{ K_{il} }[/math] has a non zero right part then [math]\displaystyle{ K_{il} \oplus K_{jl} }[/math] has also a non zero right part and the two leftmost bits of this right part will be the same as the one of [math]\displaystyle{ A_{il} }[/math]. As a result, the right part of c is a function of the entries Bob transferred correspond to the unique bits in a and b and the only bits in the right part in c which are not random are the two leftmost, Exactly the bits which determines the result of [math]\displaystyle{ a_i \gt b_i }[/math] where i is the highest order bit in which a and b differ. In the end, if [math]\displaystyle{ a_i \gt b_i }[/math] then those two leftmost bits will be 11 and Bob will answer that [math]\displaystyle{ a \geq b }[/math]. If the bits are 10 then [math]\displaystyle{ a_i \lt b_i }[/math] and he will answer a<b. If a=b then there will be no right part in c and in this case the two leftmost bits in c will be 11 and will indicate the result.
The information Bob sends to Alice is secure because it is sent through oblivious transfer which is secure.
Bob gets 3 numbers from Alice,
The complexity of the protocol is [math]\displaystyle{ O(d^2) }[/math]. Alice constructs d length number for each bit of a and Bob calculates XOR d times of d length numbers. The complexity of those operations is [math]\displaystyle{ O(d^2) }[/math]. The communication part takes also [math]\displaystyle{ O(d^2) }[/math]. Therefore, the complexity of the protocol is [math]\displaystyle{ O(d^2). }[/math]
The content is sourced from: https://handwiki.org/wiki/Yao%27s_Millionaires%27_Problem