public interface FastGarbledBooleanCircuit
FastGarbledBooleanCircuit
is a general interface for all basic garbled circuits.
Fast garbled boolean circuit includes the same functionality as the regular garbled boolean circuit
but it does it faster due to simpler data structures that does not need any conversion to the native code.As the garbledBooleanCircuit interface, fast garbled circuits have four main operations:
1. The garble()
function that generates the keys and creates the garbled tables.
2. The compute()
function computes a result on a garbled circuit whose input has been set.
3. The verify(byte[])
method is used in the case of a malicious adversary to verify that the garbled circuit
created is an honest garbling of the agreed upon non garbled circuit. For example, the constructing party constructs many garbled circuits and
the second party chooses all but one of them to verify and test the honesty of the constructing party.
4. The translate(byte[])
that translates the garbled output from compute()
into meaningful output.
Modifier and Type  Method and Description 

byte[] 
compute()
This method computes the circuit using the given inputs.

FastCircuitCreationValues 
garble()
This method generates both keys for each wire.

FastCircuitCreationValues 
garble(byte[] seed)
This method generates both keys for each input wire using the seed.

byte[] 
getGarbledInputFromUngarbledInput(byte[] ungarbledInputBits,
byte[] allInputWireValues,
int partyNumber)
This method takes an array containing the non garbled values, both keys for all input wires and the party number which the inputs belong to.

GarbledTablesHolder 
getGarbledTables()
The garbled tables are stored in the circuit for all the gates.

int[] 
getInputWireIndices() 
int[] 
getInputWireIndices(int partyNumber)
Returns the input wires' indices of the given party.

int 
getKeySize() 
int 
getNumberOfInputs(int partyNumber)
Returns the number of input wires of the given party.

int 
getNumberOfParties()
Returns the number of parties using this circuit.

int[] 
getOutputWireIndices() 
byte[] 
getTranslationTable()
Returns the translation table of the circuit.

boolean 
internalVerify(byte[] allInputWireValues,
byte[] allOutputWireValues)
This function behaves exactly as the verify(byte[] allInputWireValues) method except the last part.

void 
setGarbledTables(GarbledTablesHolder garbledTables)
Sets the garbled tables of this circuit.

void 
setInputs(byte[] garbledInputs) 
void 
setTranslationTable(byte[] translationTable)
Sets the translation table of the circuit.

