Yao's Garbled Circuit
   HOME

TheInfoList



OR:

Garbled circuit is a
cryptographic protocol A cryptographic protocol is an abstract or concrete Communications protocol, protocol that performs a information security, security-related function and applies cryptographic methods, often as sequences of cryptographic primitives. A protocol desc ...
that enables two-party secure computation in which two mistrusting parties can jointly evaluate a
function Function or functionality may refer to: Computing * Function key, a type of key on computer keyboards * Function model, a structured representation of processes in a system * Function object or functor or functionoid, a concept of object-orie ...
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 In computational complexity theory and circuit complexity, a Boolean circuit is a mathematical model for combinational digital logic circuits. A formal language can be decided by a family of Boolean circuits, one circuit for each possible inpu ...
. The history of garbled circuits is complicated. The invention of garbled circuit was credited to
Andrew Yao Andrew Chi-Chih Yao ( zh , c = 姚期智 , p = Yáo Qīzhì; born December 24, 1946) is a Chinese computer scientist, physicist, and computational theorist. He is currently a professor and the dean of Institute for Interdisciplinary Informati ...
, as Yao introduced the idea in the oral presentation of a paper in FOCS'86. This was documented by
Oded Goldreich Oded Goldreich (; born 1957) is a professor of computer science at the faculty of mathematics and computer science of the Weizmann Institute of Science, Israel. His research interests lie within the theory of computation and are, specifically, ...
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 cryptography, an oblivious transfer (OT) protocol is a type of protocol in which a sender transfers one of potentially many pieces of information to a receiver, but remains oblivious as to what piece (if any) has been transferred. The first fo ...
. In the oblivious transfer, a
string String or strings may refer to: *String (structure), a long flexible structure made from threads twisted together, which is used to tie, bind, or hang other objects Arts, entertainment, and media Films * ''Strings'' (1991 film), a Canadian anim ...
is transferred between a sender and a receiver in the following way: a sender has two strings S_0 and S_1. The receiver chooses b\in\ and the sender sends S_b with the oblivious transfer protocol such that # the receiver doesn't gain any information about the unsent string S_, # the value of b is not exposed to the sender. Note that while the receiver doesn't know the S_, S_ values, in practice the receiver knows some information about what S_ encodes so that the receiver is not blindly choosing b. That is, if S_ encodes a false value, S_ encodes a true value and the receiver wants to get the encoded true value, the receiver chooses b=1. The
oblivious transfer In cryptography, an oblivious transfer (OT) protocol is a type of protocol in which a sender transfers one of potentially many pieces of information to a receiver, but remains oblivious as to what piece (if any) has been transferred. The first fo ...
can be built using
asymmetric cryptography Public-key cryptography, or asymmetric cryptography, is the field of cryptographic systems that use pairs of related keys. Each key pair consists of a public key and a corresponding private key. Key pairs are generated with cryptographic alg ...
like the
RSA cryptosystem The RSA (Rivest–Shamir–Adleman) cryptosystem is a public-key cryptosystem, one of the oldest widely used for secure data transmission. The initialism "RSA" comes from the surnames of Ron Rivest, Adi Shamir and Leonard Adleman, who publicly ...
.


Definitions and notations

