changeset 967:3ad2a2728f33

Folded _shamir_share into mul.
author Martin Geisler <mg@daimi.au.dk>
date Tue, 07 Oct 2008 20:55:32 +0200
parents 352b186a79af
children f4de7f56103e
files viff/runtime.py
diffstat 1 files changed, 15 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/viff/runtime.py	Tue Oct 07 20:31:03 2008 +0200
+++ b/viff/runtime.py	Tue Oct 07 20:55:32 2008 +0200
@@ -813,6 +813,20 @@
         # At this point both share_a and share_b must be Share
         # objects. So we wait on them, multiply and reshare.
 
+        def share(number):
+            """Share a FieldElement using Shamir sharing.
+
+            Returns a list of (id, share) pairs.
+            """
+            shares = shamir.share(number, self.threshold, self.num_players)
+
+            result = []
+            for peer_id, share in shares:
+                d = self._exchange_shares(peer_id.value, share)
+                d.addCallback(lambda share, peer_id: (peer_id, share), peer_id)
+                result.append(d)
+            return result
+
         def recombine(shares):
             # Recombine the first 2t+1 shares.
             result = gather_shares(shares[:2*self.threshold+1])
@@ -821,7 +835,7 @@
 
         result = gather_shares([share_a, share_b])
         result.addCallback(lambda (a, b): a * b)
-        self.schedule_callback(result, self._shamir_share)
+        self.schedule_callback(result, share)
         self.schedule_callback(result, recombine)
         return result
 
@@ -1026,22 +1040,6 @@
         return (b_p, b ^ r_lsb)
 
     @increment_pc
-    def _shamir_share(self, number):
-        """Share a FieldElement using Shamir sharing.
-
-        Returns a list of (id, share) pairs.
-        """
-        shares = shamir.share(number, self.threshold, self.num_players)
-
-        result = []
-        for peer_id, share in shares:
-            d = self._exchange_shares(peer_id.value, share)
-            d.addCallback(lambda share, peer_id: (peer_id, share), peer_id)
-            result.append(d)
-
-        return result
-
-    @increment_pc
     def shamir_share(self, inputters, field, number=None, threshold=None):
         """Secret share *number* over *field* using Shamir's method.