byte[] 
translate(byte[] garbledOutput)
Translates the garbled output obtained from the
compute() function into a meaningful(i.e. 
byte[] 
verifiedTranslate(byte[] garbledOutput,
byte[] allOutputWireValues)
Verifies that the given garbledOutput is valid values according to the given all OutputWireValues.

boolean 
verify(byte[] allInputWireValues)
The verify method is used in the case of malicious adversaries.

boolean 
verifyTranslationTable(byte[] allOutputWireValues)
This function does the last part of the verify function.

FastCircuitCreationValues garble()
FastCircuitCreationValues garble(byte[] seed) throws java.security.InvalidKeyException
seed
 Used to initialize the prg.java.security.InvalidKeyException
 In case the seed is an invalid key for the given PRG.byte[] getGarbledInputFromUngarbledInput(byte[] ungarbledInputBits, byte[] allInputWireValues, int partyNumber)
This method then performs the lookup on the allInputWireValues according to the party number and returns the keys of the corresponding input bits.
ungarbledInputBits
 An array containing the non garbled value for each input wire of the given party number.allInputWireValues
 The array containing both garbled values (keys) for each input wire.
The input values are placed one after another, meaning that the input values are in the following format:
[k0,0 k0,1 k1,0 k1,1 k2,0 k2,1 ....] (while k0,1 is key 1 of wire 0).partyNumber
 The number of party which the inputs belong to.void setInputs(byte[] garbledInputs)
byte[] compute() throws NotAllInputsSetException
It returns an array containing the garbled output. This output can be translated via the translate(byte[])
method.
NotAllInputsSetException
 if the given inputs array does not includes a key for all input wires.boolean verify(byte[] allInputWireValues)
Alice constructs n circuits and Bob can verify n1 of them (of his choice) to confirm that they are indeed garbling of the agreed upon non garbled circuit. In order to verify, Alice has to give Bob both keys for each of the input wires.
allInputWireValues
 An array containing both keys for each input wire.
The input values are placed one after another, meaning that the input values are in the following format:
[k0,0 k0,1 k1,0 k1,1 k2,0 k2,1 ....] (while k0,1 is key 1 of wire 0).true
if this GarbledBooleanCircuit
is a garbling the given keys, false
if it is not.boolean internalVerify(byte[] allInputWireValues, byte[] allOutputWireValues)
allInputWireValues
 An array containing both keys for each input wire.
The input values are placed one after another, meaning that the input values are in the following format:
[k0,0 k0,1 k1,0 k1,1 k2,0 k2,1 ....] (while k0,1 is key 1 of wire 0).allOutputWireValues
 An array containing both keys for each output wire.
The output values are placed one after another, meaning that the output values are in the following format:
[k0,0 k0,1 k1,0 k1,1 k2,0 k2,1 ....] (while k0,1 is key 1 of wire 0).
When calling the function this array should be empty and will be filled during the process of the function.true
if this GarbledBooleanCircuit
is a garbling the given keys, false
if it is not.boolean verifyTranslationTable(byte[] allOutputWireValues)
The internalVerify function followed by this function are actually executes the whole verify of the circuit.
allOutputWireValues
 both keys of each output wire.
The output values are placed one after another, meaning that the output values are in the following format:
[k0,0 k0,1 k1,0 k1,1 k2,0 k2,1 ....] (while k0,1 is key 1 of wire 0).true
if the given keys match the translation table ,false
if not.byte[] translate(byte[] garbledOutput)
compute()
function into a meaningful(i.e. 01) output.garbledOutput
 An array contains the garbled output.byte[] verifiedTranslate(byte[] garbledOutput, byte[] allOutputWireValues) throws CheatAttemptException
Meaning, for each output wire, checks that the garbled wire is one of the two possibilities.
Then, translates the garbled output obtained from the compute()
function into a meaningful(i.e. 01) output.
garbledOutput
 An array contains the garbled output.allOutputWireValues
 both values for each output wire.
The output values are placed one after another, meaning that the output values are in the following format:
[k0,0 k0,1 k1,0 k1,1 k2,0 k2,1 ....] (while k0,1 is key 1 of wire 0).CheatAttemptException
 if there is a garbledOutput values that is not one of the two possibilities.GarbledTablesHolder getGarbledTables()
This function is useful if we would like to pass many garbled circuits built on the same boolean circuit.
This is a compact way to define a circuit, that is, two garbled circuit with the same multi encryption scheme and the same basic boolean circuit only differ in the garbled tables and the translation table.
Thus we can hold one garbled circuit for all the circuits and only replace the garbled tables (and the translation tables if necessary). The advantage is that the size of the tables only is much smaller that all the information stored in the circuit (gates and other member variables). The size becomes important when sending large circuits.
void setGarbledTables(GarbledTablesHolder garbledTables)
This function is useful if we would like to pass many garbled circuits built on the same boolean circuit.
This is a compact way to define a circuit, that is, two garbled circuit with the same multi encryption scheme and the same basic boolean circuit only differ in the garbled tables and the translation table.
Thus we can hold one garbled circuit for all the circuits and only replace the garbled tables (and the translation tables if necessary). The advantage is that the size of the tables only is much smaller that all the information stored in the circuit (gates and other member variables). The size becomes important when sending large circuits.
The receiver of the circuits will set the garbled tables for the relevant circuit.
byte[] getTranslationTable()
This is necessary since the constructor of the circuit may want to pass the translation table to an other party.
Usually, this will be used when the other party (not the constructor of the circuit) creates a circuit, sets the garbled tables and needs the translation table as well to complete the construction of the circuit.
void setTranslationTable(byte[] translationTable)
This is necessary when the garbled tables where set and we would like to compute the circuit later on.
translationTable
 This value should match the garbled tables of the circuit.int[] getInputWireIndices(int partyNumber) throws NoSuchPartyException
partyNumber
 The number of the party which we need his input wire indices.NoSuchPartyException
 In case the given party number is not valid.int[] getOutputWireIndices()
int[] getInputWireIndices()
int getNumberOfInputs(int partyNumber) throws NoSuchPartyException
partyNumber
 the number of the party which we need his number of inputs.NoSuchPartyException
 In case the given party number is not valid.int getNumberOfParties()
int getKeySize()