viff

changeset 965:24ca90163151

Move _recombine into the open method. This was the only place that used _recombine after mul was fixed.
author Martin Geisler <mg@daimi.au.dk>
date Tue, 07 Oct 2008 20:30:03 +0200
parents 003ca9e1ad90
children 352b186a79af
files viff/runtime.py
diffstat 1 files changed, 14 insertions(+), 16 deletions(-) [+]
line diff
     1.1 --- a/viff/runtime.py	Tue Oct 07 20:00:49 2008 +0200
     1.2 +++ b/viff/runtime.py	Tue Oct 07 20:30:03 2008 +0200
     1.3 @@ -723,6 +723,19 @@
     1.4          if threshold is None:
     1.5              threshold = self.threshold
     1.6  
     1.7 +        def filter_good_shares(results):
     1.8 +            # Filter results, which is a list of (success, share)
     1.9 +            # pairs.
    1.10 +            return [result[1] for result in results
    1.11 +                    if result is not None and result[0]][:threshold+1]
    1.12 +
    1.13 +        def recombine(shares):
    1.14 +            assert len(shares) > threshold
    1.15 +            result = ShareList(shares, threshold+1)
    1.16 +            result.addCallback(filter_good_shares)
    1.17 +            result.addCallback(shamir.recombine)
    1.18 +            return result
    1.19 +
    1.20          def exchange(share):
    1.21              # Send share to all receivers.
    1.22              for peer_id in receivers:
    1.23 @@ -739,7 +752,7 @@
    1.24                          d = self._expect_share(peer_id, share.field)
    1.25                          self.schedule_callback(d, lambda s, peer_id: (s.field(peer_id), s), peer_id)
    1.26                      deferreds.append(d)
    1.27 -                return self._recombine(deferreds, threshold)
    1.28 +                return recombine(deferreds)
    1.29  
    1.30          result = share.clone()
    1.31          self.schedule_callback(result, exchange)
    1.32 @@ -1063,21 +1076,6 @@
    1.33          else:
    1.34              return results
    1.35  
    1.36 -    @increment_pc
    1.37 -    def _recombine(self, shares, threshold):
    1.38 -        """Shamir recombine a list of deferred (id,share) pairs."""
    1.39 -        assert len(shares) > threshold
    1.40 -
    1.41 -        def filter_good_shares(results):
    1.42 -            # Filter results, which is a list of (success, share)
    1.43 -            # pairs.
    1.44 -            return [result[1] for result in results
    1.45 -                    if result is not None and result[0]][:threshold+1]
    1.46 -
    1.47 -        result = ShareList(shares, threshold+1)
    1.48 -        result.addCallback(filter_good_shares)
    1.49 -        result.addCallback(shamir.recombine)
    1.50 -        return result
    1.51  
    1.52  def make_runtime_class(runtime_class=Runtime, mixins=None):
    1.53      """Creates a new runtime class with *runtime_class* as a base