Secure Multi-Party Computation

Suppose we have a function ff with nn inputs and mm outputs. The goal of MPC is to develop a protocol for NN parties where every input is submitted by one party and every output is obtained by some parties. There are some informal descriptions of the security:

  • privacy: no party learns anything about any other party's inputs (except for information that is inherently revealed by the outputs);
  • soundness: honest parties compute correct outputs (if they compute any output at all);
  • input independence: all parties must choose their inputs independently of the other parties' inputs.

And there are assumptions

  • cryptographic assumptions
  • number of corrupt parties
  • communication: synchronous or asynchronous
  • type of corruption: malicious or honest-but-curious (of the things to do), static or adapted (of which party to corrupt)

Intro: Beaver’s protocol

The beaver’s protocol securely computes the output of the arithmetic circuits over Fq\mathbb{F}_q among 22 parties.

Basic Idea

To achieve privacy, it is an intuition to split the key value into several parts, and distribute them to different parties. We use [x][x] to denote a share of value xx , meaning [x]=(x1,x2)[x]=(x_1,x_2) where x=x1+x2x=x_1+x_2 . And define

  • [x]+[y]=(x1+y1,x2+y2)[x]+[y]=(x_1+y_1,x_2+y_2)
  • c[x]=(cx1,cx2)c[x]=(cx_1,cx_2)
  • [x]+c=(x1+c,x2)[x]+c=(x_1+c,x_2) (I am curious whether it is more secure to split the constant randomly, not just always add it on one side.)

The add gate, scalar multiplication gate and constant add gate is linear; the tow parties can compute independently. The multiplication gate needs the dealer to generate a random Beaver triple sharing : ([a],[b],[c])([a],[b],[c]) where c=abc=ab .

Suppose the two parties are computing the multiplication of [x][x] and [y][y] . The dealer sends ai,bia_i,b_i to PiP_i each, and the two parties compute [u]=[x][a][u]=[x]-[a] and [v]=[y][b][v]=[y]-[b] . Then the two parties open the shares [u],[v][u],[v] to each other so that they both know u=xa,v=ybu=x-a,v=y-b , and uses their own share to compute

[z]=uv+u[b]+v[a]+[c].[z]=uv+u[b]+v[a]+[c].

For example, the party ii computes zi=uv×1i=1+ubi+vai+ciz_i=uv\times\mathbf{1}_{i=1}+ub_i+va_i+c_i and we can verify that z1+z2=uv+ub+ua+ab=xyz_1+z_2=uv+ub+ua+ab=xy .

And the dealer would split the input x=x1+x2x=x_1+x_2 and distributes them to PiP_i ’s.

Maliciously secure Beaver’s protocol

A malicious participant would send a wrong number when opening their shares. We introduce authenticated sharing x:=([x],[x(1)],[x(2)])\llbracket x \rrbracket:=([x],[x^{(1)}],[x^{(2)}]) where PiP_i has (xi,xi(1),xi(2))(x_i,x^{(1)}_i,x^{(2)}_i) and summing over ii reveals the original content (x,x(1),x(2))(x,x^{(1)},x^{(2)}) . Also there is [K(1)],[K(2)][K^{(1)}],[K^{(2)}] that the dealer randomly generalize and distribute to the parties during the setup. The authenticated sharing is valid iff x(1)=K(1)xx^{(1)}=K^{(1)}x , x(2)=K(2)xx^{(2)}=K^{(2)}x .

The intuition is, if any one of the two parties are corrupt, they will never know the other’s secret KK , thus cannot make up a fake authenticated sharing. The KK here serves as a MAC with homomorphic properties, and is initialized during setup phase, where the dealer sends the sharing to each party using K(i)K^{(i)} .

Thus, simply replace [x][x] by x\llbracket x \rrbracket we shift our protocol to a secure version w.r.t. corrupt parties.

Keeping the dealer honest

However, the dealer can be malicious. Although it cannot know the data computed, it can:

  • offer an invalid sharing or wrong keys such that x(i)K(i)xx^{(i)}\not=K^{(i)}x
  • inappropriately split the input xx1+x2x\not=x_1+x_2
  • provide incorrect Beaver’s triple ([a],[b],[c])([a],[b],[c])

The first one is easily defenced through checking, and I suppose that the second one is not a problem, because the protocol is in fact computing with a replaced input. We consider the third problem and suppose the dealer sends aij,bij,cija_{ij},b_{ij},c_{ij} where i=1,2i=1,2 and j=1,2,,mj=1,2,\dots,m .

