Package viff :: Module runtime :: Class Runtime
[hide private]
[frames] | no frames]

Class Runtime

source code


Basic VIFF runtime with no crypto.

This runtime contains only the most basic operations needed such as the program counter, the list of other players, etc.

Instance Methods [hide private]
 
__init__(self, player, threshold, options=None)
Initialize runtime.
source code
 
_exchange_shares(self, peer_id, field_element)
Exchange shares with another player.
source code
 
_expect_data(self, peer_id, data_type, deferred) source code
 
_expect_data_with_pc(self, pc, peer_id, data_type, deferred) source code
 
_expect_share(self, peer_id, field) source code
 
abort(self, protocol, exc)
Abort the execution due to an exception.
source code
 
activate_reactor(self)
Activate the reactor to do actual communcation.
source code
 
add(self, share_a, share_b)
Secure addition.
source code
 
add_player(self, player, protocol) source code
 
fork_pc(self)
Fork the program counter.
source code
 
handle_deferred_data(self, deferred, data)
Put deferred and data into the queue if the ViffReactor is running.
source code
 
increment_pc(self)
Increment the program counter.
source code
 
input(self, inputters, field, number=None)
Input number to the computation.
source code
 
mul(self, share_a, share_b)
Secure multiplication.
source code
 
output(self, share, receivers=None)
Open share to receivers (defaults to all players).
source code
 
preprocess(self, program)
Generate preprocess material.
source code
 
print_transferred_data(self)
Print the amount of transferred data for all connections.
source code
 
process_deferred_queue(self)
Execute the callbacks of the deferreds in the queue.
source code
 
process_queue(self, queue)
Execute the callbacks of the deferreds in queue.
source code
 
schedule_callback(self, deferred, func, *args, **kwargs)
Schedule a callback on a deferred with the correct program counter.
source code
 
schedule_complex_callback(self, deferred, func, *args, **kwargs)
Schedule a complex callback, i.e.
source code
 
shutdown(self)
Shutdown the runtime.
source code
 
synchronize(self)
Introduce a synchronization point.
source code
 
unfork_pc(self)
Leave a fork of the program counter.
source code
 
wait_for(self, *vars)
Make the runtime wait for the variables given.
source code
Static Methods [hide private]
 
add_options(parser) source code
Instance Variables [hide private]
  _needed_data
Description of needed preprocessed data.
  _pool
Pool of preprocessed data.
  activation_counter
Counter for calls of activate_reactor().
  deferred_queue
Queue of deferreds and data.
  depth_counter
Record the recursion depth.
  depth_limit
Recursion depth limit by experiment, including security margin.
  id
ID of this player.
  num_players
Number of known players.
  players
Information on players.
  program_counter
Current program counter.
  protocols
Connections to the other players.
  threshold
Shamir secret sharing threshold.
  using_viff_reactor
Use deferred queues only if the ViffReactor is running.
Method Details [hide private]

__init__(self, player, threshold, options=None)
(Constructor)

source code 

Initialize runtime.

Initialized a runtime owned by the given, the threshold, and optionally a set of options. The runtime has no network connections and knows of no other players -- the create_runtime function should be used instead to create a usable runtime.

_exchange_shares(self, peer_id, field_element)

source code 

Exchange shares with another player.

We send the player our share and record a Deferred which will trigger when the share from the other side arrives.

abort(self, protocol, exc)

source code 

Abort the execution due to an exception.

The protocol received bad data which resulted in exc being raised when unpacking.

activate_reactor(self)

source code 

Activate the reactor to do actual communcation.

This is where the recursion happens.

add(self, share_a, share_b)

source code 

Secure addition.

At least one of the arguments must be a Share, the other can be a FieldElement or a (possible long) Python integer.

handle_deferred_data(self, deferred, data)

source code 
Put deferred and data into the queue if the ViffReactor is running. Otherwise, just execute the callback.

input(self, inputters, field, number=None)

source code 

Input number to the computation.

The players listed in inputters must provide an input number, everybody will receive a list with Share objects, one from each inputter. If only a single player is listed in inputters, then a Share is given back directly.

mul(self, share_a, share_b)

source code 

Secure multiplication.

At least one of the arguments must be a Share, the other can be a FieldElement or a (possible long) Python integer.

output(self, share, receivers=None)

source code 

Open share to receivers (defaults to all players).

Returns a Share to players with IDs in receivers and None to the remaining players.

preprocess(self, program)

source code 

Generate preprocess material.

The program specifies which methods to call and with which arguments. The generator methods called must adhere to the following interface:

  • They must return a (int, Deferred) tuple where the int tells us how many items of pre-processed data the Deferred will yield.
  • The Deferred must yield a list of the promised length.
  • The list contains the actual data. This data can be either a Deferred or a tuple of Deferreds.

The ActiveRuntime.generate_triples method is an example of a method fulfilling this interface.

process_deferred_queue(self)

source code 

Execute the callbacks of the deferreds in the queue.

If this function is not called via activate_reactor(), also complex callbacks are executed.

schedule_callback(self, deferred, func, *args, **kwargs)

source code 

Schedule a callback on a deferred with the correct program counter.

If a callback depends on the current program counter, then use this method to schedule it instead of simply calling addCallback directly. Simple callbacks that are independent of the program counter can still be added directly to the Deferred as usual.

Any extra arguments are passed to the callback as with addCallback.

schedule_complex_callback(self, deferred, func, *args, **kwargs)

source code 

Schedule a complex callback, i.e. a callback which blocks a long time.

Consider that the deferred is forked, i.e. if the callback returns something to be used afterwards, add further callbacks to the returned deferred.

shutdown(self)

source code 

Shutdown the runtime.

All connections are closed and the runtime cannot be used again after this has been called.

synchronize(self)

source code 

Introduce a synchronization point.

Returns a Deferred which will trigger if and when all other players have made their calls to synchronize. By adding callbacks to the returned Deferred, one can divide a protocol execution into disjoint phases.

wait_for(self, *vars)

source code 

Make the runtime wait for the variables given.

The runtime is shut down when all variables are calculated.


Instance Variable Details [hide private]

num_players

Number of known players.

Equal to len(self.players), but storing it here is more direct.

players

Information on players.

Mapping from Player ID to Player objects.

protocols

Connections to the other players.

Mapping from from Player ID to ShareExchanger objects.