viff

changeset 642:885828ebed92

Created new ActiveRuntime class. The idea is that this class will (eventually) become secure against active adversaries. So far the Bracha broadcast has been moved to it.
author Martin Geisler <mg@daimi.au.dk>
date Sat, 05 Apr 2008 00:00:24 +0200
parents e093f8fcd640
children 84d720a9ed4b
files viff/runtime.py viff/test/test_active_runtime.py
diffstat 2 files changed, 27 insertions(+), 16 deletions(-) [+]
line diff
     1.1 --- a/viff/runtime.py	Sat Apr 05 00:00:24 2008 +0200
     1.2 +++ b/viff/runtime.py	Sat Apr 05 00:00:24 2008 +0200
     1.3 @@ -929,6 +929,30 @@
     1.4              return results
     1.5  
     1.6      @increment_pc
     1.7 +    def _recombine(self, shares, threshold):
     1.8 +        """Shamir recombine a list of deferred (id,share) pairs."""
     1.9 +        assert len(shares) > threshold
    1.10 +
    1.11 +        def filter_good_shares(results):
    1.12 +            # Filter results, which is a list of (success, share)
    1.13 +            # pairs.
    1.14 +            return [result[1] for result in results
    1.15 +                    if result is not None and result[0]][:threshold+1]
    1.16 +
    1.17 +        result = ShareList(shares, threshold+1)
    1.18 +        result.addCallback(filter_good_shares)
    1.19 +        result.addCallback(shamir.recombine)
    1.20 +        return result
    1.21 +
    1.22 +
    1.23 +class ActiveRuntime(Runtime):
    1.24 +    """A runtime secure against active adversaries.
    1.25 +
    1.26 +    This class currently inherits most of its functionality from the
    1.27 +    normal L{Runtime} class and is thus I{not} yet secure.
    1.28 +    """
    1.29 +
    1.30 +    @increment_pc
    1.31      def _broadcast(self, sender, message=None):
    1.32          """Perform a Bracha broadcast.
    1.33  
    1.34 @@ -1066,22 +1090,6 @@
    1.35  
    1.36          return result
    1.37  
    1.38 -    @increment_pc
    1.39 -    def _recombine(self, shares, threshold):
    1.40 -        """Shamir recombine a list of deferred (id,share) pairs."""
    1.41 -        assert len(shares) > threshold
    1.42 -
    1.43 -        def filter_good_shares(results):
    1.44 -            # Filter results, which is a list of (success, share)
    1.45 -            # pairs.
    1.46 -            return [result[1] for result in results
    1.47 -                    if result is not None and result[0]][:threshold+1]
    1.48 -
    1.49 -        result = ShareList(shares, threshold+1)
    1.50 -        result.addCallback(filter_good_shares)
    1.51 -        result.addCallback(shamir.recombine)
    1.52 -        return result
    1.53 -
    1.54  
    1.55  def create_runtime(id, players, threshold, options=None, runtime_class=Runtime):
    1.56      """Create a L{Runtime} and connect to the other players.
     2.1 --- a/viff/test/test_active_runtime.py	Sat Apr 05 00:00:24 2008 +0200
     2.2 +++ b/viff/test/test_active_runtime.py	Sat Apr 05 00:00:24 2008 +0200
     2.3 @@ -18,6 +18,7 @@
     2.4  from twisted.internet.defer import gatherResults
     2.5  
     2.6  from viff.test.util import RuntimeTestCase, protocol
     2.7 +from viff.runtime import ActiveRuntime
     2.8  
     2.9  
    2.10  class ActiveRuntimeTest(RuntimeTestCase):
    2.11 @@ -29,6 +30,8 @@
    2.12      #: default threshold of t=1, we need n=4.
    2.13      num_players = 4
    2.14  
    2.15 +    runtime_class = ActiveRuntime
    2.16 +
    2.17      @protocol
    2.18      def test_broadcast(self, runtime):
    2.19          """Test Bracha broadcast."""