viff

changeset 1538:9d4f9551644c

Added computation-id option. This changeset adds a command line option to VIFF allowing users to specify a computation id. Prior to this changeset, any computation involving pseudo-random secret sharing (which for the time being boils down to computations done with the PassiveRuntime) could only be run one time using the same set of VIFF player configuration files. If more than one computation was executed with the same set of configuration files, the security of the system would be broken. With this changeset, multiple computations can be run securely with the same set of configuration files as long as each computation is run with a unique computation id.
author Tomas Toft <ttoft at cs.au.dk>
date Wed, 11 Aug 2010 16:09:32 +0200
parents 9c938858c46b
children 1ffd6d928a7f d2f48fac982a
files viff/runtime.py viff/test/test_basic_runtime.py viff/test/test_orlandi_runtime.py
diffstat 3 files changed, 23 insertions(+), 12 deletions(-) [+]
line diff
     1.1 --- a/viff/runtime.py	Wed Aug 11 11:47:45 2010 +0200
     1.2 +++ b/viff/runtime.py	Wed Aug 11 16:09:32 2010 +0200
     1.3 @@ -536,6 +536,11 @@
     1.4                           "multiple times on the command line; the first will "
     1.5                           "override host and port of player 1, the second that "
     1.6                           "of player 2, and so forth.")
     1.7 +        group.add_option("--computation-id", type="int", metavar="ID",
     1.8 +                         help="Set the (positive, integer) ID for this "
     1.9 +                         "computation. All IDs for runs using the same set "
    1.10 +                         "of player configuration files must be unique "
    1.11 +                         "to ensure security.")
    1.12  
    1.13          try:
    1.14              # Using __import__ since we do not use the module, we are
    1.15 @@ -551,7 +556,8 @@
    1.16                              deferred_debug=False,
    1.17                              profile=False,
    1.18                              track_memory=False,
    1.19 -                            statistics=False)
    1.20 +                            statistics=False,
    1.21 +                            computation_id=None)
    1.22  
    1.23      def __init__(self, player, threshold, options=None):
    1.24          """Initialize runtime.
    1.25 @@ -585,7 +591,12 @@
    1.26          self._needed_data = {}
    1.27  
    1.28          #: Current program counter.
    1.29 -        self.program_counter = [0]
    1.30 +        __comp_id = self.options.computation_id
    1.31 +        if __comp_id is None:
    1.32 +            __comp_id = 0
    1.33 +        else:
    1.34 +            assert __comp_id > 0, "Non-positive ID: %d." % __comp_id
    1.35 +        self.program_counter = [__comp_id, 0]
    1.36  
    1.37          #: Connections to the other players.
    1.38          #:
     2.1 --- a/viff/test/test_basic_runtime.py	Wed Aug 11 11:47:45 2010 +0200
     2.2 +++ b/viff/test/test_basic_runtime.py	Wed Aug 11 16:09:32 2010 +0200
     2.3 @@ -25,7 +25,7 @@
     2.4  
     2.5      @protocol
     2.6      def test_initial_value(self, runtime):
     2.7 -        self.assertEquals(runtime.program_counter, [0])
     2.8 +        self.assertEquals(runtime.program_counter, [0, 0])
     2.9  
    2.10      @protocol
    2.11      def test_synchronize(self, runtime):
    2.12 @@ -33,11 +33,11 @@
    2.13  
    2.14          Every synchronize operation should have its unique program
    2.15          counter."""
    2.16 -        self.assertEquals(runtime.program_counter, [0])
    2.17 +        self.assertEquals(runtime.program_counter, [0, 0])
    2.18          runtime.synchronize()
    2.19 -        self.assertEquals(runtime.program_counter, [1])
    2.20 +        self.assertEquals(runtime.program_counter, [0, 1])
    2.21          runtime.synchronize()
    2.22 -        self.assertEquals(runtime.program_counter, [2])
    2.23 +        self.assertEquals(runtime.program_counter, [0, 2])
    2.24  
    2.25      @protocol
    2.26      def test_callback(self, runtime):
    2.27 @@ -49,15 +49,15 @@
    2.28  
    2.29          def verify_program_counter(_):
    2.30              # The callback is run with its own sub-program counter.
    2.31 -            self.assertEquals(runtime.program_counter, [1, 0])
    2.32 +            self.assertEquals(runtime.program_counter, [0, 1, 0])
    2.33  
    2.34          d = Deferred()
    2.35  
    2.36 -        self.assertEquals(runtime.program_counter, [0])
    2.37 +        self.assertEquals(runtime.program_counter, [0, 0])
    2.38  
    2.39          # Scheduling a callback increases the program counter.
    2.40          runtime.schedule_callback(d, verify_program_counter)
    2.41 -        self.assertEquals(runtime.program_counter, [1])
    2.42 +        self.assertEquals(runtime.program_counter, [0, 1])
    2.43  
    2.44          # Now trigger verify_program_counter.
    2.45          d.callback(None)
    2.46 @@ -69,11 +69,11 @@
    2.47          d2 = Deferred()
    2.48  
    2.49          def verify_program_counter(_, count):
    2.50 -            self.assertEquals(runtime.program_counter, [count, 0])
    2.51 +            self.assertEquals(runtime.program_counter, [0, count, 0])
    2.52  
    2.53          def method_a(runtime):
    2.54              # No calls to schedule_callback yet.
    2.55 -            self.assertEquals(runtime.program_counter, [0])
    2.56 +            self.assertEquals(runtime.program_counter, [0, 0])
    2.57  
    2.58              runtime.schedule_callback(d1, verify_program_counter, 1)
    2.59              runtime.schedule_callback(d2, verify_program_counter, 2)
     3.1 --- a/viff/test/test_orlandi_runtime.py	Wed Aug 11 11:47:45 2010 +0200
     3.2 +++ b/viff/test/test_orlandi_runtime.py	Wed Aug 11 16:09:32 2010 +0200
     3.3 @@ -410,7 +410,7 @@
     3.4  
     3.5          def r1(ls):
     3.6              x, y = ls
     3.7 -            self.assertEquals(runtime.program_counter, [4])
     3.8 +            self.assertEquals(runtime.program_counter, [0, 4])
     3.9  
    3.10          x = runtime.shift([1], self.Zp, 42)
    3.11          y = runtime.shift([2], self.Zp, 42)