Suppose we have a function f with n inputs and m outputs. The goal of MPC is to develop a protocol for N 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)
Garbled Circuit: Quick Catch-up
这里我们用统一的语言描述 GC 的各种构造和优化。设要跑的门是 g, 对应 0,1 的 label 为 a0,a1,b0,b1 for input wires, c0,c1 for output wires. Garbling table 用 map 表示,也可以看作一个函数. 导线上的值用 v 表示,随机 bit 用 r 表示。
The beaver’s protocol securely computes the output of the arithmetic circuits over Fq among 2 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] to denote a share of value x , meaning [x]=(x1,x2) where x=x1+x2 . And define
[x]+[y]=(x1+y1,x2+y2)
c[x]=(cx1,cx2)
[x]+c=(x1+c,x2) (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]) where c=ab .
Suppose the two parties are computing the multiplication of [x] and [y] . The dealer sends ai,bi to Pi each, and the two parties compute [u]=[x]−[a] and [v]=[y]−[b] . Then the two parties open the shares [u],[v] to each other so that they both know u=x−a,v=y−b , and uses their own share to compute
[z]=uv+u[b]+v[a]+[c].
For example, the party i computes zi=uv×1i=1+ubi+vai+ci and we can verify that z1+z2=uv+ub+ua+ab=xy .
And the dealer would split the input x=x1+x2 and distributes them to Pi ’s.
A malicious participant would send a wrong number when opening their shares. We introduce authenticated sharing[[x]]:=([x],[x(1)],[x(2)]) where Pi has (xi,xi(1),xi(2)) and summing over i reveals the original content (x,x(1),x(2)) . Also there is [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)x , x(2)=K(2)x .
The intuition is, if any one of the two parties are corrupt, they will never know the other’s secret K , thus cannot make up a fake authenticated sharing. The K 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) .
First, the dealer sends the authenticated sharing to the two parties. The two parties P1,P2 go through an interaction where [a],[a(i)],[K(i)] is opened to Pi . Use the opened sharing, each of them checks whether a(i)=K(i)a . This process is called the reliable key opening protocol, which runs as an sub-protocol in the maliciously secure 2.5-party protocol. After the protocol, Pi knows only the value of K(i) and a portion of the other key K(3−i) .
Thus, simply replace [x] by [[x]] we shift our protocol to a secure version w.r.t. corrupt parties. We have
Adding a constant: [[x]]+c=([x]+c,[x(1)]+c[K(1)],[x(2)]+c[K(2)]) . This is possible since P1 has the first share of K(2) .
This method let Pi prove to P3−i that it will not tamper the opening results.
Moreover, the protocol will abort if any one of the parties has maliciously computed an incorrect output of any gate. This is equivalent to opening with a incorrect share of some value. If the result of P1 is modified by δ , and outputs (x1+δ,x1(1)+K(1)δ,x1(2)+δ(2)) , the accepting probability of P2 is the probability that K(2)δ=δ(2) .
Or you may wonder if P1 computes x+2y instead of x+y of its share. The result is (x1+2y1,x1(1)+2y1(1),x1(2)+2y1(2)) . Then P2 checks if K(2)y1=y1(2) . Also a low probability to accept.
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)x
inappropriately split the input x=x1+x2
provide incorrect Beaver’s triple ([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 another problem with a replaced input. We consider the third problem and suppose the dealer sends aij,bij,cij where i=1,2 and j=1,2,…,m .
The dealer will do additional computations to prove that for every j , (a1j+a2j)(b1j+b2j)=c1j+c2j using interpolation. The dealer randomly picks aj0,bj0,cj0,j=1,2 such that (a10+a20)(b10+b20)=c10+c20 and interpolates a degree- m polynomial A1(X),A2(X) such that Ai(j)=aij,i=1,2,j=0,…,m . Similar for B , and C(X)=(A1(X)+A2(X))(B1(X)+B2(X)) . Then for k=m+1,…,2m , randomize c1k+c2k=C(k) .
Each of the participant Pi receives aik,bik,k=0,…,m and cik,k=0,…,2m , and interpolates the polynomials Ai,Bi,Ci . The next step, the participants run an argument of proving the polynomial equals 0 , all done by sending a random number and reveal the evaluations to each other. To be precise,
Party P1 randomly chooses r∈Zq∖{0,…,m} and sends it to P2 .
Party P2 verifies that r∈Zq∖{0,…,m} ; if not, P2 aborts the protocol.
Each party Pi (for i=1,2 ) sends to the other party
αi←Ai(r),βi←Bi(r),γi←Ci(r).
Each party locally checks whether
(α1+α2)(β1+β2)=(γ1+γ2)
holds. If not, the party aborts the protocol.
So the soundness probability of the dealer to be corrupt is about q2m .
Further, we should use simulator as in ZKP to prove that with a corrupted Pi , the Pi cannot learn anything from P3−i .
This protocol is placed after the reliable key opening protocol, before the main process.
Beaver protocol for n parties
The protocol can extend to n parties easily, for the sharing can be [x]=(x(1),…,x(n)) . The protocol requires 2 broadcasts through public (maybe not safe) channels.
Garbled Circuits
A garbling scheme consists of four algorithms; the first is non-deterministic while others are deterministic:
Garble : (F,e,d)←Garble(f)
Encode : X←Encode(e,x)
Eval : Y←Eval(F,X)
Decode : {y,⊥}←Decode(d,Y)
Correctness: For all f,(F,e,d)←Garble(f),x ,
Decode(d,Eval(F,Encode(e,x)))=f(x)
Intuitive security goals:
Obliviousness : F,X reveals nothing about x . This is about preventing the evaluator from gaining the input.
Authenticity : Given F,X it is of negligible probability for all PPT adversaries to find Y′=Eval(F,X) that decodes to a value (not a ⊥ ). This is about preventing the evaluator from forging the result.
Output simulatability : Y can be efficiently computed by f(x) and d .
Here is a scheme of outsourcing computation: suppose Alice uses Bob’s computation resources to compute f(x) . First Alice generates (F,e,d)←Garble(f) ; then sends F to Bob, and keeps e,d herself. When she wants to compute, she has X←Encode(e,x) and sends X to Bob, where Bob computes Y←Eval(F,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 ; or some information about e . We should always keep in mind that the encoding algorithm is deterministic.
Formal definition of the security goals
Obliviousness. For b=0,1 , we have experiment Expb :
Adversary submits (f,x(0),x(1))
Challenger computes:
(F,e,d)←Garble(f),X←Encode(e,x(b))
and sends (F,X) to adversary.
Adversary outputs b^∈{0,1} , let Wb be the event that the adversary outputs 1 .
A garbling scheme is oblivious iff for every PPT adversary, the game has a negligible advantage defined by ∣Pr[W0]−Pr[W1]∣ .
Output Simulatability. A garbling scheme is output simulatable if there exists an efficient deterministic algorithm Reverse such that for every f , every (F,e,d)←Garble(f) , and every x :
Eval(F,Encode(e,x))=Reverse(d,f(x)).
Garble0 : an implementation of garbling scheme
Suppose the boolean circuit has n variables and m outputs. The below e is called a projective input encoding, where the encoding process is for every bit, use one value out of two.
where x is the input and Y is the garbled output. The decoding algorithm is to compare each Yj to the pair (Yj0,Yj1) .
Our goal is to establish the algorithm Eval that with input F and X carries out the garbled output.
The garbled circuit F consists of a function for each gate g , which we will denote by GateEvalg satisfying
GateEval(G,I1u,I2v)=Og(u,v)
where Iix ‘s are the garbled values of input wires and Oy are that of the output wire. For example an AND gate, we have GateEval(I1u,I2v)=O1[u=1∧v=1] . The encoding G for this gate is called a garbled encoding, ****which should be used together with a garbled evaluation algorithmGateEval .
Implementation of garbled encoding
This implementation entails a public key encryption scheme. We index each wire by I and each wire i corresponds to two public keys (ki0,ki1) as the private encoding. Then consider one gate with inputs wires i,j and output wire t .
E(a,b)=Enckia(Enckjb(ktg(a,b)∥000…00))
where the length of the trailing zeros is the security parameter λ . And the garbled circuit is the tuple
G=(i,j,t,E(0,0),E(0,1),E(1,0),E(1,1))
with the evaluation algorithm
GateEval(G,X,Y)=fora∈{0,1},b∈{0,1}:ifDeckjY(DeckiX(E(a,b))) end with λ0’sreturnDeckjY(DeckiX(E(a,b)))
This algorithm is obviously correct, but requires computations for all 4 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}ℓ be our set of tokens and I is the finite set of identifiers that each gate has a unique identifier i∈I . And H:T×T×I↦T a hash function. For each wire, the garbling process generates (X0,X1,r) as the private encoding such that Xi begins with i . Then consider the gate i with its input private encodings (A0,A1,r),(B0,B1,s) and the output private encodings (C0,C1,t) . We set for a,b∈{0,1} ,
E(a,b)=H(Aa,Bb,i)⊕Cg(a⊕r,b⊕s)⊕t.
Note that And we define the garbled encoding
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)
where a is the first bit of X and b is the first bit of Y .
This is just like the above scheme where the double encryption is realized by the hash function and the XOR operation. So we can also introduce such a point-and-permute method into the scheme above. Suppose E(a,b)=Enckia(Enckjb(ktg(a,b))) , and the table is
E(1,0),E(1,1),E(0,0),E(0,1)
So we let the kia begin by 1−a and kjb begin by b , the evaluator would know from the keys which entry to decode. Note that this method only supports 4 out of ∣S4∣=24 permutations.
The correctness of the algorithm is one line of formula. When computing, if the first input wire has value u , then the corresponding encoding is Xu:=Au⊕r , and the same for the second input and the output, say, Yv:=Bv⊕s and Zw:=Cw⊕t . Then we have
The random bit here is used to mask the true value. Imagine you send Au,Bv directly, the evaluator immediately knows the hidden value because Au has the first bit u , and the same as Bv .
The full protocol
Garbler,(xi(0))i=0k−1F={Gi}i=0t−1,e=((X10,X11),…,(Xn0,Xn1)),d=((Y10,Y11),…,(Ym0,Ym1))ey=Decode(d,Y)F,(Xixi(0))i=0k−11-out-of-2 OTYEvaluator,(xi(1))i=kn−1(Xixi(1))i=kn−1Y=Eval(F,(Xixi)i=0n−1), runs GateEval on each gate
Why OT?
Here is a more direct version: the garbler sends the full (Xi0,Xi1) and let the evaluator choose one from the pair. Thus the garbler will not know what the evaluator chooses; so the problem is, why do we mask the other value from the evaluator in the protocol Garble0 ?
For one AND gate x1∧x2 , where x1 is from the garbler and x2 is from the evaluator. Now suppose the evaluator gets both X20 and X21 , and the evaluator would secretly compute the garbled output with the garbled circuit, using different values of x2 . If the garbled output are different, the evaluator knows that x1=1 .
FreeXOR
The garbler uses a global difference Δ and let for every wire, X0⊕Δ=X1 . For one XOR gate, let the labels of the input/output gates be A0,A1=A0⊕Δ,B0,B1=B0⊕Δ,C0=A0⊕B0,C1=C0⊕Δ . Then if the two inputs are x,y then Ax⊕By=A0⊕B0⊕xΔ⊕yΔ=C0⊕(x⊕y)Δ=Cx⊕y .
The evaluator cannot have access to Δ and the reason is the same as Why OT . Now communication is 0 per XOR and 4κ per AND; verification is 0 per XOR and κ per AND.
3-party protocol against 1 malicious adversary
We consider a 3-party setting where P1 and P2 hold private inputs (a partition of the n input bits), and an additional party P3 acts as an evaluator. The goal is to compute f(x) while tolerating 1 malicious adversary.
High-level idea: P1 and P2 jointly generate the same garbled circuit F (using shared randomness) and send it to P3 together with commitments/hashes to the wire tokens. Each of P1 and P2 then “opens” only the tokens corresponding to its own input bits, in a way that lets P3 evaluate but not learn the raw input bits.
Protocol sketch (for a fixed circuit f):
A compact “message-flow” diagram (aligned):
P1(x(1))(F,e,d)←Garble(f;G(s)),{Ci(b)}i,b(i,ai,Xi,ri)i∈I1y←Decode(d,Y)F,{Ci(b)}open own inputsYP2(x(2))(F,e,d)←Garble(f;G(s)),{Ci(b)}i,b(i,ai,Xi,ri)i∈I2y←Decode(d,Y)F,{Ci(b)}open own inputsYP3check and store F,{Ci(b)}check Ci(ai)=H1(Xi,ri)check Ci(ai)=H1(Xi,ri)Y←Eval(F,X)
Here, e=((X1(0),X1(1)),…,(Xn(0),Xn(1))) , and the tuple list {Ci(b)} is generated by randomly choosing (bi)i=1n and (ri(b))i∈[n],b∈{0,1} and computing Ci(b)=H1(Xi(b⊕bi),ri(b)) .
Then P1,P2 sends their known bits in the encoded value Xi=Xi(xi),ai=xi⊕bi,ri=ri(ai) .
Note that the output of the two garblers are expected to be the same, since they use the same PRG G and the same seed s .
Why this helps against a malicious party:
If one of P1 or P2 tries to cheat by sending inconsistent garbling information, P3 detects it because it receives two versions and checks equality.
If a party tries to cheat by sending an invalid wire token, the hash/commitment check fails.
The random “swap” bits bi hide which of the two tokens corresponds to 0/1 for each wire, so P3 can evaluate without learning the underlying input bits.
“In practice, a typical way to build a multi-party protocol is to start with a secure 3-party protocol, and to use that protocol as a service provided to a larger set of parties.”
Here we consider (for example) how to use Beaver’s 2.5-party maliciously secure protocol to obtain an N -party protocol.
I have many problems with this part, especially with some certain interactions that I do not consider necessary. So I leave it blank. Check out the textbook A Graduate Course in Applied Cryptography .
The Universal Composability framework
The UC framework allows us to formally define the security property and make combinations of different protocols.
There are many details, which includes the interactions of parties in the ideal world and real world. Refer to A Graduate Course in Applied Cryptography . The key idea is, the simulator simulates to the environment Z everything the real-world environment sees, for every adversaries proposing every possible attacks in the real world.
Intro: composability
Consider the following two protocols: the first one is a PKE-based key exchange protocol
A,B are meta-data pre-known to both parties to ensure the decryption is valid; pk ’s are public. The second one is a one-time pad encryption protocol, where Alice sends message m by masking it with the shared key: c=NB⊕m .
The composition of these protocol is not secure: here is where Carol comes in.
Alice: (A,B,pkA,skA,pkB,m)NA←R{0,1}nNB=DecskA(…)NBc=NB⊕mEncpkB(NA,A,B)EncpkA(NA,NB,A,B)EncpkB(NB)cBob: (A,B,pkB,skB,pkA)NB←R{0,1}nCarol takes control over the channel 😈Guess m′ and sends to Bob EncpkB(c⊕m′)
If Carol is lucky enough (Carol only needs to win for one time) he would guess the correct m that makes Bob accept. This attack assumes that B tends to receive different messages and try decrypting all of them. (In network practice this is common, for example, re-transmission. )
Note that we shall not consider enumerating through the message space and compare the encryption with EncpkB(NB) . This attack only works with deterministic encryption schemes, which is not IND-CPA secure.
Proof strategies
Real world: Z , C , P , A for environment, public channel, parties, and adversary. The environment tells which parties to be corrupt and the only adversary controls the corrupted parties (sends input if malicious; read-only when honest-but-curious).
Ideal world: Z , F , S for environment, ideal functionality, and simulator. The simulator only interacts with corrupted parties and simulates all the messages that the environment receives in the real world.
All the parties are modelled as interactive Turing machines. We assume they (together) runs in polynomial time of secure parameters.
We say that Πsecurely implementsFagainstA if there exists a simulator S (which may depend on A / use A as oracle) that is compatible with F , such that for every well-behaved environment Z ,
ExecΠ,A,Z≈ExecF,S,Z.
And if Π is secure against all A , we say that Π securely implements F . Note that in real world, Π represents the honest parties; in ideal world, the honest parties only forwards their inputs from the environment (so they are merely wires).
In the real world, every variable that Z sees is either from the input of the adversary (from an honest party to the trivial adversary, i.e. directly to Z ) , or from the output of the adversary (in fact sent directly by Z through trivial adversary). So a simulator should
Read the outputs of the adversary, pretending to have output them and at the same time ensure the fidelity of the data that the environment sees;
Forge the inputs of the adversary, since there are no way of simulator knowing anything of the input of the adversary.
Universal composition
Since all parties are modelled as ITM, it is natural to compose different parties into a larger ITM. Utilizing this property, we derive lemmas concerning the trivial adversary, concurrency, subprotocol composition and transitivity.
Maliciously secure 3-party OT protocol
Helper Ph , sender Ps , receiver Pr :
Setup. Helper has p0,p1←RM , r0,r1←RR ; then sends (p0,p1,r0,r1) to sender; then b←R{0,1} and sends (b,pb,rb,c1⊕b=H(p1⊕b,r1⊕b)) to the receiver.
Check. Receiver sends (b,cb=H(pb,rb),c1⊕b) to the sender, whereafter the sender checks if c0=H(p0,r0) and c1=H(p1,r1) .
Request. Receiver sends τ=b⊕σ to sender. Sender computes e0=m0⊕pτ and e1=m1⊕p1⊕τ , then sends them back to the receiver.
Compute. Sender gets eσ⊕pb .
(I mistake p for c in the above protocol. Since the receiver knows c0,c1 it can has m0,m1 by computing e1⊕σ⊕c1⊕b . But in the correct protocol, the receiver only knows pb . )