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 wrap: on
line diff
--- a/viff/bedoza.py	Wed Jul 07 16:06:38 2010 +0200
+++ b/viff/bedoza.py	Wed Jul 07 16:06:41 2010 +0200
@@ -377,4 +377,4 @@
                 b += share_b.value
                 triple_c = self.generate_share(field, share_c)
                 c += share_c.value
-        return [triple_a, triple_b, triple_c]
+        return [triple_a, triple_b, triple_c], False
--- a/viff/simplearithmetic.py	Wed Jul 07 16:06:38 2010 +0200
+++ b/viff/simplearithmetic.py	Wed Jul 07 16:06:41 2010 +0200
@@ -91,7 +91,10 @@
 
         field = getattr(share_x, "field", getattr(share_y, "field", None))
 
-        triple = self._get_triple(field)
+        triple, prep = self._get_triple(field)
+        if prep:
+            # The data from the pool must be wrapped in Shares.
+            triple = [Share(self, field, i) for i in triple]
         return self._basic_multiplication(share_x, share_y, *triple)
 
     def _basic_multiplication(self, share_x, share_y, triple_a, triple_b, triple_c):
--- a/viff/test/test_bedoza_runtime.py	Wed Jul 07 16:06:38 2010 +0200
+++ b/viff/test/test_bedoza_runtime.py	Wed Jul 07 16:06:41 2010 +0200
@@ -343,10 +343,10 @@
         def check((a, b, c)):
             self.assertEquals(c, a * b)
 
-        triples = runtime._get_triple(self.Zp)
-        d1 = runtime.open(triples[0])
-        d2 = runtime.open(triples[1])
-        d3 = runtime.open(triples[2])
+        (a, b, c), _ = runtime._get_triple(self.Zp)
+        d1 = runtime.open(a)
+        d2 = runtime.open(b)
+        d3 = runtime.open(c)
         d = gather_shares([d1, d2, d3])
         d.addCallback(check)
         return d
@@ -366,7 +366,7 @@
         x2 = runtime.random_share(self.Zp)
         y2 = runtime.random_share(self.Zp)
 
-        a, b, c = runtime._get_triple(self.Zp)
+        (a, b, c), _ = runtime._get_triple(self.Zp)
         z2 = runtime._basic_multiplication(x2, y2, a, b, c)
         d = runtime.open(z2)
         d.addCallback(check)
@@ -405,7 +405,7 @@
 
         x2 = runtime.random_share(self.Zp)
 
-        a, b, c = runtime._get_triple(self.Zp)
+        (a, b, c), _ = runtime._get_triple(self.Zp)
         z2 = runtime._basic_multiplication(x2, self.Zp(y1), a, b, c)
         d = runtime.open(z2)
         d.addCallback(check)
@@ -425,7 +425,7 @@
 
         x2 = runtime.random_share(self.Zp)
 
-        a, b, c = runtime._get_triple(self.Zp)
+        (a, b, c), _ = runtime._get_triple(self.Zp)
         z2 = runtime._basic_multiplication(self.Zp(y1), x2, a, b, c)
         d = runtime.open(z2)
         d.addCallback(check)