/rev/c2a553514804
changeset: 1345:c2a553514804
user: Janus Dam Nielsen <[email protected]>
date: Tue Oct 27 19:08:29 2009 +0100
summary: Orlandi: Fixed bug.
diffstat:
viff/orlandi.py | 9 ++++-----
viff/test/test_orlandi_runtime.py | 44
+++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 47 insertions(+), 6 deletions(-)
diffs (100 lines):
diff -r 568f9c696979 -r c2a553514804 viff/orlandi.py
--- a/viff/orlandi.py Tue Oct 27 11:43:37 2009 +0100
+++ b/viff/orlandi.py Tue Oct 27 19:08:29 2009 +0100
@@ -740,13 +740,13 @@
x, y = t[0]
f = []
g = []
- if 1 in t:
+ if len(t) == 3:
f = t[1]
- if 2 in t:
g = t[2]
# print "==> poly", self.id
# print "x:", x
# print "y:", y
+# print "t:", t, len(t)
# print "f:", f
# print "g:", g
# 2) for j = 1, ..., 2d+1 do
@@ -795,10 +795,9 @@
return H0
ls = [gather_shares([share_x, share_y])]
- if g:
+ if g and f:
+ ls.append(gather_shares(f))
ls.append(gather_shares(g))
- if f:
- ls.append(gather_shares(f))
result = gather_shares(ls)
self.schedule_callback(result, compute_polynomials)
result.addErrback(self.error_handler)
diff -r 568f9c696979 -r c2a553514804 viff/test/test_orlandi_runtime.py
--- a/viff/test/test_orlandi_runtime.py Tue Oct 27 11:43:37 2009 +0100
+++ b/viff/test/test_orlandi_runtime.py Tue Oct 27 19:08:29 2009 +0100
@@ -263,7 +263,7 @@
runtime_class = OrlandiRuntime
- timeout = 60
+ timeout = 700
@protocol
def test_shift(self, runtime):
@@ -575,6 +575,44 @@
self.assertEquals(z2, None)
return z2
+ @protocol
+ def test_leak_mul1(self, runtime):
+ """Test leaktolerant multiplication of two numbers."""
+ commitment.set_reference_string(long(2), long(6))
+
+ self.Zp =
GF(6277101735386680763835789423176059013767194773182842284081)
+
+ x1 = 42
+ y1 = 7
+
+ runtime.s = 2
+ runtime.d = 2
+ runtime.s_lambda = 1
+
+ def check(v):
+ runtime.s = 1
+ runtime.d = 0
+ runtime.s_lambda = 1
+ self.assertEquals(v, x1 * y1)
+
+ x2 = runtime.shift([1], self.Zp, x1)
+ y2 = runtime.shift([2], self.Zp, y1)
+
+ sls = gatherResults(runtime.random_triple(self.Zp, 2*runtime.d + 1))
+
+ def cont(M):
+ M = [[Share(self, self.Zp, j) for j in i] for i in M]
+ z2 = runtime.leak_tolerant_mul(x2, y2, M)
+ d = runtime.open(z2)
+ d.addCallback(check)
+ return d
+ sls.addCallbacks(cont, runtime.error_handler)
+ return sls
+
+ z2 = runtime._cmul(y2, x2, self.Zp)
+ self.assertEquals(z2, None)
+ return z2
+
class TripleGenTest(RuntimeTestCase):
"""Test for generation of triples."""
@@ -591,6 +629,10 @@
self.Zp =
GF(6277101735386680763835789423176059013767194773182842284081)
+ runtime.s = 1
+ runtime.d = 0
+ runtime.s_lambda = 1
+
def check((a, b, c)):
self.assertEquals(c, a * b)
_______________________________________________
viff-commits mailing list
[email protected]
http://lists.viff.dk/listinfo.cgi/viff-commits-viff.dk