/rev/5a2e6564c40a
changeset: 1322:5a2e6564c40a
user:      Marcel Keller <[email protected]>
date:      Tue Oct 06 17:52:14 2009 +0200
summary:   Optimize by using reflected argument version of overloaded operators.

diffstat:

 viff/aes.py     |  6 +-----
 viff/passive.py |  6 +++---
 2 files changed, 4 insertions(+), 8 deletions(-)

diffs (53 lines):

diff -r 71f205befbbb -r 5a2e6564c40a viff/aes.py
--- a/viff/aes.py       Tue Oct 06 14:18:55 2009 +0200
+++ b/viff/aes.py       Tue Oct 06 17:52:14 2009 +0200
@@ -129,7 +129,7 @@
         bits = bit_decompose(byte)
 
         for j in range(len(bits)):
-            bits[j].addCallback(lambda x: GF256(1) - x)
+            bits[j].addCallback(lambda x: 1 - x)
 #            bits[j] = 1 - bits[j]
 
         while(len(bits) > 1):
@@ -278,10 +278,6 @@
          [1, 1, 2, 3],
          [3, 1, 1, 2]]
 
-    for row in C:
-        for i in xrange(len(row)):
-            row[i] = GF256(row[i])
-
     C = Matrix(C)
 
     def mix_column(self, state, use_lin_comb=True):
diff -r 71f205befbbb -r 5a2e6564c40a viff/passive.py
--- a/viff/passive.py   Tue Oct 06 14:18:55 2009 +0200
+++ b/viff/passive.py   Tue Oct 06 17:52:14 2009 +0200
@@ -127,7 +127,7 @@
             # operator overloading in Share. Clone share_a to avoid
             # changing it.
             result = share_a.clone()
-            result.addCallback(lambda a, b: a + b, share_b)
+            result.addCallback(lambda a, b: b + a, share_b)
             return result
         
         result = gather_shares([share_a, share_b])
@@ -168,7 +168,7 @@
             "Number of coefficients and shares should be equal."
 
         def computation(shares, coefficients):
-            return sum(map(operator.mul, shares, coefficients))
+            return sum(map(operator.mul, coefficients, shares))
 
         result = gather_shares(shares)
         result.addCallback(computation, coefficients)
@@ -189,7 +189,7 @@
             # operator overloading in Share. We clone share_a first
             # to avoid changing it.
             result = share_a.clone()
-            result.addCallback(lambda a: a * share_b)
+            result.addCallback(lambda a: share_b * a)
             return result
 
         # At this point both share_a and share_b must be Share
_______________________________________________
viff-commits mailing list
[email protected]
http://lists.viff.dk/listinfo.cgi/viff-commits-viff.dk

Reply via email to