viff

changeset 1059:476bac16b2d9

Added abstract methods to Runtime. The idea is that all classes inheriting from Runtime should define input, output, add, and mul methods with the interface from Runtime.
author Martin Geisler <mg@daimi.au.dk>
date Tue, 16 Dec 2008 13:21:27 +0100
parents 806148d6146f
children 81b22c71a13e
files viff/runtime.py
diffstat 1 files changed, 35 insertions(+), 0 deletions(-) [+]
line diff
     1.1 --- a/viff/runtime.py	Tue Dec 16 13:21:22 2008 +0100
     1.2 +++ b/viff/runtime.py	Tue Dec 16 13:21:27 2008 +0100
     1.3 @@ -680,6 +680,41 @@
     1.4              wait_list.append(ready)
     1.5          return DeferredList(wait_list)
     1.6  
     1.7 +    def input(self, inputters, field, number=None):
     1.8 +        """Input *number* to the computation.
     1.9 +
    1.10 +        The players listed in *inputters* must provide an input
    1.11 +        number, everybody will receive a list with :class:`Share`
    1.12 +        objects, one from each *inputter*. If only a single player is
    1.13 +        listed in *inputters*, then a :class:`Share` is given back
    1.14 +        directly.
    1.15 +        """
    1.16 +        raise NotImplemented("Override this abstract method in a subclass.")
    1.17 +
    1.18 +    def output(self, share, receivers=None):
    1.19 +        """Open *share* to *receivers* (defaults to all players).
    1.20 +
    1.21 +        Returns a :class:`Share` to players with IDs in *receivers*
    1.22 +        and :const:`None` to the remaining players.
    1.23 +        """
    1.24 +        raise NotImplemented("Override this abstract method in a subclass.")
    1.25 +
    1.26 +    def add(self, share_a, share_b):
    1.27 +        """Secure addition.
    1.28 +        
    1.29 +        At least one of the arguments must be a :class:`Share`, the
    1.30 +        other can be a :class:`FieldElement` or a (possible long)
    1.31 +        Python integer."""
    1.32 +        raise NotImplemented("Override this abstract method in a subclass.")
    1.33 +
    1.34 +    def mul(self, share_a, share_b):
    1.35 +        """Secure multiplication.
    1.36 +        
    1.37 +        At least one of the arguments must be a :class:`Share`, the
    1.38 +        other can be a :class:`FieldElement` or a (possible long)
    1.39 +        Python integer."""
    1.40 +        raise NotImplemented("Override this abstract method in a subclass.")
    1.41 +
    1.42  
    1.43  def make_runtime_class(runtime_class=None, mixins=None):
    1.44      """Creates a new runtime class with *runtime_class* as a base