Operator \parallel is string
concatenation In formal language theory and computer programming, string concatenation is the operation of joining character strings end-to-end. For example, the concatenation of "snow" and "ball" is "snowball". In certain formalizations of concatenati ...
. Operator \oplus is bit-wise
XOR Exclusive or, exclusive disjunction, exclusive alternation, logical non-equivalence, or logical inequality is a logical operator whose negation is the logical biconditional. With two inputs, XOR is true if and only if the inputs differ (one ...
. k is a
security parameter In cryptography, a security parameter is a way of measuring of how "hard" it is for an adversary to break a cryptographic scheme. There are two main types of security parameter: ''computational'' and ''statistical'', often denoted by \kappa and ...
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 In computational complexity theory and circuit complexity, a Boolean circuit is a mathematical model for combinational digital logic circuits. A formal language can be decided by a family of Boolean circuits, one circuit for each possible inpu ...
for small functions can be generated by hand. It is conventional to make the circuit out of 2-input
XOR Exclusive or, exclusive disjunction, exclusive alternation, logical non-equivalence, or logical inequality is a logical operator whose negation is the logical biconditional. With two inputs, XOR is true if and only if the inputs differ (one ...
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 In computer engineering, logic synthesis is a process by which an abstract specification of desired circuit behavior, typically at register transfer level (RTL), is turned into a design implementation in terms of logic gates, typically by a co ...
technique. The circuit for the Millionaires' Problem is a
digital comparator A digital comparator or magnitude comparator is a Computer hardware, hardware electronic device that takes two numbers as input in Binary numeral system, binary form and determines whether one number is greater than, less than or equal to the o ...
circuit (which is a chain of
full adder An adder, or summer, is a digital circuit that performs addition of numbers. In many computers and other kinds of processors, adders are used in the arithmetic logic units (ALUs). They are also used in other parts of the processor, where they ar ...
s working as a subtractor and outputting the
carry flag In computer processors, the carry flag (usually indicated as the C flag) is a single bit in a system status register A status register, flag register, or condition code register (CCR) is a collection of status Flag (computing), flag bits for a ...
). A full adder circuit can be implemented using only one AND gate and some
XOR Exclusive or, exclusive disjunction, exclusive alternation, logical non-equivalence, or logical inequality is a logical operator whose negation is the logical biconditional. With two inputs, XOR is true if and only if the inputs differ (one ...
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 computational complexity theory and circuit complexity, a Boolean circuit is a mathematical model for combinational digital logic circuits. A formal language can be decided by a family of Boolean circuits, one circuit for each possible inpu ...
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 In cryptography, a security parameter is a way of measuring of how "hard" it is for an adversary to break a cryptographic scheme. There are two main types of security parameter: ''computational'' and ''statistical'', often denoted by \kappa and ...
and is usually set to 128.) Next, she goes to all the gates in the circuit and replaces 0 and 1 in the
truth table A truth table is a mathematical table used in logic—specifically in connection with Boolean algebra, Boolean functions, and propositional calculus—which sets out the functional values of logical expressions on each of their functional arg ...
s with the corresponding labels. The table below shows the truth table for an
AND gate The AND gate is a basic digital logic gate that implements the logical conjunction (∧) from mathematical logic AND gates behave according to their truth table. A HIGH output (1) results only if all the inputs to the AND gate are HIGH (1). If a ...
with two inputs w^a, w^b and output w^c: Alice replaced 0 and 1 with the corresponding labels: She then encrypts the output entry of the
truth table A truth table is a mathematical table used in logic—specifically in connection with Boolean algebra, Boolean functions, and propositional calculus—which sets out the functional values of logical expressions on each of their functional arg ...
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_\kappa(X) is a double-key
symmetric encryption Symmetric-key algorithms are algorithms for cryptography that use the same cryptographic keys for both the encryption of plaintext and the decryption of ciphertext. The keys may be identical, or there may be a simple transformation to go between t ...
in which \kappa 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 \mathbf = a_4a_3a_2a_1a_0 = 01101, then she sends X_0^, X_1^, X_1^, X_0^, and X_1^ to Bob. Bob will not learn anything about Alice's input, \mathbf, 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 transfer In cryptography, an oblivious transfer (OT) protocol is a type of protocol in which a sender transfers one of potentially many pieces of information to a receiver, but remains oblivious as to what piece (if any) has been transferred. The first fo ...
s for each bit of his input. For example, if Bob's input is \mathbf = b_4b_3b_2b_1b_0 = 10100, Bob first asks for b_0=0 between Alice's labels X_0^ and X_1^. Through a 1-out-of-2
oblivious transfer In cryptography, an oblivious transfer (OT) protocol is a type of protocol in which a sender transfers one of potentially many pieces of information to a receiver, but remains oblivious as to what piece (if any) has been transferred. The first fo ...
, he receives X_0^ and so on. After the
oblivious transfer In cryptography, an oblivious transfer (OT) protocol is a type of protocol in which a sender transfers one of potentially many pieces of information to a receiver, but remains oblivious as to what piece (if any) has been transferred. The first fo ...
s, 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: X^c = Dec_(garbled\_table , where 0\le i \le 3. He continues the evaluation until he reaches to the output labels.


Revealing output

After the evaluation, Bob obtains the output label, X^c, and Alice knows its mapping to Boolean value since she has both labels: X_0^c and X_1^c. 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


Point-and-permute

In this optimization, Alice generates a random bit, s, called select bit for each wire w. She sets the first bit of label 0, X_0^a to s and the first bit of label 1, X_1^a, to \bar ( NOT of s). She does the same for wire w^b. She then, instead of randomly permuting, sorts the garbled table according to the inputs select bits. This way, Bob does not need to test all four rows of the table to find the correct one, since he receives the pointer bits with each wire label and can find the correct row and decrypt it with one attempt. This reduces the evaluation load by 4 times. It also does not reveal anything about the output value because the select bits are randomly generated.


Row reduction

This optimization reduces the size of garbled tables from 4 rows to 3 rows. Here, instead of generating a label for the output wire of a gate randomly, Alice generates it using a function of the input labels. She generates the output labels such that the first entry of the garbled table becomes all 0 and no longer needs to be sent: \begin &Enc_(X_0^c) = 0 \\ &X_0^c = Dec_(0). \end


Free XOR

In this optimization, Alice generates a global random (k-1)-bit value R which is kept secret. During the garbling of the input gates w^a and w^b, she only generates the labels (X_0^a,X_0^b) and computes the other labels as X_1^a = X_0^a \oplus (R \parallel 1) and X_1^b = X_0^b \oplus (R \parallel 1). Using these values, the label of an XOR gate's output wire w^c with input wires w^a, w^b is set to X^c = X^a \oplus X^b. The proof of security in the
Random Oracle Model In cryptography, a random oracle is an oracle (a theoretical black box) that responds to every ''unique query'' with a (truly) random response chosen uniformly from its output domain. If a query is repeated, it responds the same way every tim ...
for this optimization is given in the Free-XOR paper.


Implication

Free XOR optimization implies an important point that the amount of data transfer (communication) and number of encryption and decryption (computation) of the garbled circuit protocol relies only on the number of AND gates in the
Boolean circuit In computational complexity theory and circuit complexity, a Boolean circuit is a mathematical model for combinational digital logic circuits. A formal language can be decided by a family of Boolean circuits, one circuit for each possible inpu ...
not the XOR gates. Thus, between two Boolean circuits representing the same function, the one with the smaller number of AND gates is preferred.


Fixed-key blockcipher

This method allows to efficiently garble and evaluate AND gates using fixed-key AES, instead of costly
cryptographic hash function A cryptographic hash function (CHF) is a hash algorithm (a map (mathematics), map of an arbitrary binary string to a binary string with a fixed size of n bits) that has special properties desirable for a cryptography, cryptographic application: ...
like
SHA-2 SHA-2 (Secure Hash Algorithm 2) is a set of cryptographic hash functions designed by the United States National Security Agency (NSA) and first published in 2001. They are built using the Merkle–Damgård construction, from a one-way compression ...
. In this garbling scheme which is compatible with the Free XOR and
Row Reduction In mathematics, Gaussian elimination, also known as row reduction, is an algorithm for solving systems of linear equations. It consists of a sequence of row-wise operations performed on the corresponding matrix of coefficients. This method can als ...
techniques, the output key X^c is encrypted with the input token X^a and X^b using the encryption function Enc(X^a, X^b, T, X^c) = \pi(K) \oplus K \oplus X^c, where K = 2X^a \oplus 4X^b \oplus T, \pi is a fixed-key
block cipher In cryptography, a block cipher is a deterministic algorithm that operates on fixed-length groups of bits, called ''blocks''. Block ciphers are the elementary building blocks of many cryptographic protocols. They are ubiquitous in the storage a ...
(e.g., instantiated with AES), and T is a unique-per-gate number (e.g., gate identifier) called ''tweak''.


Half And

This optimization reduce the size of garbled table for AND gates from 3 row in
Row Reduction In mathematics, Gaussian elimination, also known as row reduction, is an algorithm for solving systems of linear equations. It consists of a sequence of row-wise operations performed on the corresponding matrix of coefficients. This method can als ...
to 2 rows. It is shown that this is the theoretical minimum for the number of rows in the garbled table, for a certain class of garbling techniques.


Security

The Yao's Garbled Circuit is secure against a semi-honest adversary. This type of adversary follows the protocol and does not do any malicious behavior, but it tries to violate the privacy of the other party's input by scrutinizing the messages transmitted in the protocol. It is more challenging to make this protocol secure against a malicious adversary that deviates from the protocol. One of the first solutions to make the protocol secure against malicious adversary is to use
zero-knowledge proof In cryptography, a zero-knowledge proof (also known as a ZK proof or ZKP) is a protocol in which one party (the prover) can convince another party (the verifier) that some given statement is true, without conveying to the verifier any information ...
to prevent malicious activities during the protocol. For years, this approach was considered more as theoretical solution than a practical solution because of complexity overheads of it. But, it is shown that it is possible to use it with just a small overhead. Another approach is using several GC for a circuit and verifying the correctness of a subset of them and then using the rest for the computation with the hope that if the garbler was malicious, it would be detected during the verification phase. Another solution is to make the garbling scheme authenticated such that the evaluator can verify the garbled circuit.


See also

*
Cryptography Cryptography, or cryptology (from "hidden, secret"; and ''graphein'', "to write", or ''-logy, -logia'', "study", respectively), is the practice and study of techniques for secure communication in the presence of Adversary (cryptography), ...
* RSA *
Secure multi-party computation Secure multi-party computation (also known as secure computation, multi-party computation (MPC) or privacy-preserving computation) is a subfield of cryptography with the goal of creating methods for parties to jointly compute a function over their ...
* Yao's Millionaires' Problem


References


Further reading

*{{cite web, title=Yao's Garbled Circuit, url=https://courses.engr.illinois.edu/cs598man/fa2009/slides/ac-f09-lect16-yao.pdf, website=CS598, publisher=illinois.edu, accessdate=18 October 2016 Theory of cryptography Cryptographic protocols