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 wrap: on
line diff
--- a/viff/bedoza/share.py	Tue Sep 21 11:51:35 2010 +0200
+++ b/viff/bedoza/share.py	Tue Sep 21 15:42:57 2010 +0200
@@ -15,6 +15,8 @@
 # You should have received a copy of the GNU Lesser General Public
 # License along with VIFF. If not, see <http://www.gnu.org/licenses/>.
 
+from twisted.internet.defer import gatherResults
+
 from viff.bedoza.shares import PartialShareContents
 from viff.bedoza.util import _convolute
 
@@ -34,9 +36,12 @@
     list_of_enc_shares = []
     for field_element in field_elements:
         list_of_enc_shares.append(paillier.encrypt(field_element.value))
-        
-    list_of_enc_shares = _convolute(runtime, list_of_enc_shares, deserialize=eval)
+       
+    list_of_enc_shares = runtime.broadcast(runtime.players.keys(), runtime.players.keys(),
+                                           str(list_of_enc_shares))
+    
     def create_partial_share(list_of_enc_shares, field_elements):
+        list_of_enc_shares = [eval(x) for x in list_of_enc_shares]
 
         reordered_encrypted_shares = [[] for _ in list_of_enc_shares[0]]
         for enc_shares in list_of_enc_shares:
@@ -47,7 +52,8 @@
         for enc_shares, field_element in zip(reordered_encrypted_shares, field_elements):
             partialShareContents.append(PartialShareContents(field_element, enc_shares, N_squared_list))
         return partialShareContents
-    
-    runtime.schedule_callback(list_of_enc_shares, create_partial_share, field_elements)
-    return list_of_enc_shares
+
+    d = gatherResults(list_of_enc_shares)
+    runtime.schedule_callback(d, create_partial_share, field_elements)
+    return d