viff

changeset 1328:444954db1fc9

aes: Masked exponentiation without preprocessing works again.
author Marcel Keller <mkeller@cs.au.dk>
date Fri, 23 Oct 2009 14:59:34 +0200
parents 75fbb52aea09
children c4803511dbf8
files viff/aes.py
diffstat 1 files changed, 7 insertions(+), 5 deletions(-) [+]
line diff
     1.1 --- a/viff/aes.py	Fri Oct 23 14:56:38 2009 +0200
     1.2 +++ b/viff/aes.py	Fri Oct 23 14:59:34 2009 +0200
     1.3 @@ -155,19 +155,21 @@
     1.4          return result
     1.5  
     1.6      def invert_by_masked_exponentiation(self, byte):
     1.7 -        def add_and_multiply(masked_powers, random_powers):
     1.8 -            byte_powers = [Share(self.runtime, GF256, value) for value in
     1.9 -                           map(operator.add, masked_powers, random_powers)[1:]]
    1.10 +        def add_and_multiply(masked_powers, random_powers, prep):
    1.11 +            byte_powers = map(operator.add, masked_powers, random_powers)[1:]
    1.12 +            if prep:
    1.13 +                byte_powers = [Share(self.runtime, GF256, value)
    1.14 +                               for value in byte_powers]
    1.15              while len(byte_powers) > 1:
    1.16                  byte_powers.append(byte_powers.pop(0) * byte_powers.pop(0))
    1.17              return byte_powers[0]
    1.18  
    1.19 -        random_powers = self.runtime.prss_powerchain()
    1.20 +        random_powers, prep = self.runtime.prss_powerchain()
    1.21          masked_byte = self.runtime.open(byte + random_powers[0])
    1.22          masked_powers = self.runtime.schedule_callback(masked_byte,
    1.23              lambda masked_byte: self.runtime.powerchain(masked_byte, 7))
    1.24          return self.runtime.schedule_callback(
    1.25 -            masked_powers, add_and_multiply, random_powers)
    1.26 +            masked_powers, add_and_multiply, random_powers, prep)
    1.27  
    1.28      def invert_by_exponentiation(self, byte):
    1.29          byte_2 = byte * byte