Skip to main content

Full Description

Garbling. The garbling algorithm Garble(C)\mathsf{Garble}(\sC) is described as follows.

  • Let CircuitInputs(C)\mathsf{CircuitInputs}(\sC), CircuitOutputs(C)\mathsf{CircuitOutputs}(\sC) be the set of input and output wires of C\sC, respectively. Given a non-input wire ii, let (a,b)InputWires(C,i)(a,b)\leftarrow\mathsf{InputWires}(\sC,i) denote the two input wires a,ba,b of ii associated to an AND\and or XOR\xor gate. Let aInputsWires(C,i)a\leftarrow\mathsf{InputsWires}(\sC,i) denote the input wire aa of ii associated to an INV\inv gate. The garbler maintains three sets EE,DD and TT. The garbler also maintains a counter\counter initiated as 00.

  • Choose a secret global 128-bit string Δ\Delta uniformly, and set LSB(Δ)=1\lsb(\Delta) = 1. Let P=XΔP = X\oplus \Delta be the label of public bit 11, where XX is chosen uniformly at random. Note that PP will be sent to the evaluator.

  • For iCircuitInputs(C)i\in\mathsf{CircuitInputs}(\sC), do the following.

    • Choose 128128-bit Xi0X_i^0 uniformly at random, and set Xi1=Xi0ΔX_i^1 = X_i^0\oplus \Delta.
    • Let ei=Xi0e_i = X_i^0 and insert it to EE.
  • For any non-input wire ii, do the following.

    • If the gate associated to ii is a XOR\xor gate.
      • Let (a,b)GateInputs(C,i)(a,b)\leftarrow\mathsf{GateInputs}(\sC,i).
      • Compute Xi0=Xa0Xb0X_i^0 = X_a^0\oplus X_b^0 and Xi1=Xi0ΔX_i^1 = X_i^0\oplus \Delta.
    • If the gate associated to ii is an INV\inv gate.
      • Let aGateInputs(C,i)a\leftarrow\mathsf{GateInputs}(\sC,i),
      • Compute Xi0=Xa0PX_i^0 = X_a^0\oplus P and Xi1=Xi0ΔX_i^1 = X_i^0\oplus \Delta.
    • If the gate associated to ii is an AND\and gate.
      • let (a,b)GateInputs(C,i)(a,b)\leftarrow\mathsf{GateInputs}(\sC,i),
      • Let pa=LSB(Xa0)p_a = \lsb(X_a^0), pb=LSB(Xb0)p_b = \lsb(X_b^0).
      • Compute the first half gate:
      • Let TG=H(counter,Xa0)H(counter,Xa1)(pbΔ)T_G = \sH(\counter,X_a^0)\oplus \sH(\counter,X_a^1)\oplus (p_b\cdot \Delta).
      • Let XG0=H(counter,Xa0)(paTG)X_G^0 = \sH(\counter,X_a^0)\oplus (p_a\cdot T_G).
      • counter=counter+1\counter = \counter + 1.
      • Compute the second half gate:
      • Let TE=H(counter,Xb0)H(counter,Xb1)Xa0T_E = \sH(\counter,X_b^0)\oplus\sH(\counter,X_b^1)\oplus X_a^0.
      • Let XE0=H(counter,Xb0)pb(TEXa0)X_E^0 = \sH(\counter,X_b^0)\oplus p_b\cdot (T_E\oplus X_a^0)
      • Let Xi0=XG0XE0X_i^0 = X_G^0\oplus X_E^0, Xi1=Xi0ΔX_i^1 = X_i^0\oplus\Delta and insert the garbled gate (TG,TE)(T_G,T_E) to TT.
      • counter=counter+1\counter = \counter + 1.
  • For iCircuitOutputs(C)i\in\mathsf{CircuitOutputs}(\sC), do the following.

    • Compute di=LSB(Xi0)d_i = \lsb(X_i^0).
    • Insert did_i into DD.
  • The garbler outputs (G,E,D)(G,E,D).

Input Encoding. Given E=(e1,...,e)E = (e_1,...,e_\ell), the garbler encodes the input (x1,...,x){0,1}(x_1,...,x_\ell)\in\bit^\ell as follows.

  • For all 1i1\leq i\leq \ell, compute Xi=eixiΔX_i = e_i\oplus x_i\Delta
  • Outputs X=(X1,...,X)X = (X_1,...,X_\ell).

Evaluating. The evaluating algorithm Eval(C)\mathsf{Eval}(\sC) is described as follows.

  • The evaluator takes as input the garbled circuit TT and the encoded inputs XX.

  • The evaluator obtains the input labels (X1,...,X)(X_1,...,X_\ell) from XX and initiates counter=0\counter = 0.

  • For any non-input wire ii, do the following.

    • If the gate associated to ii is a XOR\xor gate.
      • Let (a,b)GateInputs(C,i)(a,b)\leftarrow\mathsf{GateInputs}(\sC,i).
      • Compute Xi=XaXbX_i = X_a\oplus X_b.
    • If the gate associated to ii is an INV\inv gate.
      • Let aGateInputs(C,i)a\leftarrow\mathsf{GateInputs}(\sC,i),
      • Compute Xi=XaPX_i = X_a\oplus P.
    • If the gate associated to ii is an AND\and gate.
      • Let (a,b)GateInputs(C,i)(a,b)\leftarrow\mathsf{GateInputs}(\sC,i),
      • Let sa=LSB(Xa)s_a = \lsb(X_a), sb=LSB(Xb)s_b = \lsb(X_b).
      • Parse TiT_i as (TG,TE)(T_G,T_E).
      • Compute XG=H(counter,Xa)saTGX_G = \sH(\counter,X_a)\oplus s_a\cdot T_G.
      • counter=counter+1\counter = \counter + 1.
      • Compute XE=H(counter,Xb)sb(TEXa)X_E = \sH(\counter, X_b)\oplus s_b(T_E\oplus X_a).
      • Let Xi=XGXEX_i = X_G\oplus X_E.
  • For iCircuitOutputs(C)i\in\mathsf{CircuitOutputs}(\sC), do the following.

    • Let Yi=XiY_i = X_i.
    • Outputs YY, the set of YiY_i.

Output Decoding. Given YY and DD, the evaluator decodes the labels into outputs as follows.

  • For any ii, compute yi=diLSB(Yi)y_i = d_i\oplus\lsb(Y_i).
  • Outputs all yiy_i.