changeset 1342:3a87b4d84eb6

active: Transferred optimizations from PassiveRuntime.
author Marcel Keller <mkeller@cs.au.dk>
date Tue, 27 Oct 2009 20:46:38 +0100
parents 31a1534f6b77
children ab118728e88d
files viff/active.py
diffstat 1 files changed, 6 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/viff/active.py	Tue Oct 27 20:45:20 2009 +0100
+++ b/viff/active.py	Tue Oct 27 20:46:38 2009 +0100
@@ -474,19 +474,15 @@
         Preprocessing: 1 multiplication triple.
         Communication: 2 openings.
         """
-        assert isinstance(share_x, Share) or isinstance(share_y, Share), \
-            "At least one of share_x and share_y must be a Share."
+        assert isinstance(share_x, Share), \
+            "share_x must be a Share."
 
-        if not isinstance(share_x, Share):
-            # Then share_y must be a Share => local multiplication. We
-            # clone first to avoid changing share_y.
-            result = share_y.clone()
-            result.addCallback(lambda y: share_x * y)
-            return result
         if not isinstance(share_y, Share):
-            # Likewise when share_y is a constant.
+            # Local multiplication. share_x always is a Share by
+            # operator overloading in Share. We clone share_x first
+            # to avoid changing it.
             result = share_x.clone()
-            result.addCallback(lambda x: x * share_y)
+            result.addCallback(lambda x: share_y * x)
             return result
 
         # At this point both share_x and share_y must be Share