changeset 1489:f3c3dba59fd8

BeDOZa: The dummy share generation code can now handle up to 8 players.
author Janus Dam Nielsen <janus.nielsen@alexandra.dk>
date Mon, 12 Jul 2010 12:00:32 +0200
parents cfcfb46f9450
children e837d8eec15d
files viff/bedoza.py viff/test/test_bedoza_runtime.py
diffstat 2 files changed, 13 insertions(+), 58 deletions(-) [+]
line wrap: on
line diff
--- a/viff/bedoza.py	Mon Jul 12 11:34:44 2010 +0200
+++ b/viff/bedoza.py	Mon Jul 12 12:00:32 2010 +0200
@@ -19,6 +19,7 @@
 
 from twisted.internet.defer import Deferred, gatherResults, succeed
 
+from viff.util import rand
 from viff.runtime import Runtime, Share, ShareList, gather_shares
 from viff.field import FieldElement
 from viff.constants import TEXT
@@ -152,9 +153,18 @@
         return BeDOZaKeyList(alpha, betas)
 
     def init_keys(self, field):
-        self.keys = {1: (field(2), [field(1), field(2), field(3)]),
-                     2: (field(3), [field(4), field(5), field(6)]),
-                     3: (field(4), [field(7), field(8), field(9)])}
+
+        self.keys = {}
+        for player_id in self.players:
+            betas = [field(56387295767672113),
+                     field(89238458945400961),
+                     field(12340004554789025),
+                     field(12907853897457058),
+                     field(90457903592570134),
+                     field(56256262346343232),
+                     field(23897437894556562),
+                     field(90297849575975574)]
+            self.keys[player_id] = (field(player_id), betas)
 
     def get_keys(self):   
         return self.keys[self.id]
--- a/viff/test/test_bedoza_runtime.py	Mon Jul 12 11:34:44 2010 +0200
+++ b/viff/test/test_bedoza_runtime.py	Mon Jul 12 12:00:32 2010 +0200
@@ -35,61 +35,6 @@
     runtime_class = BeDOZaRuntime
 
     @protocol
-    def test_load_keys(self, runtime):
-        """Test loading of keys."""
-
-        Zp = GF(6277101735386680763835789423176059013767194773182842284081)
-
-        runtime.init_keys(Zp)
-        keys = runtime.get_keys()
-        if runtime.id == 1:
-            betas = keys[1]
-            self.assertEquals(betas[0], 1)
-            self.assertEquals(betas[1], 2)
-            self.assertEquals(betas[2], 3)
-        if runtime.id == 2:
-            betas = keys[1]
-            self.assertEquals(betas[0], 4)
-            self.assertEquals(betas[1], 5)
-            self.assertEquals(betas[2], 6)
-        if runtime.id == 3:
-            betas = keys[1]
-            self.assertEquals(betas[0], 7)
-            self.assertEquals(betas[1], 8)
-            self.assertEquals(betas[2], 9)
-
-    @protocol
-    def test_authentication_codes(self, runtime):
-        """Test generating random shares."""
-
-        Zp = GF(6277101735386680763835789423176059013767194773182842284081)
-
-        v = Zp(2)
-        runtime.init_keys(Zp)
-        alpha, betas = runtime.get_keys()
-        codes = self.num_players * [None]
-
-        for xid in runtime.players.keys():
-            keys = map(lambda (alpha, akeys): (alpha, akeys[xid - 1]), runtime.keys.values())
-            codes[xid-1] = runtime.authentication_codes(keys, v).auth_codes
-        
-        if runtime.id == 1:
-            my_codes = codes[0]
-            self.assertEquals(my_codes[0], Zp(5))
-            self.assertEquals(my_codes[1], Zp(10))
-            self.assertEquals(my_codes[2], Zp(15))
-        if runtime.id == 2:
-            my_codes = codes[1]
-            self.assertEquals(my_codes[0], Zp(6))
-            self.assertEquals(my_codes[1], Zp(11))
-            self.assertEquals(my_codes[2], Zp(16))
-        if runtime.id == 3:
-            my_codes = codes[2]
-            self.assertEquals(my_codes[0], Zp(7))
-            self.assertEquals(my_codes[1], Zp(12))
-            self.assertEquals(my_codes[2], Zp(17))
-
-    @protocol
     def test_messagelist(self, runtime):
         """Test loading of keys."""