cicada.calculator module

Implements a client and a server for an MPC-as-a-service calculator.

class cicada.calculator.Client(addresses)[source]

Bases: object

Client for working with the privacy-preserving RPN calculator service.

Parameters:

addresses (sequence of str, required) – Socket addresses of the players providing an RPN calculator service.

command(command, *, player=None, **kwargs)[source]

Sends a command to the players providing an RPN calculator service.

Parameters:
  • command (str) – The command to be executed by the RPN calculator service.

  • player (int or sequence of int, optional) – The player(s) that will execute the command. By default, the command will be sent to all players.

  • kwargs – Keyword arguments that will be included with the command.

Returns:

results – Contains the result value returned by each player.

Return type:

sequence of object

property ranks

Returns a list of player ranks provided by the service.

exception cicada.calculator.PlayerError(exception, traceback)[source]

Bases: Exception

Returned from the RPN calculator service when a player raises an exception.

cicada.calculator.main(listen_socket, communicator)[source]

Implements a privacy-preserving RPN calculator service.

This is an example of MPC-as-a-service, for cases where that is desirable. Run this function using:

SocketCommunicator.run_forever(world_size=n, fn=cicada.calculator.main)

… which will start the service and return a set of player addresses and processes. Client code can use those addressess to connect to the service and issue commands, which will be executed by the service players.

The service implements an RPN calculator where communicators, protocols, and operands are pushed and popped from stacks.