(DRAFT) Garbled Circuits for Three-Party Computation

Imagine a group of people have some private data, and they want to jointly compute a function of their private data, without sharing any of the data. Maybe they want to know the median of their salaries, without anyone revealing their own. Maybe a group of doctors wants to collaborate on a statistical study, without sharing any data about individual patients. This is the problem that multiparty computation solves.

If you haven’t thought about this before, you’ll want to start with the special case of two-party computation, which rests on Yao’s garbled circuits protocol and a technique called oblivious transfer. This post by Gubsheep walks you through understanding how you would discover the protocol on your own. If you just want to see the protocol, Vitalik’s post is also very good.

In this post I’m going to explain how to upgrade two-party computation to handle computations between three (or more) people, still using the basic idea of garbled circuits.

For this post, we’re going to assume that all three parties carry out the protocol honestly… One could ask for stronger security guarantees. There are lots of different 3PC protocols, with different tradeoffs among security and complexity. There are also lots of good ideas that we won’t get into in this blog post – for example, “cut-and-choose”.

A three-party version of oblivious transfer

Alice has 4 messages: . Bob and Carol each have a private bit – call them and . Alice wants to transmit to Carol, in such a way that:

If you’ve seen plain vanilla two-party oblivious transfer, it’s not hard to come up with a protocol. Here’s one:

(b, c)
(0, 0)
(0, 1)
(1, 0)
(1, 1)

Why is this secure?

Toward a 3PC Protocol

Let’s make a couple of observations.

To make this work, Alice needs to give Bob (and Carol, but we’ll focus on Bob for now) a for each of his two bits. So Alice chooses at random 4 symmetric keys, . Using two OTs, Alice transfers to Bob the key corresponding to his first bit and the key corresponding to his second bit. Now Bob computes a symmetric key . Alice does the same with Carol.

Now there are four possibilities for and four possibilities for , and Alice knows all of them. So Alice can publish a table – just like the table above, but with 16 rows – and at the end of the protocol, Carol learns only the one value she’s supposed to.

In the actual protocol, Bob has 3 bits , Carol has 2 bits , and Alice’s table has rows.

Secret shares

Just like in the 2PC protocol, each bit – each “wire” in the circuit – will be jointly held by Alice, Bob, and Carol, in the form of “secret shares”. In other words: Alice will hold a bit , Bob , and Carol , with the property that .

In our protocol, Alice and Bob will choose her bit at random. We might as well as choose Bob’s shares of gate output bits by simply setting them all equal to , Bob’s first input bit. (This lets Alice send Bob his keys without using extra oblivious transfers.) And then will be determined from the inputs to the gate, and , by the rule .

The Protocol

Just as in the usual 2PC garbled circuits protocol, Alice sets up the initial “garbling” of the circuit.

We set up some notation first. Number Bob’s inputs and . Number the gates , in some order (so that the inputs to each are either inputs to the circuit, or outputs of previous gates).

Let’s call all the bits (wires) in the circuit . So is just another name for Bob’s inputs , and similarly for Carol’s inputs. We’ll call the three parties’ shares of the bit .

(b_i, b_j, b_k, c_j, c_k)

Security

First of all, notice that until the very last step information only ever travels from Alice –> Bob –> Carol. So (if the three parties don’t communicate outside the protocol) Alice can’t learn anything about Bob’s or Carol’s inputs, and Bob can’t learn anything about Carol’s.

Bob doesn’t learn anything about Alice’s inputs, either, since he only ever sees encrypted messages. And Carol only ever learns the bits , which are guaranteed to be uniformly random, because they are computed by , and is chosen uniformly at random.

But there’s a more interesting question: If two of Alice, Bob and Carol team up, can they learn the third person’s inputs?

Alice and Bob can’t learn anything about Carol’s inputs, because Carol never sends them any messages.

What can Bob and Carol learn? Even if they collaborate, they can’t possibly learn more than the one row from each table. So they can learn and for each , but again that tells them nothing they didn’t already know, because Bob chose and is random.

Alice and Carol can learn something, though. If Carol tells Alice which row of the table Bob sent her, Alice can work out Bob’s bit . But was the same as Bob’s input bit . Even worse, once they know , they can figure out for every .

Things get even worse if the players don’t carry out the protocol honestly. Bob and Carol are constrained by the encryption: they only ever find out one key per bit, so they can only read the “correct” row of the table. But our protocol relies on Alice to garble the circuit correctly in the first place. Nothing stops a malicious Alice from writing any circuit she pleases.

We’ll leave this as an example of a 3PC protocol and the level of security it affords – but if you want to know more, read about the “cut and choose” method.