viff

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 diff
     1.1 --- a/viff/active.py	Tue Oct 27 20:45:20 2009 +0100
     1.2 +++ b/viff/active.py	Tue Oct 27 20:46:38 2009 +0100
     1.3 @@ -474,19 +474,15 @@
     1.4          Preprocessing: 1 multiplication triple.
     1.5          Communication: 2 openings.
     1.6          """
     1.7 -        assert isinstance(share_x, Share) or isinstance(share_y, Share), \
     1.8 -            "At least one of share_x and share_y must be a Share."
     1.9 +        assert isinstance(share_x, Share), \
    1.10 +            "share_x must be a Share."
    1.11  
    1.12 -        if not isinstance(share_x, Share):
    1.13 -            # Then share_y must be a Share => local multiplication. We
    1.14 -            # clone first to avoid changing share_y.
    1.15 -            result = share_y.clone()
    1.16 -            result.addCallback(lambda y: share_x * y)
    1.17 -            return result
    1.18          if not isinstance(share_y, Share):
    1.19 -            # Likewise when share_y is a constant.
    1.20 +            # Local multiplication. share_x always is a Share by
    1.21 +            # operator overloading in Share. We clone share_x first
    1.22 +            # to avoid changing it.
    1.23              result = share_x.clone()
    1.24 -            result.addCallback(lambda x: x * share_y)
    1.25 +            result.addCallback(lambda x: share_y * x)
    1.26              return result
    1.27  
    1.28          # At this point both share_x and share_y must be Share