Garbled circuit explained

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.

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[1] in FOCS'86. This was documented by Oded Goldreich in 2003.[2] The first written document about this technique was by Goldreich, Micali, andWigderson in STOC'87.[3] The term "garbled circuit" was first used by Beaver, Micali, and Rogaway in STOC'90.[4] 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\in\{0,1\}

and the sender sends

Sb

with the oblivious transfer protocol such that
  1. the receiver doesn't gain any information about the unsent string

S(1-b)

,
  1. 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

\parallel

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:

  1. 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.
  2. Alice garbles (encrypts) the circuit. We call Alice the garbler.
  3. Alice sends the garbled circuit to Bob along with her encrypted input.
  4. 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.
  5. Bob evaluates (decrypts) the circuit and obtains the encrypted outputs. We call Bob the evaluator.
  6. 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.[5] 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

:
a b c
0 0 0
0 1 0
1 0 0
1 1 1

Alice replaced 0 and 1 with the corresponding labels:

a b c
a
X
0
b
X
0
c
X
0
a
X
0
b
X
1
c
X
0
a
X
1
b
X
0
c
X
0
a
X
1
b
X
1
c
X
1
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,

Enck(X)

is a double-key symmetric encryption in which k is the secret key and X is the value to be encrypted (see Fixed-Key Blockcipher).
Garbled Table
Enc
a,
X
b
X
0
0
c)
(X
0
Enc
a,
X
b
X
1
0
c)
(X
0
Enc
a,
X
b
X
0
1
c)
(X
0
Enc
a,
X
b
X
1
1
c)
(X
1
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

a=a4a3a2a1a0=01101

, then she sends
a4
X
0
,
a3
X
1
,
a2
X
1
,
a1
X
0
, and
a0
X
1
to Bob. Bob will not learn anything about Alice's input,

a

, 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

b=b4b3b2b1b0=10100

, Bob first asks for

b0=0

between Alice's labels
b0
X
0
and
b0
X
1
. Through a 1-out-of-2 oblivious transfer, he receives
b0
X
0
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=

Dec
Xa,Xb

(garbled\table[i])

, where

0\lei\le3

. 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:
c
X
0
and
c
X
1
. 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,
a
X
0
to

s

and the first bit of label 1,
a
X
1
, to

\bar{s}

(NOT of

s

). She does the same for wire

wb

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

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:[7]

\begin{align} &Enc
a,
X
b
X
0
0
c)
(X
0

=0

c
\\ &X
0

=

Dec
a,
X
b
X
0
0

(0). \end{align}

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

wa

and

wb

, she only generates the labels
b)
(X
0
and computes the other labels as
a
X
1

=

a
X
0

(R\parallel1)

and
b
X
1

=

b
X
0

(R\parallel1)

. Using these values, the label of an XOR gate's output wire

wc

with input wires

wa

,

wb

is set to

Xc=XaXb

. The proof of security in the Random Oracle Model for this optimization is given in the Free-XOR paper.[8]

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 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 like SHA-2. In this garbling scheme which is compatible with the Free XOR and Row Reduction techniques, the output key

Xc

is encrypted with the input token

Xa

and

Xb

using the encryption function

Enc(Xa,Xb,T,Xc)=\pi(K)KXc

, where

K=2Xa4XbT

,

\pi

is a fixed-key block cipher (e.g., instantiated with AES), and

T

is a unique-per-gate number (e.g., gate identifier) called tweak.[9]

Half And

This optimization reduce the size of garbled table for AND gates from 3 row in Row Reduction 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.[10]

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 to prevent malicious activities during the protocol.[11] 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.[12] 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.[13] Another solution is to make the garbling scheme authenticated such that the evaluator can verify the garbled circuit.[14] [15]

See also

Further reading

Notes and References

  1. Book: Yao , Andrew Chi-Chih . 27th Annual Symposium on Foundations of Computer Science (SFCS 1986). 1986. How to generate and exchange secrets. 162–167. 10.1109/SFCS.1986.25. 978-0-8186-0740-0.
  2. Goldreich. Oded. 2003. Cryptography and Cryptographic Protocols. Distributed Computing - Papers in Celebration of the 20th Anniversary of PODC. 16. 2–3. 177–199 . 10.1007/s00446-002-0077-1. 10.1.1.117.3618. 9966766.
  3. Book: Goldreich. Oded. Micali. Silvio. Wigderson. Avi. Proceedings of the nineteenth annual ACM conference on Theory of computing - STOC '87. How to play ANY mental game. 1987. 218–229 . 10.1145/28395.28420. 978-0897912211. 6669082.
  4. Book: Beaver. Donald. Micali. Silvio. Rogaway. Phillip. Proceedings of the twenty-second annual ACM symposium on Theory of computing - STOC '90. The round complexity of secure protocols. 1990. 503–513 . 10.1145/100216.100287. 978-0897913614. 10.1.1.697.1624. 1578121.
  5. Book: Songhori. Ebrahim M. Hussain. Siam U. Sadeghi. Ahmad-Reza. Schneider. Thomas. Koushanfar. Farinaz. TinyGarble: Highly Compressed and Scalable Sequential Garbled Circuits. 2015 IEEE Symposium on Security and Privacy. Farinaz Koushanfar. 2015. 411–428. 10.1109/SP.2015.32. 978-1-4673-6949-7. 5346323.
  6. Book: Beaver. Donald. Micali. Silvio. Rogaway. Phillip. Proceedings of the twenty-second annual ACM symposium on Theory of computing - STOC '90. The round complexity of secure protocols. 1990. 503–513. 10.1145/100216.100287. 978-0897913614. 10.1.1.697.1624. 1578121.
  7. Book: Naor. Moni. Pinkas. Benny. Sumner. Reuban. Proceedings of the 1st ACM conference on Electronic commerce. Privacy preserving auctions and mechanism design. 1999. 129–139. 10.1145/336992.337028. 978-1581131765. 10.1.1.17.7459. 207593367.
  8. Book: Kolesnikov. Vladimir. Schneider. Thomas. Automata, Languages and Programming. Improved Garbled Circuit: Free XOR Gates and Applications. 2008. 5126. 486–498. 10.1007/978-3-540-70583-3_40. Lecture Notes in Computer Science. 978-3-540-70582-6. 10.1.1.160.5268.
  9. Book: Bellare. Mihir. Hoang. Viet Tung. Keelveedhi. Sriram. Rogaway. Phillip. 2013 IEEE Symposium on Security and Privacy. Efficient Garbling from a Fixed-Key Blockcipher. 2013. 478–492. 10.1109/SP.2013.39. 978-0-7695-4977-4. 10.1.1.299.2755. 1351222.
  10. Book: Zahur. Samee. Rosulek. Mike. Evans. David. 2015. Two halves make a whole.
  11. Book: Goldwasser. S. Micali. S. Rackoff. C. Proceedings of the seventeenth annual ACM symposium on Theory of computing - STOC '85. The knowledge complexity of interactive proof-systems. 1985-12-01. https://doi.org/10.1145/22145.22178. Providence, Rhode Island, US. Association for Computing Machinery. 291–304. 10.1145/22145.22178. 978-0-89791-151-1. 8689051.
  12. Book: Abascal. Jackson. Faghihi Sereshgi. Mohammad Hossein. Hazay. Carmit. Ishai. Yuval. Venkitasubramaniam. Muthuramakrishnan. Proceedings of the 2020 ACM SIGSAC Conference on Computer and Communications Security . Is the Classical GMW Paradigm Practical? The Case of Non-Interactive Actively Secure 2PC . 2020-10-30. https://doi.org/10.1145/3372297.3423366. CCS '20. Virtual Event, US. Association for Computing Machinery. 1591–1605. 10.1145/3372297.3423366. 978-1-4503-7089-9. 226228208.
  13. Book: Lindell. Yehuda. Pinkas. Benny. Advances in Cryptology - EUROCRYPT 2007 . An Efficient Protocol for Secure Two-Party Computation in the Presence of Malicious Adversaries . 2007. Naor. Moni. Lecture Notes in Computer Science. 4515. en. Berlin, Heidelberg. Springer. 52–78. 10.1007/978-3-540-72540-4_4. 2007LNCS.4515...52L. 978-3-540-72540-4. free.
  14. Book: Ishai. Yuval. Kushilevitz. Eyal. Ostrovsky. Rafail. Prabhakaran. Manoj. Sahai. Amit. Advances in Cryptology – EUROCRYPT 2011 . Efficient Non-interactive Secure Computation . 2011. Paterson. Kenneth G.. Lecture Notes in Computer Science. 6632. en. Berlin, Heidelberg. Springer. 406–425. 10.1007/978-3-642-20465-4_23. 978-3-642-20465-4. free.
  15. Book: Hazay. Carmit. Ishai. Yuval. Venkitasubramaniam. Muthuramakrishnan. Theory of Cryptography . Actively Secure Garbled Circuits with Constant Communication Overhead in the Plain Model . 2017. Kalai. Yael. Reyzin. Leonid. https://link.springer.com/chapter/10.1007%2F978-3-319-70503-3_1. Lecture Notes in Computer Science. 10678. en. Cham. Springer International Publishing. 3–39. 10.1007/978-3-319-70503-3_1. 978-3-319-70503-3.