SFE.BOAL
Class Circuit

java.lang.Object
  extended by SFE.BOAL.Circuit
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
UC

public class Circuit
extends java.lang.Object
implements java.io.Serializable

This class holds the data structures and methods used for garbeled circuit preparation.

For the l'th gate, we generate garbeled output description values
U(l,0) U(l,1) C(l)
Where U(l,0) is an 79-bit random number representing the output value 0 of the l'th fate. Likewise, U(l,1) represents 1 on this wire; and C(l) is one bit representing a permutation on {0,1}.

Note: an input line is simply a gate with no input or computation.

Output description values for all lines are kept in a vector of gates implemented by the Gates class.

Let an input line l be as follows:

l gate n i1 .. in o0 o1 .. o((2^n)-1)
// outputs of inputs 00...0 , 00..01 through 11..11

Let F be a strong hash function such as SHA-1. Let || denote a concatanation operation.

We then generate a garbeled circuit for line l as follows:
l gate n i1 .. in [enumeration of (2^n-1) garbeled outputs]

In the output above, we first repeat inputs, so that the computing-side will know where to take them from

We then output garbeled output values, enumerated by the permuted input values.

That is, starting from (00..00) = (c1c2..cn), let:
vk = (C(ik) XOR ck) , k=1..n
let j be the binary index corresponding to (v1 v2.. vn)

We encode the output value oj as follows:
( U(l,oj) || ( oj xor C(l) ) ) xor F( U(i1,v1) || U(i2,v2) || ... || U(in,vn))

This continues until we enumerate all (2^n)-1 combination of (c1 c2 .. cn)

Author:
Dahlia Malkhi and Yaron Sella
See Also:
Serialized Form

Constructor Summary
Circuit()
           
 
Method Summary
 Gate addGate(int n_ins, int type, boolean out_gate)
          Add a new gate with the specified number of input wires to the gates vector.
 byte[] cextractEncPayload(int total_size)
          Extract encrypyed payload from an encrypted circuit (for the purpose of communicating it in minimal overhead).
 byte[] cextractSecPayload(int total_size)
          Extract secret payload from an encrypted circuit (for the purpose of communicating it in minimal overhead).
 void cinjectEncPayload(byte[] info)
          Inject encrypyed payload into a circuit.
 void cinjectSecPayload(byte[] info)
          Inject secret payload into a circuit.
 int cmeasureEncPayload()
          Measure size of encrypted payload in an encrypted circuit
 int cmeasureSecPayload()
          Measure size of secret payload in an encrypted circuit
 void evalCircuit()
          Evaluate a circuit
 void evalGarbledCircuit(boolean alice_interpret, boolean bob_interpret)
          Evaluate a garbled circuit
 void generateEncCircuit()
          Turn all gates in a circuit to encrypted gates
 Gate getGate(int gate_num)
          Get a gate from a circuit
 boolean isCorrect()
          Verify that an exposed garbled circuit is correct (done by Alice in order to prevent cheating by Bob).
 void printCircuit()
          For debugging purposes.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Circuit

public Circuit()
Method Detail

addGate

public Gate addGate(int n_ins,
                    int type,
                    boolean out_gate)
Add a new gate with the specified number of input wires to the gates vector.

Parameters:
n_ins - the number of input wires of the gate.
type - the type of gate (e.g., regular/input/output)
Returns:
the new gate.

getGate

public Gate getGate(int gate_num)
Get a gate from a circuit


generateEncCircuit

public void generateEncCircuit()
Turn all gates in a circuit to encrypted gates


cmeasureEncPayload

public int cmeasureEncPayload()
Measure size of encrypted payload in an encrypted circuit

Returns:
int - circuit's encrypted payload size in bytes

cextractEncPayload

public byte[] cextractEncPayload(int total_size)
Extract encrypyed payload from an encrypted circuit (for the purpose of communicating it in minimal overhead).

Parameters:
total_size - total size of the circuit's payload in bytes.
Returns:
a byte array with the relevant information.

cinjectEncPayload

public void cinjectEncPayload(byte[] info)
Inject encrypyed payload into a circuit.

Parameters:
info - byte array with data to inject

cmeasureSecPayload

public int cmeasureSecPayload()
Measure size of secret payload in an encrypted circuit

Returns:
int - circuit's secret payload size in bytes

cextractSecPayload

public byte[] cextractSecPayload(int total_size)
Extract secret payload from an encrypted circuit (for the purpose of communicating it in minimal overhead).

Parameters:
total_size - total size of the circuit's payload in bytes.
Returns:
a byte array with the relevant information.

cinjectSecPayload

public void cinjectSecPayload(byte[] info)
Inject secret payload into a circuit.

Parameters:
info - byte array with data to inject

isCorrect

public boolean isCorrect()
Verify that an exposed garbled circuit is correct (done by Alice in order to prevent cheating by Bob).

Returns:
true if the circuit is correct.

evalCircuit

public void evalCircuit()
Evaluate a circuit


evalGarbledCircuit

public void evalGarbledCircuit(boolean alice_interpret,
                               boolean bob_interpret)
Evaluate a garbled circuit

Parameters:
alice_interpret - - interpret Alice garbled outputs
bob_interpret - - interpret Bob garbled outputs

printCircuit

public void printCircuit()
For debugging purposes.