\(
\renewcommand{\SIM}{\mathsf{SIM}}
\renewcommand{\VIEW}{\mathsf{VIEW}}
\renewcommand{\KeyGen}{\mathsf{KeyGen}}
\renewcommand{\OblivKeyGen}{\mathsf{OblivKeyGen}}
\renewcommand{\Enc}{\mathsf{Enc}}
\renewcommand{\Dec}{\mathsf{Dec}}
\)
Oblivious transfer (OT) is an important primitive in cryptography, especially in the area of secure multi-party computation. We already saw how it can be used in practice, described in our blog post on garbled circuits. In this post, we will look at it in more detail and give a concrete instantiation.
What is Oblivious Transfer
Oblivious transfer is a protocol that’s carried out between two parties, a sender and a receiver. To understand what it does, let’s treat the protocol as a black-box and only look at the input and output. In the simplest case, the sender’s input is two bits \(b_0\) and \(b_1\), the receiver’s input is one bit, \(c\), also known as the choice bit. At the end of the protocol execution, the receiver gets back \(b_c\) (that is, if \(c = 0\), receiver gets \(b_0\), if \(c = 1\), receiver gets \(b_1\)). This is called 1-out-of-2 OT. An illustration of the protocol can be found in the diagram below.
| Sender(\(b_0\), \(b_1\)) | Receiver(\(c\)) | |
|---|---|---|
| \(b_0, b_1 \rightarrow\) | OT | \(\leftarrow c\) |
| Black-box | \(b_c \rightarrow\) |
Security Definition
Of course, we can easily achieve the functionality outlined above by simply having the receiver send the choice bit to the sender and then have the sender send the correct bit back. But this only gives us the “transfer” part of oblivious transfer, not the “oblivious” part. Concretely, for the protocol to be secure (oblivious), we need the following two properties. These properties are defined in terms of a simulator, which is an important paradigm for defining the security of cryptographic protocols as well as proving the security. Readers who are unfamiliar with this technique is encouraged to read our blog post on this topic.
Sender security: there exists a simulator \(\SIM_S(1^k, b_0, b_1) \approx \VIEW_S(b_0, b_1, c, \text{coins})\). In other words, we can create a simulator to generate a protocol transcript that is indistinguishable from the real protocol transcript without knowing what \(c\) is.
Receiver security: there exists a simulator \(\SIM_R(1^k, c, b_c) \approx \VIEW_R(b_0, b_1, c, \text{coins})\). Similarly, this means we can create a simulator to generate a protocol transcript that is indistinguishable from the real protocol without knowing the bit that the receiver did not choose, \(b_{1-c}\).
The coins are used in the (probabilistic) encryption scheme and the key generation algorithms which is used in the concrete construction (see later) of the OT protocol. We assume this is implicit so we do not pass these coins explicitly to the algorithm. The adversary model we consider is semi-honest, meaning the sender or receiver follow the protocol faithfully, but they may try to gain extra information from the messages they receive.
Applications
OT is often used as a building block in other multiparty computation protocols. Our blog post on garbled circuits describes a concrete example where OT is used to send the input from the garbler to the evaluator. We describe a very simple example here: securely computing the AND (\(\land\)) of two bits. The sender and receiver each have one bit, \(b\) and \(c\), and they want to compute \(d = b \land c\) in a secret shared form, that is \(d = x \oplus y\), where \(\oplus\) is XOR. When the output is in secret shared form, it does not leak any information about the input bits, so the two parties may use it for further computation. Of course, they can also send each other the output to reconstruct \(d\). The protocol is shown in the diagram below.
| Sender(\(b\)) | Receiver(\(c\)) | |
|---|---|---|
| pick random \(b_0\) | ||
| let \(b_1 = b_0 \oplus b\) | ||
| \(b_0, b_1 \rightarrow\) | OT | \(\leftarrow c\) |
| Black-box | \(b_c \rightarrow\) | |
| output \(x = b_0\) | output \(y = b_c\) |
To show that the protocol indeed outputs \(x\) and \(y\) such that \(x \oplus y = b \land c\), we write \(b_c = c \land b_1 \oplus (1 \oplus c) \land b_0 = c \land (b_1 \oplus b_0) \oplus b_0\). Before we interpreted \(b_c\) as the \(c\)’th choice from the sender’s input, rewriting it is simply another way to express the same logic. Now if we compute \(b_0 \oplus b_c\), which are the two outputs, we indeed end up with \(c \land b\).
Having the ability to compute AND is extremely useful since any binary circuits can be expressed using XOR and AND. In fact, computing AND is the much harder part which requires parties to communicate to each other. Computing XOR is easy. When the inputs are already secret shared, XOR computation can be performed locally. For instance, if Alice has input \(x = x_1 \oplus x_2\) and Bob has \(y = y_1 \oplus y_2\), and assume these inputs are already shared, i.e., Alice holds \(x_1\) and \(y_1\) and Bob holds \(x_2\) and \(y_2\). Then they can compute \(z = x \oplus y = z_1 \oplus z_2\) where Alice holds \(z_1\) and Bob holds \(z_2\) by computing \(z_1 = x_1 \oplus y_1\) and \(z_2 = x_2 \oplus y_2\). In fact, this is the basis of the GMW [1] protocol, using local computation for XOR gates and OT for AND gates.
Concrete construction based on ElGamal
This section gives a concrete construction of an OT protocol based on ElGamal, or any public key encryption scheme (which consist of three algorithm, \(\KeyGen\), \(\Enc\) and \(\Dec\)) that satisfies a few properties. Firstly, the scheme needs to be CPA-secure. That is, the ciphertext must be randomized, so textbook RSA does not work. Secondly, there must exist an \(\OblivKeyGen\) function. This function outputs a fake public key that is indistinguishable from a real public key without knowing the secret part.
The protocol is given in the diagram below. In essence, what happens in the protocol is that the receiver generates two public keys but only one secret key is know. The secret key that it knows corresponds to its choice bit \(c\). Then the receiver sends the two public keys to the sender, who will use them to encrypt both of its inputs, and then send it back to the receiver. Finally, since the receiver only knows the “right” secret key for decrypting the bit that he’s interested in \(b_c\), he’s able to do so without learning the other bit.
| Sender(b_0, b_1) | Receiver(c) | |
|---|---|---|
| \((pk_c, sk_c) \leftarrow \KeyGen()\) | ||
| \(pk_{c-1} \leftarrow \OblivKeyGen()\) | ||
| \(\leftarrow pk_0, pk_1\) | ||
| \(ct_0 \leftarrow \Enc_{pk_0}(b_0)\) | ||
| \(ct_1 \leftarrow \Enc_{pk_1}(b_1)\) | ||
| \(ct_0, ct_1 \rightarrow\) | ||
| \(b_c \leftarrow \Dec_{sk_c}(ct_c)\) |
Security Intuition
Here we give an informal version of the security proof using the simulation technique. The goal in a simulation-based security proof is to give a simulator and then show its output is indistinguishable from the view.
Let’s start by proving the sender security, which is the simpler case. Here is the simulator program:
- Generate \(pk_0\) and \(pk_1\) by running \(\OblivKeyGen\)
- Set \(b_0\) and \(b_1\) as its input
The only thing that’s different in this simulator is that one of the public keys is generated using \(\OblivKeyGen\) instead of the normal key generation algorithm. So we just need to show that a random public key sampled from \(\OblivKeyGen\) is indistinguishable from the real public key generation algorithm \(\KeyGen\). In fact, this is the definition of \(\OblivKeyGen\) so we’ve shown sender security.
Next let’s look at the receiver simulator. Here’s the program:
- Let \(b_{1-c} \leftarrow 0\) (using 1 also works)
- Let \(ct_c \leftarrow \Enc_{pk_c}(b_c)\)
- Let \(ct_{1-c} \leftarrow \Enc_{pk_{1-c}}(b_{1-c})\)
Note that the only difference between the simulator and the real-world view is that the simulator does not know \(b_{1-c}\) and it is generated at random. For the simulation to be indistinguishable from the view, we rely on the fact that \(\Enc_{pk_{1-c}}(0)\) is indistinguishable from \(\Enc_{pk_{1-c}}(1)\). This fact holds because we’re using a CPA-secure encryption scheme.
We mentioned that the protocol is only secure in the semi-honest setting in the Security Definition section. Here is an easy example of how the protocol breaks when an active adversary is involved. Suppose the receiver is an active attacker, it could generate \(pk_{c-1}\) using \(\KeyGen\) instead of \(\OblivKeyGen\), then it will have both secret keys to decrypt \(ct_0\) and \(ct_1\).
Conclusion
What we saw was the most basic version of OT, the 1-out-of-2 OT. With this simple protocol, we can easily build a 1-out-of-n OT. The easiest way is to have the receiver input the demultiplexed representation of the choice value \(i\), that is a bit-string of length \(n\) with the \(i\)th bit set to 1 and the rest are set to 0 and then perform \(n\) 1-out-of-2 OTs with the sender. While this protocol is simple, it’s not efficient. More efficient protocols exist (for example the one by Naor and Pinkas [2]) where only \(\log(n)\) 1-out-of-2 OTs are needed instead of \(n\).
There are many other variations such as random OT (where the receiver “picks” a random \(c\) instead of a \(c\) of its choice) or correlated OT (where sender’s inputs are correlated). Furthermore, a very important optimization to the standard OT is called OT-extension. Note that to transfer a single bit, we need to do two encryption and one decryption, which can become quite expensive when a lot of bits need to be transferred. OT-extension is a way to transfer a lot of bits, even millions, using only a few hundred standard OTs. This technique is a bit more involved, so it will be the topic of a future blog post.
[1] https://dl.acm.org/doi/abs/10.1145/3335741.3335755
[2] http://www.wisdom.weizmann.ac.il/~naor/PAPERS/ope.pdf


