changeset 1085:29d85ec50160

Use lin_comb() in AES bit decomposition.
author Marcel Keller <mkeller@cs.au.dk>
date Tue, 20 Jan 2009 11:30:27 +0100
parents b4d9b373bbab
children e954b0a9c939
files viff/aes.py
diffstat 1 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/viff/aes.py	Tue Jan 20 10:45:50 2009 +0100
+++ b/viff/aes.py	Tue Jan 20 11:30:27 2009 +0100
@@ -25,7 +25,7 @@
 from viff.matrix import Matrix
 
 
-def bit_decompose(share):
+def bit_decompose(share, use_lin_comb=True):
     """Bit decomposition for GF256 shares."""
 
     assert isinstance(share, Share) and share.field == GF256, \
@@ -33,8 +33,13 @@
 
     r_bits = [share.runtime.prss_share_random(GF256, binary=True) \
                   for i in range(8)]
-    r = reduce(lambda x,y: x + y, [r_bits[i] * 2 ** i for i in range(8)])
     
+    if (use_lin_comb):
+        r = share.runtime.lin_comb([2 ** i for i in range(8)], r_bits)
+    else:
+        r = reduce(lambda x,y: x + y, 
+                   [r_bits[i] * 2 ** i for i in range(8)])
+
     c = share.runtime.open(share + r)
     c_bits = [Share(share.runtime, GF256) for i in range(8)]