viff

changeset 968:f4de7f56103e

Merged share and recombine in mul.
author Martin Geisler <mg@daimi.au.dk>
date Tue, 07 Oct 2008 21:11:00 +0200
parents 3ad2a2728f33
children 343dbf9675d6
files viff/runtime.py
diffstat 1 files changed, 5 insertions(+), 12 deletions(-) [+]
line diff
     1.1 --- a/viff/runtime.py	Tue Oct 07 20:55:32 2008 +0200
     1.2 +++ b/viff/runtime.py	Tue Oct 07 21:11:00 2008 +0200
     1.3 @@ -813,30 +813,23 @@
     1.4          # At this point both share_a and share_b must be Share
     1.5          # objects. So we wait on them, multiply and reshare.
     1.6  
     1.7 -        def share(number):
     1.8 -            """Share a FieldElement using Shamir sharing.
     1.9 -
    1.10 -            Returns a list of (id, share) pairs.
    1.11 -            """
    1.12 +        def share_recombine(number):
    1.13              shares = shamir.share(number, self.threshold, self.num_players)
    1.14  
    1.15 -            result = []
    1.16 +            exchanged_shares = []
    1.17              for peer_id, share in shares:
    1.18                  d = self._exchange_shares(peer_id.value, share)
    1.19                  d.addCallback(lambda share, peer_id: (peer_id, share), peer_id)
    1.20 -                result.append(d)
    1.21 -            return result
    1.22 +                exchanged_shares.append(d)
    1.23  
    1.24 -        def recombine(shares):
    1.25              # Recombine the first 2t+1 shares.
    1.26 -            result = gather_shares(shares[:2*self.threshold+1])
    1.27 +            result = gather_shares(exchanged_shares[:2*self.threshold+1])
    1.28              result.addCallback(shamir.recombine)
    1.29              return result
    1.30  
    1.31          result = gather_shares([share_a, share_b])
    1.32          result.addCallback(lambda (a, b): a * b)
    1.33 -        self.schedule_callback(result, share)
    1.34 -        self.schedule_callback(result, recombine)
    1.35 +        self.schedule_callback(result, share_recombine)
    1.36          return result
    1.37  
    1.38      @increment_pc