viff

changeset 1195:aa2b3941a380

Faster computation of dot product.
author Martin Geisler <mg@cs.au.dk>
date Mon, 13 Jul 2009 14:17:52 +0200
parents 51167e387cc3
children 84c8f3d5fa86
files viff/passive.py
diffstat 1 files changed, 3 insertions(+), 2 deletions(-) [+]
line diff
     1.1 --- a/viff/passive.py	Thu Jun 25 08:58:54 2009 +0200
     1.2 +++ b/viff/passive.py	Mon Jul 13 14:17:52 2009 +0200
     1.3 @@ -19,6 +19,8 @@
     1.4  
     1.5  """Passively secure VIFF runtime."""
     1.6  
     1.7 +import operator
     1.8 +
     1.9  from viff import shamir
    1.10  from viff.runtime import Runtime, increment_pc, Share, ShareList, gather_shares
    1.11  from viff.prss import prss, prss_lsb, prss_zero, prss_multi
    1.12 @@ -163,8 +165,7 @@
    1.13              "Number of coefficients and shares should be equal."
    1.14  
    1.15          def computation(shares, coefficients):
    1.16 -            summands = [shares[i] * coefficients[i] for i in range(len(shares))]
    1.17 -            return reduce(lambda x, y: x + y, summands)
    1.18 +            return sum(map(operator.mul, shares, coefficients))
    1.19  
    1.20          result = gather_shares(shares)
    1.21          result.addCallback(computation, coefficients)