viff

changeset 1487:c6f29ad5c91e

BeDOZa: Removed unecessary code.
author Janus Dam Nielsen <janus.nielsen@alexandra.dk>
date Mon, 12 Jul 2010 11:33:09 +0200
parents 6b448315eedf
children cfcfb46f9450
files viff/test/test_bedoza_runtime.py
diffstat 1 files changed, 65 insertions(+), 65 deletions(-) [+]
line diff
     1.1 --- a/viff/test/test_bedoza_runtime.py	Mon Jul 12 11:31:50 2010 +0200
     1.2 +++ b/viff/test/test_bedoza_runtime.py	Mon Jul 12 11:33:09 2010 +0200
     1.3 @@ -38,9 +38,9 @@
     1.4      def test_load_keys(self, runtime):
     1.5          """Test loading of keys."""
     1.6  
     1.7 -        self.Zp = GF(6277101735386680763835789423176059013767194773182842284081)
     1.8 +        Zp = GF(6277101735386680763835789423176059013767194773182842284081)
     1.9  
    1.10 -        runtime.init_keys(self.Zp)
    1.11 +        runtime.init_keys(Zp)
    1.12          keys = runtime.get_keys()
    1.13          if runtime.id == 1:
    1.14              betas = keys[1]
    1.15 @@ -62,10 +62,10 @@
    1.16      def test_authentication_codes(self, runtime):
    1.17          """Test generating random shares."""
    1.18  
    1.19 -        self.Zp = GF(6277101735386680763835789423176059013767194773182842284081)
    1.20 +        Zp = GF(6277101735386680763835789423176059013767194773182842284081)
    1.21  
    1.22 -        v = self.Zp(2)
    1.23 -        runtime.init_keys(self.Zp)
    1.24 +        v = Zp(2)
    1.25 +        runtime.init_keys(Zp)
    1.26          alpha, betas = runtime.get_keys()
    1.27          codes = self.num_players * [None]
    1.28  
    1.29 @@ -75,19 +75,19 @@
    1.30          
    1.31          if runtime.id == 1:
    1.32              my_codes = codes[0]
    1.33 -            self.assertEquals(my_codes[0], self.Zp(5))
    1.34 -            self.assertEquals(my_codes[1], self.Zp(10))
    1.35 -            self.assertEquals(my_codes[2], self.Zp(15))
    1.36 +            self.assertEquals(my_codes[0], Zp(5))
    1.37 +            self.assertEquals(my_codes[1], Zp(10))
    1.38 +            self.assertEquals(my_codes[2], Zp(15))
    1.39          if runtime.id == 2:
    1.40              my_codes = codes[1]
    1.41 -            self.assertEquals(my_codes[0], self.Zp(6))
    1.42 -            self.assertEquals(my_codes[1], self.Zp(11))
    1.43 -            self.assertEquals(my_codes[2], self.Zp(16))
    1.44 +            self.assertEquals(my_codes[0], Zp(6))
    1.45 +            self.assertEquals(my_codes[1], Zp(11))
    1.46 +            self.assertEquals(my_codes[2], Zp(16))
    1.47          if runtime.id == 3:
    1.48              my_codes = codes[2]
    1.49 -            self.assertEquals(my_codes[0], self.Zp(7))
    1.50 -            self.assertEquals(my_codes[1], self.Zp(12))
    1.51 -            self.assertEquals(my_codes[2], self.Zp(17))
    1.52 +            self.assertEquals(my_codes[0], Zp(7))
    1.53 +            self.assertEquals(my_codes[1], Zp(12))
    1.54 +            self.assertEquals(my_codes[2], Zp(17))
    1.55  
    1.56      @protocol
    1.57      def test_messagelist(self, runtime):
    1.58 @@ -119,12 +119,12 @@
    1.59      def test_random_share(self, runtime):
    1.60          """Test creation of a random shared number."""
    1.61  
    1.62 -        self.Zp = GF(6277101735386680763835789423176059013767194773182842284081)
    1.63 +        Zp = GF(6277101735386680763835789423176059013767194773182842284081)
    1.64  
    1.65          def check(v):
    1.66              self.assertEquals(True, True)
    1.67  
    1.68 -        x = runtime.random_share(self.Zp)
    1.69 +        x = runtime.random_share(Zp)
    1.70          d = runtime.open(x)
    1.71          d.addCallback(check)
    1.72          return d
    1.73 @@ -147,13 +147,13 @@
    1.74      def test_sum(self, runtime):
    1.75          """Test addition of two numbers."""
    1.76  
    1.77 -        self.Zp = GF(6277101735386680763835789423176059013767194773182842284081)
    1.78 +        Zp = GF(6277101735386680763835789423176059013767194773182842284081)
    1.79  
    1.80          def check(v):
    1.81              self.assertEquals(v, 12)
    1.82  
    1.83 -        x2 = runtime.random_share(self.Zp)
    1.84 -        y2 = runtime.random_share(self.Zp)
    1.85 +        x2 = runtime.random_share(Zp)
    1.86 +        y2 = runtime.random_share(Zp)
    1.87          z2 = runtime.add(x2, y2)
    1.88          d = runtime.open(z2)
    1.89          d.addCallback(check)
    1.90 @@ -163,13 +163,13 @@
    1.91      def test_sum_plus(self, runtime):
    1.92          """Test addition of two numbers."""
    1.93  
    1.94 -        self.Zp = GF(6277101735386680763835789423176059013767194773182842284081)
    1.95 +        Zp = GF(6277101735386680763835789423176059013767194773182842284081)
    1.96  
    1.97          def check(v):
    1.98              self.assertEquals(v, 12)
    1.99  
   1.100 -        x2 = runtime.random_share(self.Zp)
   1.101 -        y2 = runtime.random_share(self.Zp)
   1.102 +        x2 = runtime.random_share(Zp)
   1.103 +        y2 = runtime.random_share(Zp)
   1.104          z2 = x2 + y2
   1.105          d = runtime.open(z2)
   1.106          d.addCallback(check)
   1.107 @@ -179,7 +179,7 @@
   1.108      def test_sum_constant_right(self, runtime):
   1.109          """Test addition of secret shared number and a public number."""
   1.110  
   1.111 -        self.Zp = GF(31)
   1.112 +        Zp = GF(31)
   1.113  
   1.114          x1 = 42
   1.115          y1 = 7
   1.116 @@ -187,7 +187,7 @@
   1.117          def check(v):
   1.118              self.assertEquals(v, 13)
   1.119  
   1.120 -        x2 = runtime.random_share(self.Zp)
   1.121 +        x2 = runtime.random_share(Zp)
   1.122          z2 = x2 + y1
   1.123          d = runtime.open(z2)
   1.124          d.addCallback(check)
   1.125 @@ -197,7 +197,7 @@
   1.126      def test_sum_constant_left(self, runtime):
   1.127          """Test addition of a public number and secret shared number."""
   1.128  
   1.129 -        self.Zp = GF(6277101735386680763835789423176059013767194773182842284081)
   1.130 +        Zp = GF(6277101735386680763835789423176059013767194773182842284081)
   1.131  
   1.132          x1 = 42
   1.133          y1 = 7
   1.134 @@ -205,7 +205,7 @@
   1.135          def check(v):
   1.136              self.assertEquals(v, 13)
   1.137  
   1.138 -        x2 = runtime.random_share(self.Zp)
   1.139 +        x2 = runtime.random_share(Zp)
   1.140          z2 = y1 + x2
   1.141          d = runtime.open(z2)
   1.142          d.addCallback(check)
   1.143 @@ -229,13 +229,13 @@
   1.144      def test_sub(self, runtime):
   1.145          """Test subtraction of two numbers."""
   1.146  
   1.147 -        self.Zp = GF(6277101735386680763835789423176059013767194773182842284081)
   1.148 +        Zp = GF(6277101735386680763835789423176059013767194773182842284081)
   1.149  
   1.150          def check(v):
   1.151              self.assertEquals(v, 0)
   1.152  
   1.153 -        x2 = runtime.random_share(self.Zp)
   1.154 -        y2 = runtime.random_share(self.Zp)
   1.155 +        x2 = runtime.random_share(Zp)
   1.156 +        y2 = runtime.random_share(Zp)
   1.157          z2 = runtime.sub(x2, y2)
   1.158          d = runtime.open(z2)
   1.159          d.addCallback(check)
   1.160 @@ -245,13 +245,13 @@
   1.161      def test_sub_minus(self, runtime):
   1.162          """Test subtraction of two numbers."""
   1.163  
   1.164 -        self.Zp = GF(6277101735386680763835789423176059013767194773182842284081)
   1.165 +        Zp = GF(6277101735386680763835789423176059013767194773182842284081)
   1.166  
   1.167          def check(v):
   1.168              self.assertEquals(v, 0)
   1.169  
   1.170 -        x2 = runtime.random_share(self.Zp)
   1.171 -        y2 = runtime.random_share(self.Zp)
   1.172 +        x2 = runtime.random_share(Zp)
   1.173 +        y2 = runtime.random_share(Zp)
   1.174          z2 = x2 - y2
   1.175          d = runtime.open(z2)
   1.176          d.addCallback(check)
   1.177 @@ -261,14 +261,14 @@
   1.178      def test_sub_constant_right(self, runtime):
   1.179          """Test subtraction of secret shared number and a public number."""
   1.180  
   1.181 -        self.Zp = GF(31)
   1.182 +        Zp = GF(31)
   1.183  
   1.184          y = 4
   1.185  
   1.186          def check(v):
   1.187              self.assertEquals(v, 2)
   1.188  
   1.189 -        x2 = runtime.random_share(self.Zp)
   1.190 +        x2 = runtime.random_share(Zp)
   1.191          z2 = x2 - y
   1.192          d = runtime.open(x2)
   1.193          d.addCallback(check)
   1.194 @@ -278,14 +278,14 @@
   1.195      def test_sub_constant_left(self, runtime):
   1.196          """Test subtraction of a public number and secret shared number."""
   1.197  
   1.198 -        self.Zp = GF(31)
   1.199 +        Zp = GF(31)
   1.200  
   1.201          y = 8
   1.202  
   1.203          def check(v):
   1.204              self.assertEquals(v, 2)
   1.205  
   1.206 -        x2 = runtime.random_share(self.Zp)
   1.207 +        x2 = runtime.random_share(Zp)
   1.208          z2 = y - x2
   1.209          d = runtime.open(x2)
   1.210          d.addCallback(check)
   1.211 @@ -295,7 +295,7 @@
   1.212      def test_constant_multiplication_constant_left(self, runtime):
   1.213          """Test multiplication of two numbers."""
   1.214  
   1.215 -        self.Zp = GF(6277101735386680763835789423176059013767194773182842284081)
   1.216 +        Zp = GF(6277101735386680763835789423176059013767194773182842284081)
   1.217  
   1.218          x1 = 6
   1.219          y1 = 7
   1.220 @@ -303,9 +303,9 @@
   1.221          def check(v):
   1.222              self.assertEquals(v, x1 * y1)
   1.223  
   1.224 -        x2 = runtime.random_share(self.Zp)
   1.225 +        x2 = runtime.random_share(Zp)
   1.226  
   1.227 -        z2 = runtime._cmul(self.Zp(y1), x2, self.Zp)
   1.228 +        z2 = runtime._cmul(Zp(y1), x2, Zp)
   1.229          d = runtime.open(z2)
   1.230          d.addCallback(check)
   1.231          return d
   1.232 @@ -314,7 +314,7 @@
   1.233      def test_constant_multiplication_constant_right(self, runtime):
   1.234          """Test multiplication of two numbers."""
   1.235  
   1.236 -        self.Zp = GF(6277101735386680763835789423176059013767194773182842284081)
   1.237 +        Zp = GF(6277101735386680763835789423176059013767194773182842284081)
   1.238  
   1.239          x1 = 6
   1.240          y1 = 7
   1.241 @@ -322,9 +322,9 @@
   1.242          def check(v):
   1.243              self.assertEquals(v, x1 * y1)
   1.244  
   1.245 -        x2 = runtime.random_share(self.Zp)
   1.246 +        x2 = runtime.random_share(Zp)
   1.247  
   1.248 -        z2 = runtime._cmul(x2, self.Zp(y1), self.Zp)
   1.249 +        z2 = runtime._cmul(x2, Zp(y1), Zp)
   1.250          d = runtime.open(z2)
   1.251          d.addCallback(check)
   1.252          return d
   1.253 @@ -333,12 +333,12 @@
   1.254      def test_get_triple(self, runtime):
   1.255          """Test generation of a triple."""
   1.256  
   1.257 -        self.Zp = GF(6277101735386680763835789423176059013767194773182842284081)
   1.258 +        Zp = GF(6277101735386680763835789423176059013767194773182842284081)
   1.259        
   1.260          def check((a, b, c)):
   1.261              self.assertEquals(c, a * b)
   1.262  
   1.263 -        (a, b, c), _ = runtime._get_triple(self.Zp)
   1.264 +        (a, b, c), _ = runtime._get_triple(Zp)
   1.265          d1 = runtime.open(a)
   1.266          d2 = runtime.open(b)
   1.267          d3 = runtime.open(c)
   1.268 @@ -350,7 +350,7 @@
   1.269      def test_basic_multiply(self, runtime):
   1.270          """Test multiplication of two numbers."""
   1.271  
   1.272 -        self.Zp = GF(6277101735386680763835789423176059013767194773182842284081)
   1.273 +        Zp = GF(6277101735386680763835789423176059013767194773182842284081)
   1.274  
   1.275          x1 = 6
   1.276          y1 = 6
   1.277 @@ -358,10 +358,10 @@
   1.278          def check(v):
   1.279              self.assertEquals(v, x1 * y1)
   1.280  
   1.281 -        x2 = runtime.random_share(self.Zp)
   1.282 -        y2 = runtime.random_share(self.Zp)
   1.283 +        x2 = runtime.random_share(Zp)
   1.284 +        y2 = runtime.random_share(Zp)
   1.285  
   1.286 -        (a, b, c), _ = runtime._get_triple(self.Zp)
   1.287 +        (a, b, c), _ = runtime._get_triple(Zp)
   1.288          z2 = runtime._basic_multiplication(x2, y2, a, b, c)
   1.289          d = runtime.open(z2)
   1.290          d.addCallback(check)
   1.291 @@ -371,7 +371,7 @@
   1.292      def test_mul_mul(self, runtime):
   1.293          """Test multiplication of two numbers."""
   1.294  
   1.295 -        self.Zp = GF(6277101735386680763835789423176059013767194773182842284081)
   1.296 +        Zp = GF(6277101735386680763835789423176059013767194773182842284081)
   1.297  
   1.298          x1 = 6
   1.299          y1 = 6
   1.300 @@ -379,8 +379,8 @@
   1.301          def check(v):
   1.302              self.assertEquals(v, x1 * y1)
   1.303  
   1.304 -        x2 = runtime.random_share(self.Zp)
   1.305 -        y2 = runtime.random_share(self.Zp)
   1.306 +        x2 = runtime.random_share(Zp)
   1.307 +        y2 = runtime.random_share(Zp)
   1.308  
   1.309          z2 = x2 * y2
   1.310          d = runtime.open(z2)
   1.311 @@ -390,7 +390,7 @@
   1.312      def test_basic_multiply_constant_right(self, runtime):
   1.313          """Test multiplication of two numbers."""
   1.314  
   1.315 -        self.Zp = GF(6277101735386680763835789423176059013767194773182842284081)
   1.316 +        Zp = GF(6277101735386680763835789423176059013767194773182842284081)
   1.317  
   1.318          x1 = 6
   1.319          y1 = 6
   1.320 @@ -398,10 +398,10 @@
   1.321          def check(v):
   1.322              self.assertEquals(v, x1 * y1)
   1.323  
   1.324 -        x2 = runtime.random_share(self.Zp)
   1.325 +        x2 = runtime.random_share(Zp)
   1.326  
   1.327 -        (a, b, c), _ = runtime._get_triple(self.Zp)
   1.328 -        z2 = runtime._basic_multiplication(x2, self.Zp(y1), a, b, c)
   1.329 +        (a, b, c), _ = runtime._get_triple(Zp)
   1.330 +        z2 = runtime._basic_multiplication(x2, Zp(y1), a, b, c)
   1.331          d = runtime.open(z2)
   1.332          d.addCallback(check)
   1.333          return d
   1.334 @@ -410,7 +410,7 @@
   1.335      def test_basic_multiply_constant_left(self, runtime):
   1.336          """Test multiplication of two numbers."""
   1.337  
   1.338 -        self.Zp = GF(6277101735386680763835789423176059013767194773182842284081)
   1.339 +        Zp = GF(6277101735386680763835789423176059013767194773182842284081)
   1.340  
   1.341          x1 = 6
   1.342          y1 = 6
   1.343 @@ -418,10 +418,10 @@
   1.344          def check(v):
   1.345              self.assertEquals(v, x1 * y1)
   1.346  
   1.347 -        x2 = runtime.random_share(self.Zp)
   1.348 +        x2 = runtime.random_share(Zp)
   1.349  
   1.350 -        (a, b, c), _ = runtime._get_triple(self.Zp)
   1.351 -        z2 = runtime._basic_multiplication(self.Zp(y1), x2, a, b, c)
   1.352 +        (a, b, c), _ = runtime._get_triple(Zp)
   1.353 +        z2 = runtime._basic_multiplication(Zp(y1), x2, a, b, c)
   1.354          d = runtime.open(z2)
   1.355          d.addCallback(check)
   1.356          return d
   1.357 @@ -430,14 +430,14 @@
   1.358      def test_open_multiple_secret_share(self, runtime):
   1.359          """Test sharing and open of a number."""
   1.360  
   1.361 -        self.Zp = GF(6277101735386680763835789423176059013767194773182842284081)
   1.362 +        Zp = GF(6277101735386680763835789423176059013767194773182842284081)
   1.363  
   1.364          def check(ls):
   1.365              for v in ls:
   1.366                  self.assertEquals(v, 6)
   1.367  
   1.368 -        x = runtime.random_share(self.Zp)
   1.369 -        y = runtime.random_share(self.Zp)
   1.370 +        x = runtime.random_share(Zp)
   1.371 +        y = runtime.random_share(Zp)
   1.372          d = runtime.open_multiple_values([x, y])
   1.373          d.addCallback(check)
   1.374          return d
   1.375 @@ -446,14 +446,14 @@
   1.376      def test_open_two_secret_share(self, runtime):
   1.377          """Test sharing and open of a number."""
   1.378  
   1.379 -        self.Zp = GF(6277101735386680763835789423176059013767194773182842284081)
   1.380 +        Zp = GF(6277101735386680763835789423176059013767194773182842284081)
   1.381  
   1.382          def check((a, b)):
   1.383              self.assertEquals(a, 6)
   1.384              self.assertEquals(b, 6)
   1.385  
   1.386 -        x = runtime.random_share(self.Zp)
   1.387 -        y = runtime.random_share(self.Zp)
   1.388 +        x = runtime.random_share(Zp)
   1.389 +        y = runtime.random_share(Zp)
   1.390          d = runtime.open_two_values(x, y)
   1.391          d.addCallback(check)
   1.392          return d