The dealer will do additional computations to prove that for every jj , (a1j+a2j)(b1j+b2j)=c1j+c2j(a_{1j}+a_{2j})(b_{1j}+b_{2j})=c_{1j}+c_{2j} using interpolation. The dealer randomly picks aj0,bj0,cj0,j=1,2a_{j0},b_{j0},c_{j0},j=1,2 such that (a10+a20)(b10+b20)=c10+c20(a_{10}+a_{20})(b_{10}+b_{20})=c_{10}+c_{20} and interpolates a degree- mm polynomial A1(X),A2(X)A_1(X),A_2(X) such that Ai(j)=aij,i=1,2,j=0,,mA_i(j)=a_{ij},i=1,2,j=0,\dots,m . Similar for BB , and C(X)=(A1(X)+A2(X))(B1(X)+B2(X))C(X)=(A_1(X)+A_2(X))(B_1(X)+B_2(X)) . Then for k=m+1,,2mk=m+1,\dots,2m , randomize c1k+c2k=C(k)c_{1k}+c_{2k}=C(k) .

Each of the participant PiP_i receives aik,bik,k=0,,ma_{ik},b_{ik},k=0,\dots,m and cik,k=0,,2mc_{ik},k=0,\dots,2m , and interpolates the polynomials Ai,Bi,CiA_i,B_i,C_i . The next step, the participants run an argument of proving the polynomial equals 00 , all done by sending a random number and reveal the evaluations to each other. To be precise,

  • Party P1P_1 randomly chooses rZq{0,,m}r \in \mathbb{Z}_q \setminus \{0, \ldots, m\} and sends it to P2P_2 .
  • Party P2P_2 verifies that rZq{0,,m}r \in \mathbb{Z}_q \setminus \{0, \ldots, m\} ; if not, P2P_2 aborts the protocol.
  • Each party $P_i$ (for $i = 1, 2$) sends to the other party
    αiAi(r),βiBi(r),γiCi(r).\alpha_i \leftarrow A_i(r), \quad \beta_i \leftarrow B_i(r), \quad \gamma_i \leftarrow C_i(r).
  • Each party locally checks whether
    (α1+α2)(β1+β2)=(γ1+γ2)(\alpha_1 + \alpha_2)(\beta_1 + \beta_2) = (\gamma_1 + \gamma_2)

    holds. If not, the party aborts the protocol.

So the soundness probability of the dealer to be corrupt is about 2mq\frac{2m}{q} .

Further, we should use simulator as in ZKP to prove that with a corrupted PiP_i , the PiP_i cannot learn anything from P3iP_{3-i} .

Garbled Circuits

A garbling scheme consists of four algorithms; the first is non-deterministic while others are deterministic:

  • Garble\mathsf{Garble} : (F,e,d)Garble(f)(\mathcal{F}, e, d) \leftarrow \mathsf{Garble}(f)
  • Encode\mathsf{Encode} : XEncode(e,x)\mathcal{X} \leftarrow \mathsf{Encode}(e, {x})
  • Eval\mathsf{Eval} : YEval(F,X)\mathcal{Y} \leftarrow \mathsf{Eval}(\mathcal{F}, \mathcal{X})
  • Decode\mathsf{Decode} : {y,}Decode(d,Y)\{{y},\bot\} \leftarrow \mathsf{Decode}(d, \mathcal{Y})

Correctness: For all f,(F,e,d)Garble(f),xf, (\mathcal{F}, e, d) \leftarrow \mathsf{Garble}(f), {x} ,

Decode(d,Eval(F,Encode(e,x)))=f(x)\mathsf{Decode}(d, \mathsf{Eval}(\mathcal{F}, \mathsf{Encode}(e, {x}))) = f({x})

Intuitive security goals:

  • Obliviousness : F,X\mathcal{F}, \mathcal{X} reveals nothing about xx . This is about preventing the evaluator from gaining the input.
  • Authenticity : Given F,X\mathcal{F}, \mathcal{X} it is of negligible probability for all PPT adversaries to find YEval(F,X)\mathcal{Y}'\not=\mathsf{Eval}(\mathcal{F},\mathcal{X}) that decodes to a value (not a \bot ). This is about preventing the evaluator from forging the result.
  • Output simulatability : Y\mathcal{Y} can be efficiently computed by f(x)f(x) and dd .

Here is a scheme of outsourcing computation: suppose Alice uses Bob’s computation resources to compute f(x)f(x) . First Alice generates (F,e,d)Garble(f)(\mathcal{F}, e, d) \leftarrow \mathsf{Garble}(f) ; then sends F\mathcal{F} to Bob, and keeps e,de,d herself. When she wants to compute, she has XEncode(e,x)\mathcal{X} \leftarrow \mathsf{Encode}(e, {x}) and sends X\mathcal{X} to Bob, where Bob computes YEval(F,X)\mathcal{Y} \leftarrow \mathsf{Eval}(\mathcal{F}, \mathcal{X}) and returns to Alice. Then Alice can decode.

