Yao's Millionaires' Problem

From HandWiki
Short description: Problem in mathematics

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.[1]

Protocols and proof

The protocol of Hsiao-Ying Lin and Wen-Guey Tzeng[2]

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 of Ioannidis & Ananth[3]

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

  1. the receiver doesn't get any information about [math]\displaystyle{ S_{(1-i)} }[/math],
  2. the value of [math]\displaystyle{ i }[/math] is not exposed to the sender.

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.

  1. Alice creates a matrix [math]\displaystyle{ K }[/math] of size [math]\displaystyle{ d\times2 }[/math] of [math]\displaystyle{ k }[/math]-bit numbers, where [math]\displaystyle{ k }[/math] is the length of the key in the oblivious transfer protocol. In addition, she chooses two random numbers [math]\displaystyle{ u }[/math] and [math]\displaystyle{ v }[/math] where [math]\displaystyle{ 0 \leq u\lt 2k }[/math] and [math]\displaystyle{ v \leq k }[/math].
  2. [math]\displaystyle{ K_{ijl} }[/math] will be the [math]\displaystyle{ l }[/math]-th bit of the number which appears in cell [math]\displaystyle{ K_{ij} }[/math] (where [math]\displaystyle{ l=0 }[/math] indicates the least significant bit). In addition, [math]\displaystyle{ a_i }[/math] is denoted as the [math]\displaystyle{ i }[/math]-th bit of Alice's number [math]\displaystyle{ a }[/math]. For every [math]\displaystyle{ i }[/math], [math]\displaystyle{ 1 \leq i \leq d }[/math] Alice does the following actions.
    1. For every bit [math]\displaystyle{ j \geq v }[/math] she sets [math]\displaystyle{ K_{i1j} }[/math] and [math]\displaystyle{ K_{i2j} }[/math] to random bits.
    2. If [math]\displaystyle{ a_i=1 }[/math] let [math]\displaystyle{ l=1 }[/math] otherwise let [math]\displaystyle{ l=2 }[/math] and for every [math]\displaystyle{ j, 0 \leq j \leq 2 \cdot i -1 }[/math] set [math]\displaystyle{ K_{ilj} }[/math] to a random bit.
    3. For [math]\displaystyle{ m=2 \cdot i }[/math] set [math]\displaystyle{ K_{il(m+1)}=1 }[/math] and [math]\displaystyle{ K_{ilm} }[/math] to [math]\displaystyle{ a_i }[/math].
    4. For every [math]\displaystyle{ i, 1 \leq i \lt d }[/math], [math]\displaystyle{ S_i }[/math] will be a random [math]\displaystyle{ k }[/math]-bit number and [math]\displaystyle{ S_d }[/math] will be another number of [math]\displaystyle{ k }[/math] bits where all bits except the last two are random and the last two are calculated as [math]\displaystyle{ S_{d(k-1)}=1 \oplus \bigoplus_{j=1}^{d-1}S_{j(k-1)}\oplus \bigoplus_{j=1}^{d}K_{j1(k-1)} }[/math] and [math]\displaystyle{ S_{d(k-2)}=1 \oplus \bigoplus_{j=1}^{d-1}S_{j(k-2)}\oplus \bigoplus_{j=1}^{d}K_{j1(k-2)} }[/math], where [math]\displaystyle{ \bigoplus }[/math] is the bitwise XOR operation.
    5. For [math]\displaystyle{ l=1,2 }[/math] set [math]\displaystyle{ K'_{ij}=rot(K_{il} \oplus S_i,u) }[/math]. Where [math]\displaystyle{ rot(x,t) }[/math] indicates the bitwise rotation of [math]\displaystyle{ x }[/math] to the left by [math]\displaystyle{ t }[/math] bits.
  3. For every [math]\displaystyle{ i }[/math], [math]\displaystyle{ 0 \leq i \leq d }[/math] Bob transfers [math]\displaystyle{ K'_{il} }[/math] with the oblivious transfer protocol where [math]\displaystyle{ l=b_i+1 }[/math] and [math]\displaystyle{ b_i }[/math] is the [math]\displaystyle{ i }[/math]-th bit of [math]\displaystyle{ b }[/math].
  4. Alice sends to Bob [math]\displaystyle{ N=rot(\bigoplus_{j=1}^d S_j,u) }[/math].
  5. Bob calculates the bitwise XOR of all the numbers he got in step 3 and [math]\displaystyle{ N }[/math] from step 4. Bob scans the result from left to right until he finds a large sequence of zero bits. Let [math]\displaystyle{ c }[/math] be the bit to the right of that sequence ([math]\displaystyle{ c }[/math] is non zero). If the bit to the right of [math]\displaystyle{ c }[/math] equals 1 then [math]\displaystyle{ a \geq b }[/math]. otherwise [math]\displaystyle{ a \lt b }[/math].



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,

  1. [math]\displaystyle{ rol(K_{i(1+b_i)} \oplus S_i ,u) }[/math] for every [math]\displaystyle{ i }[/math] Bob receives one such number and [math]\displaystyle{ S_i }[/math] is random so no secure information is transformed,
  2. N, This is an XOR of random numbers and therefore reveals no information. The relevant information is revealed only after calculating c and,
  3. c, The same goes for c. The left part of c is random and the right part is random as well except from the two leftmost bits. Deducing any information from those bits requires guessing some other values and the chance of guessing them correct is very low.


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]

See also

External links


  1. Yao, Andrew C. (November 1982). "Protocols for secure computations". FOCS 23rd Annual Symposium on Foundations of Computer Science (FOCS 1982): 160–164. doi:10.1109/SFCS.1982.88. 
  2. Lin, Hsiao-Ying; Tzeng, Wen-Guey (2005-06-07) (in en). An Efficient Solution to the Millionaires' Problem Based on Homomorphic Encryption. Lecture Notes in Computer Science. 3531. 456–466. doi:10.1007/11496137_31. ISBN 978-3-540-26223-7. 
  3. Ioannidis, I.; Grama, A. (2003) (in en-US). An efficient protocol for Yao's millionaires' problem. IEEE. doi:10.1109/hicss.2003.1174464. ISBN 978-0769518749.