viff

changeset 1548:6191f86d814b

BeDOZa: Use broadcast instead of send.
author Janus Dam Nielsen <janus.nielsen@alexandra.dk>
date Tue, 21 Sep 2010 15:42:57 +0200
parents dae353266aa6
children 9a89c3397c9a
files viff/bedoza/share.py
diffstat 1 files changed, 11 insertions(+), 5 deletions(-) [+]
line diff
     1.1 --- a/viff/bedoza/share.py	Tue Sep 21 11:51:35 2010 +0200
     1.2 +++ b/viff/bedoza/share.py	Tue Sep 21 15:42:57 2010 +0200
     1.3 @@ -15,6 +15,8 @@
     1.4  # You should have received a copy of the GNU Lesser General Public
     1.5  # License along with VIFF. If not, see <http://www.gnu.org/licenses/>.
     1.6  
     1.7 +from twisted.internet.defer import gatherResults
     1.8 +
     1.9  from viff.bedoza.shares import PartialShareContents
    1.10  from viff.bedoza.util import _convolute
    1.11  
    1.12 @@ -34,9 +36,12 @@
    1.13      list_of_enc_shares = []
    1.14      for field_element in field_elements:
    1.15          list_of_enc_shares.append(paillier.encrypt(field_element.value))
    1.16 -        
    1.17 -    list_of_enc_shares = _convolute(runtime, list_of_enc_shares, deserialize=eval)
    1.18 +       
    1.19 +    list_of_enc_shares = runtime.broadcast(runtime.players.keys(), runtime.players.keys(),
    1.20 +                                           str(list_of_enc_shares))
    1.21 +    
    1.22      def create_partial_share(list_of_enc_shares, field_elements):
    1.23 +        list_of_enc_shares = [eval(x) for x in list_of_enc_shares]
    1.24  
    1.25          reordered_encrypted_shares = [[] for _ in list_of_enc_shares[0]]
    1.26          for enc_shares in list_of_enc_shares:
    1.27 @@ -47,7 +52,8 @@
    1.28          for enc_shares, field_element in zip(reordered_encrypted_shares, field_elements):
    1.29              partialShareContents.append(PartialShareContents(field_element, enc_shares, N_squared_list))
    1.30          return partialShareContents
    1.31 -    
    1.32 -    runtime.schedule_callback(list_of_enc_shares, create_partial_share, field_elements)
    1.33 -    return list_of_enc_shares
    1.34 +
    1.35 +    d = gatherResults(list_of_enc_shares)
    1.36 +    runtime.schedule_callback(d, create_partial_share, field_elements)
    1.37 +    return d
    1.38