Note that Alice should generate a garbled circuit on different inputs and the same boolean circuit. If we use the same GC for different computation tasks, then a honest-but-curious party would know some relations of the two inputs through comparing the encoded X\mathcal{X} ; or some information about ee . We should always keep in mind that the encoding algorithm is deterministic.

Formal definition of the security goals

Obliviousness. For b=0,1b = 0, 1 , we have experiment Expb\mathsf{Exp}_b :

  • Adversary submits (f,x(0),x(1))(f, \mathbf{x}^{(0)}, \mathbf{x}^{(1)})
  • Challenger computes:
    (F,e,d)Garble(f),XEncode(e,x(b))(\mathcal{F}, e, d) \leftarrow \mathsf{Garble}(f), \quad \mathcal{X} \leftarrow \mathsf{Encode}(e, \mathbf{x}^{(b)})

    and sends (F,X)(\mathcal{F}, \mathcal{X}) to adversary.

  • Adversary outputs b^{0,1}\hat{b} \in \{0,1\} , let WbW_b be the event that the adversary outputs 11 .

A garbling scheme is oblivious iff for every PPT adversary, the game has a negligible advantage defined by Pr[W0]Pr[W1]|\Pr[W_0] - \Pr[W_1]| .

Output Simulatability. A garbling scheme is output simulatable if there exists an efficient deterministic algorithm Reverse\mathsf{Reverse} such that for every ff , every (F,e,d)Garble(f)(\mathcal{F}, e, d) \leftarrow \mathsf{Garble}(f) , and every x{x} :

Eval(F,Encode(e,x))=Reverse(d,f(x)).\mathsf{Eval}(\mathcal{F}, \mathsf{Encode}(e, \mathbf{x})) = \mathsf{Reverse}(d, f(\mathbf{x})).

Garble0\texttt{Garble0} : an implementation of garbling scheme

Suppose the boolean circuit has nn variables and mm outputs.

e=((X10,X11),,(Xn0,Xn1))X=(X1x1,,Xnxn)d=((Y10,Y11),,(Ym0,Ym1))Y=(Y1,,Ym)\begin{align*} e&=((X_1^0,X_1^1),\dots,(X_n^0,X_n^1))\\ \mathcal{X}&=(X_1^{x_1},\dots,X_n^{x_n})\\ d&=((Y_1^0,Y_1^1),\dots,(Y_m^0,Y_m^1))\\ \mathcal{Y}&=(Y_1,\dots,Y_m) \end{align*}

where xx is the input and Y\mathcal{Y} is the garbled output. The decoding algorithm is to compare each YjY_j to the pair (Yj0,Yj1)(Y_j^0,Y_j^1) .

Our goal is to establish the algorithm Eval\mathsf{Eval} that with input F\mathcal{F} and X\mathcal{X} carries out the garbled output.

The garbled circuit F\mathcal{F} consists of a function for each gate gg , which we will denote by GateEvalg\mathsf{GateEval}_g satisfying

GateEval(G,I1u,I2v)=Og(u,v)\mathsf{GateEval}(\mathcal{G},I_1^u,I_2^v)=O^{g(u,v)}

where IixI_i^x ‘s are the garbled values of input wires and OyO^y are that of the output wire. For example an AND gate, we have GateEval(I1u,I2v)=O1[u=1v=1]\mathsf{GateEval}(I_1^u,I_2^v)=O^{\mathbf{1}[u=1\land v=1]} . The encoding G\mathcal{G} for this gate is called a garbled encoding, which should be used together with a garbled evaluation algorithm GateEval\mathsf{GateEval} .

Implementation of garbled encoding

This implementation entails a public key encryption scheme. We index each wire by II and each wire ii corresponds to two public keys (ki0,ki1)(k_i^0,k_i^1) as the private encoding. Then consider one gate with inputs wires i,ji,j and output wire tt .

E(a,b)=Enckia(Enckjb(ktg(a,b)00000))E^{(a,b)}=\mathsf{Enc}_{k_i^a}(\mathsf{Enc}_{k_j^b}(k_t^{g(a,b)}\|000\dots00))

where the length of the trailing zeros is the security parameter λ\lambda . And the garbled circuit is the tuple

G=(i,j,t,E(0,0),E(0,1),E(1,0),E(1,1))\mathcal{G}=(i,j,t,E^{(0,0)},E^{(0,1)},E^{(1,0)},E^{(1,1)})

with the evaluation algorithm

