changeset 587:bc6db28e18d0

Moved _exchange_shares and _expect_share to BasicRuntime.
author Martin Geisler <mg@daimi.au.dk>
date Wed, 19 Mar 2008 23:29:38 +0100
parents 4c10edd5c7a4
children 7c14124ca29e
files viff/runtime.py
diffstat 1 files changed, 22 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/viff/runtime.py	Wed Mar 19 23:26:40 2008 +0100
+++ b/viff/runtime.py	Wed Mar 19 23:29:38 2008 +0100
@@ -560,6 +560,28 @@
             # We have already received the data from the other side.
             deferred.callback(data)
 
+    def _exchange_shares(self, id, field_element):
+        """Exchange shares with another player.
+
+        We send the player our share and record a Deferred which will
+        trigger when the share from the other side arrives.
+        """
+        assert isinstance(field_element, FieldElement)
+
+        if id == self.id:
+            return Share(self, field_element.field, field_element)
+        else:
+            share = self._expect_share(id, field_element.field)
+            pc = tuple(self.program_counter)
+            self.protocols[id].sendShare(pc, field_element)
+            return share
+
+    def _expect_share(self, peer_id, field):
+        share = Share(self, field)
+        share.addCallback(lambda value: field(value))
+        self._expect_data(peer_id, "share", share)
+        return share
+
 
 class Runtime(BasicRuntime):
     """The VIFF runtime.
@@ -1015,28 +1037,6 @@
         
         return result
 
-    def _exchange_shares(self, id, field_element):
-        """Exchange shares with another player.
-
-        We send the player our share and record a Deferred which will
-        trigger when the share from the other side arrives.
-        """
-        assert isinstance(field_element, FieldElement)
-
-        if id == self.id:
-            return Share(self, field_element.field, field_element)
-        else:
-            share = self._expect_share(id, field_element.field)
-            pc = tuple(self.program_counter)
-            self.protocols[id].sendShare(pc, field_element)
-            return share
-
-    def _expect_share(self, peer_id, field):
-        share = Share(self, field)
-        share.addCallback(lambda value: field(value))
-        self._expect_data(peer_id, "share", share)
-        return share
-
     @increment_pc
     def _recombine(self, shares, threshold):
         """Shamir recombine a list of deferred (id,share) pairs."""