viff

changeset 1345:c2a553514804

Orlandi: Fixed bug.
author Janus Dam Nielsen <janus.nielsen@alexandra.dk>
date Tue, 27 Oct 2009 19:08:29 +0100
parents 568f9c696979
children e72cd064566d
files viff/orlandi.py viff/test/test_orlandi_runtime.py
diffstat 2 files changed, 47 insertions(+), 6 deletions(-) [+]
line diff
     1.1 --- a/viff/orlandi.py	Tue Oct 27 11:43:37 2009 +0100
     1.2 +++ b/viff/orlandi.py	Tue Oct 27 19:08:29 2009 +0100
     1.3 @@ -740,13 +740,13 @@
     1.4              x, y = t[0]
     1.5              f = []
     1.6              g = []
     1.7 -            if 1 in t:
     1.8 +            if len(t) == 3:
     1.9                  f = t[1]
    1.10 -            if 2 in t:
    1.11                  g = t[2]
    1.12  #             print "==> poly", self.id
    1.13  #             print "x:", x
    1.14  #             print "y:", y
    1.15 +#             print "t:", t, len(t)
    1.16  #             print "f:", f
    1.17  #             print "g:", g
    1.18              # 2) for j = 1, ..., 2d+1 do
    1.19 @@ -795,10 +795,9 @@
    1.20              return H0
    1.21  
    1.22          ls = [gather_shares([share_x, share_y])]
    1.23 -        if g:
    1.24 +        if g and f:
    1.25 +            ls.append(gather_shares(f))
    1.26              ls.append(gather_shares(g))
    1.27 -        if f:
    1.28 -            ls.append(gather_shares(f))
    1.29          result = gather_shares(ls)
    1.30          self.schedule_callback(result, compute_polynomials)
    1.31          result.addErrback(self.error_handler)
     2.1 --- a/viff/test/test_orlandi_runtime.py	Tue Oct 27 11:43:37 2009 +0100
     2.2 +++ b/viff/test/test_orlandi_runtime.py	Tue Oct 27 19:08:29 2009 +0100
     2.3 @@ -263,7 +263,7 @@
     2.4  
     2.5      runtime_class = OrlandiRuntime
     2.6  
     2.7 -    timeout = 60
     2.8 +    timeout = 700
     2.9  
    2.10      @protocol
    2.11      def test_shift(self, runtime):
    2.12 @@ -575,6 +575,44 @@
    2.13          self.assertEquals(z2, None)
    2.14          return z2
    2.15  
    2.16 +    @protocol
    2.17 +    def test_leak_mul1(self, runtime):
    2.18 +        """Test leaktolerant multiplication of two numbers."""
    2.19 +        commitment.set_reference_string(long(2), long(6))
    2.20 +
    2.21 +        self.Zp = GF(6277101735386680763835789423176059013767194773182842284081)
    2.22 +
    2.23 +        x1 = 42
    2.24 +        y1 = 7
    2.25 +
    2.26 +        runtime.s = 2
    2.27 +        runtime.d = 2
    2.28 +        runtime.s_lambda = 1
    2.29 +
    2.30 +        def check(v):
    2.31 +            runtime.s = 1
    2.32 +            runtime.d = 0
    2.33 +            runtime.s_lambda = 1
    2.34 +            self.assertEquals(v, x1 * y1)
    2.35 +
    2.36 +        x2 = runtime.shift([1], self.Zp, x1)
    2.37 +        y2 = runtime.shift([2], self.Zp, y1)
    2.38 +
    2.39 +        sls = gatherResults(runtime.random_triple(self.Zp, 2*runtime.d + 1))
    2.40 +
    2.41 +        def cont(M):
    2.42 +            M = [[Share(self, self.Zp, j) for j in i] for i in M]
    2.43 +            z2 = runtime.leak_tolerant_mul(x2, y2, M)
    2.44 +            d = runtime.open(z2)
    2.45 +            d.addCallback(check)
    2.46 +            return d
    2.47 +        sls.addCallbacks(cont, runtime.error_handler)
    2.48 +        return sls
    2.49 +
    2.50 +        z2 = runtime._cmul(y2, x2, self.Zp)
    2.51 +        self.assertEquals(z2, None)
    2.52 +        return z2
    2.53 +
    2.54  class TripleGenTest(RuntimeTestCase):
    2.55      """Test for generation of triples."""
    2.56  
    2.57 @@ -591,6 +629,10 @@
    2.58  
    2.59          self.Zp = GF(6277101735386680763835789423176059013767194773182842284081)
    2.60  
    2.61 +        runtime.s = 1
    2.62 +        runtime.d = 0
    2.63 +        runtime.s_lambda = 1
    2.64 +
    2.65          def check((a, b, c)):
    2.66              self.assertEquals(c, a * b)
    2.67