ArticleslgStudy

computer science

Garbled circuit

Garbled circuit is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Garbled circuit rather than just read about it. In short: Garbled circuit is a cryptographic protocol that enables two-party secure computation in which two mistrusting parties can jointly evaluate a function over their private inputs without the presence of a trusted third party. In the garbled circuit protocol, the function has to be described as a Boolean circuit.

Garbled circuit — main illustration
Garbled circuit — illustration

Key takeaways

  • Garbled circuit belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Garbled circuit to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Garbled circuit from memory before moving on to harder problems.

Reference excerpt

Garbled circuit is a cryptographic protocol that enables two-party secure computation in which two mistrusting parties can jointly evaluate a function over their private inputs without the presence of a trusted third party. In the garbled circuit protocol, the function has to be described as a Boolean circuit.

History The history of garbled circuits is complicated. The invention of garbled circuit was credited to Andrew Yao, as Yao introduced the idea in the oral presentation of a paper in FOCS'86. This was documented by Oded Goldreich in 2003. The first written document about this technique was by Goldreich, Micali, and Wigderson in STOC'87. The term "garbled circuit" was first used by Beaver, Micali, and Rogaway in STOC'90. Yao's protocol solving Yao's Millionaires' Problem was the beginning example of secure computation, yet it is not directly related to garbled circuits.

Background

Oblivious transfer In the garbled circuit protocol, we make use of oblivious transfer. In the oblivious transfer, a string is transferred between a sender and a receiver in the following way: a sender has two strings S0 and S1. The receiver chooses b∈{0,1} and the sender sends Sb with the oblivious transfer protocol such that

the receiver doesn't gain any information about the unsent string S(1−b), the value of b is not exposed to the sender. Note that while the receiver doesn't know the S0,S1 values, in practice the receiver knows some information about what Sb encodes so that the receiver is not blindly choosing b. That is, if S0 encodes a false value, S1 encodes a true value and the receiver wants to get the encoded true value, the receiver chooses b=1. The oblivious transfer can be built using asymmetric cryptography like the RSA cryptosystem.

Definitions and notations Operator ∥ is string concatenation. Operator ⊕ is bit-wise XOR. k is a security parameter and the length of keys. It should be greater than 80 and is usually set at 128.

Garbled circuit protocol The protocol consists of 6 steps as follows:

The underlying function (e.g., in the millionaires' problem, comparison function) is described as a Boolean circuit with 2-input gates. The circuit is known to both parties. This step can be done beforehand by a third-party. Alice garbles (encrypts) the circuit. We call Alice the garbler. Alice sends the garbled circuit to Bob along with her encrypted input. In order to calculate the circuit, Bob needs to garble his own input as well. To this end, he needs Alice to help him, because only the garbler knows how to encrypt. Finally, Bob can encrypt his input through oblivious transfer. In terms of the definition from above, Bob is the receiver and Alice the sender at this oblivious transfer. Bob evaluates (decrypts) the circuit and obtains the encrypted outputs. We call Bob the evaluator. Alice and Bob communicate to learn the output.

Circuit generation The Boolean circuit for small functions can be generated by hand. It is conventional to make the circuit out of 2-input XOR and AND gates. It is important that the generated circuit has the minimum number of AND gates (see Free XOR optimization). There are methods that generate the optimized circuit in term of number of AND gates using logic synthesis technique. The circuit for the Millionaires' Problem is a digital comparator circuit (which is a chain of full adders working as a subtractor and outputting the carry flag). A full adder circuit can be implemented using only one AND gate and some XOR gates. This means the total number of AND gates for the circuit of the Millionaires' Problem is equal to the bit-width of the inputs.

Garbling

Alice (garbler) encrypts the Boolean circuit in this step to obtain a garbled circuit. Alice assigns two randomly generated strings called labels to each wire in the circuit: one for Boolean semantic 0 and one for 1. (The label is k-bit long where k the security parameter and is usually set to 128.) Next, she goes to all the gates in the circuit and replaces 0 and 1 in the truth tables with the corresponding labels. The table below shows the truth table for an AND gate with two inputs wa,wb and output wc:

Alice replaced 0 and 1 with the corresponding labels:

She then encrypts the output entry of the truth table with the corresponding two input labels. The encrypted table is called garbled table. This is done such that one can decrypt the garbled table only if he has the correct two input labels. In the table below, Encκ(X) is a double-key symmetric encryption in which κ is the secret key and X is the value to be encrypted (see Fixed-Key Blockcipher).

After this, Alice randomly permutes the table such that the output value cannot be determined from the row. The protocol's name, garbled, is derived from this random permutation.

Data transfer Alice sends the computed garbled tables for all gates in the circuit to Bob. Bob needs input labels to open the garbled tables. Thus, Alice chooses the labels corresponding to her input a and sends them to Bob. For example, if Alice's input is 𝐚=a4a3a2a1a0=01101, then she sends X0a4, X1a3, X1a2, X0a1, and X1a0 to Bob. Bob will not learn anything about Alice's input, 𝐚, since the labels are randomly generated by Alice and they look like random strings to Bob. Bob needs the labels corresponding to his input as well. He receives his labels through oblivious transfers for each bit of his input. For example, if Bob's input is 𝐛=b4b3b2b1b0=10100, Bob first asks for b0=0 between Alice's labels X0b0 and X1b0. Through a 1-out-of-2 oblivious transfer, he receives X0b0 and so on. After the oblivious transfers, Alice will not learn anything about Bob's input and Bob will not learn anything about the other labels.

Evaluation After the data transfer, Bob has the garbled tables and the input labels. He goes through all gates one by one and tries to decrypt the rows in their garbled tables. He is able to open one row for each table and retrieve the corresponding output label: Xc=DecXa,Xb(garbled_table[i]), where 0≤i≤3. He continues the evaluation until he reaches to the output labels.

Revealing output After the evaluation, Bob obtains the output label, Xc, and Alice knows its mapping to Boolean value since she has both labels: X0c and X1c. Either Alice can share her information to Bob or Bob can reveal the output to Alice such that one or both of them learn the output.

Optimization

… excerpt ends here. Continue reading the full article.

Illustrations

Garbled circuit: Construction of the truth table of an AND gate
Construction of the truth table of an AND gate

Worked examples

Example 1 — a first encounter with Garbled circuit

Start with the simplest possible case. Write down what Garbled circuit claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Garbled circuit before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Garbled circuit ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Garbled circuit

In research
Garbled circuit appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Garbled circuit in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Garbled circuit is common in secondary-school and first-year university syllabi. It links to neighbouring topics Cryptographic protocols, Theory of cryptography, so understanding it makes those chapters shorter.
In everyday life
Look for Garbled circuit outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Garbled circuit” →

How to study Garbled circuit in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Garbled circuit means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Garbled circuit out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Garbled circuit in simple terms?

Garbled circuit is a cryptographic protocol that enables two-party secure computation in which two mistrusting parties can jointly evaluate a function over their private inputs without the presence of a trusted third party. In the garbled circuit protocol, the function has to be described as a Bool…

Why does Garbled circuit matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Garbled circuit?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Garbled circuit.

Tags

  • Cryptographic protocols
  • Theory of cryptography

Keep exploring