viff

changeset 1473:bf36d63d33cb

SimpleArithmetic: Added support for preprocessing.
author Janus Dam Nielsen <janus.nielsen@alexandra.dk>
date Wed, 07 Jul 2010 16:06:41 +0200
parents 55d2c1692771
children 0ed03fae3f6a
files viff/bedoza.py viff/simplearithmetic.py viff/test/test_bedoza_runtime.py
diffstat 3 files changed, 12 insertions(+), 9 deletions(-) [+]
line diff
     1.1 --- a/viff/bedoza.py	Wed Jul 07 16:06:38 2010 +0200
     1.2 +++ b/viff/bedoza.py	Wed Jul 07 16:06:41 2010 +0200
     1.3 @@ -377,4 +377,4 @@
     1.4                  b += share_b.value
     1.5                  triple_c = self.generate_share(field, share_c)
     1.6                  c += share_c.value
     1.7 -        return [triple_a, triple_b, triple_c]
     1.8 +        return [triple_a, triple_b, triple_c], False
     2.1 --- a/viff/simplearithmetic.py	Wed Jul 07 16:06:38 2010 +0200
     2.2 +++ b/viff/simplearithmetic.py	Wed Jul 07 16:06:41 2010 +0200
     2.3 @@ -91,7 +91,10 @@
     2.4  
     2.5          field = getattr(share_x, "field", getattr(share_y, "field", None))
     2.6  
     2.7 -        triple = self._get_triple(field)
     2.8 +        triple, prep = self._get_triple(field)
     2.9 +        if prep:
    2.10 +            # The data from the pool must be wrapped in Shares.
    2.11 +            triple = [Share(self, field, i) for i in triple]
    2.12          return self._basic_multiplication(share_x, share_y, *triple)
    2.13  
    2.14      def _basic_multiplication(self, share_x, share_y, triple_a, triple_b, triple_c):
     3.1 --- a/viff/test/test_bedoza_runtime.py	Wed Jul 07 16:06:38 2010 +0200
     3.2 +++ b/viff/test/test_bedoza_runtime.py	Wed Jul 07 16:06:41 2010 +0200
     3.3 @@ -343,10 +343,10 @@
     3.4          def check((a, b, c)):
     3.5              self.assertEquals(c, a * b)
     3.6  
     3.7 -        triples = runtime._get_triple(self.Zp)
     3.8 -        d1 = runtime.open(triples[0])
     3.9 -        d2 = runtime.open(triples[1])
    3.10 -        d3 = runtime.open(triples[2])
    3.11 +        (a, b, c), _ = runtime._get_triple(self.Zp)
    3.12 +        d1 = runtime.open(a)
    3.13 +        d2 = runtime.open(b)
    3.14 +        d3 = runtime.open(c)
    3.15          d = gather_shares([d1, d2, d3])
    3.16          d.addCallback(check)
    3.17          return d
    3.18 @@ -366,7 +366,7 @@
    3.19          x2 = runtime.random_share(self.Zp)
    3.20          y2 = runtime.random_share(self.Zp)
    3.21  
    3.22 -        a, b, c = runtime._get_triple(self.Zp)
    3.23 +        (a, b, c), _ = runtime._get_triple(self.Zp)
    3.24          z2 = runtime._basic_multiplication(x2, y2, a, b, c)
    3.25          d = runtime.open(z2)
    3.26          d.addCallback(check)
    3.27 @@ -405,7 +405,7 @@
    3.28  
    3.29          x2 = runtime.random_share(self.Zp)
    3.30  
    3.31 -        a, b, c = runtime._get_triple(self.Zp)
    3.32 +        (a, b, c), _ = runtime._get_triple(self.Zp)
    3.33          z2 = runtime._basic_multiplication(x2, self.Zp(y1), a, b, c)
    3.34          d = runtime.open(z2)
    3.35          d.addCallback(check)
    3.36 @@ -425,7 +425,7 @@
    3.37  
    3.38          x2 = runtime.random_share(self.Zp)
    3.39  
    3.40 -        a, b, c = runtime._get_triple(self.Zp)
    3.41 +        (a, b, c), _ = runtime._get_triple(self.Zp)
    3.42          z2 = runtime._basic_multiplication(self.Zp(y1), x2, a, b, c)
    3.43          d = runtime.open(z2)
    3.44          d.addCallback(check)