GateEval(G,X,Y)=  for  a{0,1},b{0,1}:if  DeckjY(DeckiX(E(a,b))) end with λ  0’sreturn  DeckjY(DeckiX(E(a,b)))\begin{align*} \mathsf{GateEval}(\mathcal{G},X,Y)= &\;\mathbf{for}\;a\in\{0,1\},b\in\{0,1\}:\\ &\quad\mathbf{if}\;\mathsf{Dec}_{k_j^Y}(\mathsf{Dec}_{k_i^X}(E^{(a,b)}))\text{ end with }\lambda\; 0\text{'s}\\ &\quad\quad\mathbf{return}\;\mathsf{Dec}_{k_j^Y}(\mathsf{Dec}_{k_i^X}(E^{(a,b)})) \end{align*}

This algorithm is obviously correct, but requires computations for all 44 possibilities. Below we propose the point-and-permute method to make it more efficient.

(In fact this method has a constant complexity for all gates; if we construct a big look-up table for the whole circuit, the total time will be exponential!)

More efficient

We have T={0,1}T=\{0,1\}^\ell be our set of tokens and II is the finite set of identifiers that each gate has a unique identifier iIi\in I . And H:T×T×ITH:T\times T\times I\mapsto T a hash function. For each wire, the garbling process generates (A0,A1,r)(A^0,A^1,r) as the private encoding such that AiA^i begins with ii . Then consider the gate ii with its input private encodings (A0,A1,r),(B0,B1,s)(A^0,A^1,r),(B^0,B^1,s) and the output private encodings (C0,C1,t)(C^0,C^1,t) . We set for a,b{0,1}a,b\in\{0,1\} ,

E(a,b)=H(Aa,Bb,i)Cg(ar,bs)t.E^{(a,b)}=H(A^{a},B^b,i)\oplus C^{g(a\oplus r,b\oplus s)\oplus t}.

Note that And we define the garbled encoding

G=(i,E(0,0),E(0,1),E(1,0),E(1,1))\mathcal{G}=(i,E^{(0,0)},E^{(0,1)},E^{(1,0)},E^{(1,1)})

with the garbled evaluation algorithm

GateEval(G,X,Y)=H(X,Y,i)E(a,b)\mathsf{GateEval}(\mathcal{G},X,Y)=H(X,Y,i)\oplus E^{(a,b)}

where aa is the first bit of XX and bb is the first bit of YY .

The correctness of the algorithm is one line of formula. When computing, if the first input wire has value uu , then the corresponding encoding is Xu:=AurX^u:=A^{u\oplus r} , and the same for the second input and the output, say, Yv:=BvsY^v:=B^{v\oplus s} and Zw:=CwtZ^w:=C^{w\oplus t} . Then we have

GateEval(G,Xu,Yv)=H(Aur,Bvs,i)E(ur,vs)=Cg(u,v)t=Zg(u,v).\mathsf{GateEval}(\mathcal{G},X^u,Y^v)=H(A^{u\oplus r},B^{v\oplus s},i)\oplus E^{(u\oplus r,v\oplus s)}=C^{g(u,v)\oplus t}=Z^{g(u,v)}.

The random bit here is used to mask the true value. Imagine you send Au,BvA^u,B^v directly, the evaluator immediately knows the hidden value because AuA^u has the first bit uu , and the same as BvB^v .

The full protocol

Garbler,(xi(0))i=0k1Evaluator,(xi(1))i=kn1F={Gi}i=0t1,e=((X10,X11),,(Xn0,Xn1)),d=((Y10,Y11),,(Ym0,Ym1))F,  (Xixi(0))i=0k1e1-out-of-2 OT(Xixi(1))i=kn1y=Decode(d,Y)YY=Eval(F,(Xixi)i=0n1), runs GateEval on each gate\begin{align*}&\text{Garbler},\left(x^{(0)}_i\right)_{i=0}^{k-1}&&&\text{Evaluator},\left(x^{(1)}_i\right)_{i=k}^{n-1}\\&\mathcal{F}=\{\mathcal{G}_i\}_{i=0}^{t-1}, \quad e=((X_1^0,X_1^1),\ldots,(X_n^0,X_n^1)), \quad d=((Y_1^0,Y_1^1),\ldots,(Y_m^0,Y_m^1))&\xrightarrow{\mathcal{F},\;\left(X_i^{x^{(0)}_i}\right)_{i=0}^{k-1}}&&\\&e&\xleftrightarrow{\text{1-out-of-2 }\mathbf{OT}}&&\left(X_i^{x^{(1)}_i}\right)_{i=k}^{n-1}\\&y=\mathsf{Decode}\left(d,\mathcal{Y}\right)&\xleftarrow{\mathcal{Y}}&&\mathcal{Y}=\mathsf{Eval}\left(\mathcal{F},\left(X_i^{x_i}\right)_{i=0}^{n-1}\right)\text{, runs }\mathsf{GateEval}\text{ on each gate}\\\end{align*}