changeset 1363:73a40d45008f

aes: Simplified callbacks in masked exponentiation.
author Marcel Keller <mkeller@cs.au.dk>
date Wed, 28 Oct 2009 20:23:26 +0100
parents 361aeb2668fc
children f441d4776bcc
files viff/aes.py
diffstat 1 files changed, 3 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/viff/aes.py	Wed Oct 28 15:17:24 2009 +0100
+++ b/viff/aes.py	Wed Oct 28 20:23:26 2009 +0100
@@ -155,7 +155,8 @@
         return result
 
     def invert_by_masked_exponentiation(self, byte):
-        def add_and_multiply(masked_powers, random_powers, prep):
+        def add_and_multiply(masked_byte, random_powers, prep):
+            masked_powers = self.runtime.powerchain(masked_byte, 7)
             byte_powers = map(operator.add, masked_powers, random_powers)[1:]
             if prep:
                 byte_powers = [Share(self.runtime, GF256, value)
@@ -166,10 +167,8 @@
 
         random_powers, prep = self.runtime.prss_powerchain()
         masked_byte = self.runtime.open(byte + random_powers[0])
-        masked_powers = self.runtime.schedule_callback(masked_byte,
-            lambda masked_byte: self.runtime.powerchain(masked_byte, 7))
         return self.runtime.schedule_callback(
-            masked_powers, add_and_multiply, random_powers, prep)
+            masked_byte, add_and_multiply, random_powers, prep)
 
     def invert_by_exponentiation(self, byte):
         byte_2 = byte * byte