SFE.BOAL
Class Formatter

java.lang.Object
  extended by SFE.BOAL.Formatter
All Implemented Interfaces:
java.io.Serializable

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

Formatter The format file describes the I/O with Alice and Bob in the following format:

Input line:
Alice/Bob input type "prompt-string" [ line-num1 .. line-numk ]

This line has the following interpretation: First, it designated this as Alice or Bob's input. The 'type' specifies the type of input, e.g., integer. The input will be provided by prompting Alice using "prompt-string". The input value is internally translated into k bits, LSB to MSB. These bits are given as input bits to gates in the designated lines.

Output line:
Alice/Bob output type "output-prefix" [ line-num1 .. line-numk ]

This line has the following interpretation: First, it designated this as Alice or Bob's output. The 'type' specifies the type of output, e.g., integer. The output will be gathered from k output gates, LSB to MSB, in the designated output gate lines. These output bits are translated into a value of the designated type, and printed with the designated "output-prefix"

Example file is:
Alice input integer "Enter # employees (up to 3): " [ 1 2 ] Bob input integer "Enter # employees (up to 3): " [ 3 4 ] Alice output integer "Total # employees: " [ 100 101 102 ] Bob output integer "Total # employees: " [ 100 101 102 ] This indicates that Alice should be prompted for an integer no greater than 3, which appears as input wires 1 and 2. Similarly, Bob should be prompted for his integer value for input wires 3 and 4. The output for Alice is an integer built off of output wires 100,101,102; likewise is Bob's output.

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

Constructor Summary
Formatter(java.io.StreamTokenizer st)
           
 
Method Summary
 byte[] fextractInpPayload(Circuit c, int total_size, boolean alice_inputs)
          Extract input payload from an encrypted circuit (for the purpose of communicating it in minimal overhead).
 byte[] fextractOutPayload(Circuit c, int total_size, boolean alice_inputs)
          Extract output payload from an encrypted circuit (for the purpose of communicating it in minimal overhead).
 void finjectInpPayload(Circuit c, byte[] info, boolean alice_inputs)
          Inject input payload into a circuit.
 void finjectOutPayload(Circuit c, byte[] info, boolean alice_outputs)
          Inject output payload into a circuit.
 void getAliceInput(Circuit c, java.io.BufferedReader br)
           
 void getAliceOutput(Circuit c)
           
 void getBobInput(Circuit c, java.io.BufferedReader br)
           
 void getBobOutput(Circuit c)
           
 void getInput(Circuit c, boolean is_alice, java.io.BufferedReader br)
          This routine prompts for Alice or Bob inputs, and sets the corresponding wires binary values.
 void getOutput(Circuit c, boolean is_alice)
          This routine collects all output results from the circuit for either Alice or Bob, and prints them out (the circuit must be already evaluated).
 void markIO(Circuit c, int[] tsize)
          This routine marks all the input/output gates of a circuit as belonging to either Alice or Bob.
 void parse()
          The parse() method is the parser of the formatter input file.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Formatter

public Formatter(java.io.StreamTokenizer st)
Method Detail

markIO

public void markIO(Circuit c,
                   int[] tsize)
This routine marks all the input/output gates of a circuit as belonging to either Alice or Bob.

Parameters:
c - a gate-level circuit

getBobInput

public void getBobInput(Circuit c,
                        java.io.BufferedReader br)

getAliceInput

public void getAliceInput(Circuit c,
                          java.io.BufferedReader br)

getInput

public void getInput(Circuit c,
                     boolean is_alice,
                     java.io.BufferedReader br)
This routine prompts for Alice or Bob inputs, and sets the corresponding wires binary values.

Parameters:
c - a gate-level circuit
is_alice - indicates whether this input is for Alice or Bob

getBobOutput

public void getBobOutput(Circuit c)

getAliceOutput

public void getAliceOutput(Circuit c)

getOutput

public void getOutput(Circuit c,
                      boolean is_alice)
This routine collects all output results from the circuit for either Alice or Bob, and prints them out (the circuit must be already evaluated).

Parameters:
c - a gate-level circuit
is_alice - indicates whether this output is for Alice or Bob

fextractInpPayload

public byte[] fextractInpPayload(Circuit c,
                                 int total_size,
                                 boolean alice_inputs)
Extract input payload from an encrypted circuit (for the purpose of communicating it in minimal overhead).

Parameters:
c - a gate-level circuit
total_size - total size of the circuit's payload in bytes.
alice_inputs - true for alice, false for bob
Returns:
a byte array with the relevant information.

finjectInpPayload

public void finjectInpPayload(Circuit c,
                              byte[] info,
                              boolean alice_inputs)
Inject input payload into a circuit.

Parameters:
c - a gate-level circuit
info - byte array with data to inject
alice_inputs - true for alice, false for bob

fextractOutPayload

public byte[] fextractOutPayload(Circuit c,
                                 int total_size,
                                 boolean alice_inputs)
Extract output payload from an encrypted circuit (for the purpose of communicating it in minimal overhead).

Parameters:
c - a gate-level circuit
total_size - total size of the circuit's payload in bytes.
alice_inputs - true for alice, false for bob
Returns:
a byte array with the relevant information.

finjectOutPayload

public void finjectOutPayload(Circuit c,
                              byte[] info,
                              boolean alice_outputs)
Inject output payload into a circuit.

Parameters:
c - a gate-level circuit
info - byte array with data to inject
alice_outputs - true for alice, false for bob

parse

public void parse()
           throws FormatterError
The parse() method is the parser of the formatter input file. It is called at the beginning of the IO format definition file, and it consumes the entire input file while building an internal representation of the I/O format

Throws:
- - FormatterError.
FormatterError