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 wrap: on
line diff
--- a/viff/passive.py	Thu Jun 25 08:58:54 2009 +0200
+++ b/viff/passive.py	Mon Jul 13 14:17:52 2009 +0200
@@ -19,6 +19,8 @@
 
 """Passively secure VIFF runtime."""
 
+import operator
+
 from viff import shamir
 from viff.runtime import Runtime, increment_pc, Share, ShareList, gather_shares
 from viff.prss import prss, prss_lsb, prss_zero, prss_multi
@@ -163,8 +165,7 @@
             "Number of coefficients and shares should be equal."
 
         def computation(shares, coefficients):
-            summands = [shares[i] * coefficients[i] for i in range(len(shares))]
-            return reduce(lambda x, y: x + y, summands)
+            return sum(map(operator.mul, shares, coefficients))
 
         result = gather_shares(shares)
         result.addCallback(computation, coefficients)