viff

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 diff
     1.1 --- a/viff/bedoza.py	Mon Jul 12 11:34:44 2010 +0200
     1.2 +++ b/viff/bedoza.py	Mon Jul 12 12:00:32 2010 +0200
     1.3 @@ -19,6 +19,7 @@
     1.4  
     1.5  from twisted.internet.defer import Deferred, gatherResults, succeed
     1.6  
     1.7 +from viff.util import rand
     1.8  from viff.runtime import Runtime, Share, ShareList, gather_shares
     1.9  from viff.field import FieldElement
    1.10  from viff.constants import TEXT
    1.11 @@ -152,9 +153,18 @@
    1.12          return BeDOZaKeyList(alpha, betas)
    1.13  
    1.14      def init_keys(self, field):
    1.15 -        self.keys = {1: (field(2), [field(1), field(2), field(3)]),
    1.16 -                     2: (field(3), [field(4), field(5), field(6)]),
    1.17 -                     3: (field(4), [field(7), field(8), field(9)])}
    1.18 +
    1.19 +        self.keys = {}
    1.20 +        for player_id in self.players:
    1.21 +            betas = [field(56387295767672113),
    1.22 +                     field(89238458945400961),
    1.23 +                     field(12340004554789025),
    1.24 +                     field(12907853897457058),
    1.25 +                     field(90457903592570134),
    1.26 +                     field(56256262346343232),
    1.27 +                     field(23897437894556562),
    1.28 +                     field(90297849575975574)]
    1.29 +            self.keys[player_id] = (field(player_id), betas)
    1.30  
    1.31      def get_keys(self):   
    1.32          return self.keys[self.id]
     2.1 --- a/viff/test/test_bedoza_runtime.py	Mon Jul 12 11:34:44 2010 +0200
     2.2 +++ b/viff/test/test_bedoza_runtime.py	Mon Jul 12 12:00:32 2010 +0200
     2.3 @@ -35,61 +35,6 @@
     2.4      runtime_class = BeDOZaRuntime
     2.5  
     2.6      @protocol
     2.7 -    def test_load_keys(self, runtime):
     2.8 -        """Test loading of keys."""
     2.9 -
    2.10 -        Zp = GF(6277101735386680763835789423176059013767194773182842284081)
    2.11 -
    2.12 -        runtime.init_keys(Zp)
    2.13 -        keys = runtime.get_keys()
    2.14 -        if runtime.id == 1:
    2.15 -            betas = keys[1]
    2.16 -            self.assertEquals(betas[0], 1)
    2.17 -            self.assertEquals(betas[1], 2)
    2.18 -            self.assertEquals(betas[2], 3)
    2.19 -        if runtime.id == 2:
    2.20 -            betas = keys[1]
    2.21 -            self.assertEquals(betas[0], 4)
    2.22 -            self.assertEquals(betas[1], 5)
    2.23 -            self.assertEquals(betas[2], 6)
    2.24 -        if runtime.id == 3:
    2.25 -            betas = keys[1]
    2.26 -            self.assertEquals(betas[0], 7)
    2.27 -            self.assertEquals(betas[1], 8)
    2.28 -            self.assertEquals(betas[2], 9)
    2.29 -
    2.30 -    @protocol
    2.31 -    def test_authentication_codes(self, runtime):
    2.32 -        """Test generating random shares."""
    2.33 -
    2.34 -        Zp = GF(6277101735386680763835789423176059013767194773182842284081)
    2.35 -
    2.36 -        v = Zp(2)
    2.37 -        runtime.init_keys(Zp)
    2.38 -        alpha, betas = runtime.get_keys()
    2.39 -        codes = self.num_players * [None]
    2.40 -
    2.41 -        for xid in runtime.players.keys():
    2.42 -            keys = map(lambda (alpha, akeys): (alpha, akeys[xid - 1]), runtime.keys.values())
    2.43 -            codes[xid-1] = runtime.authentication_codes(keys, v).auth_codes
    2.44 -        
    2.45 -        if runtime.id == 1:
    2.46 -            my_codes = codes[0]
    2.47 -            self.assertEquals(my_codes[0], Zp(5))
    2.48 -            self.assertEquals(my_codes[1], Zp(10))
    2.49 -            self.assertEquals(my_codes[2], Zp(15))
    2.50 -        if runtime.id == 2:
    2.51 -            my_codes = codes[1]
    2.52 -            self.assertEquals(my_codes[0], Zp(6))
    2.53 -            self.assertEquals(my_codes[1], Zp(11))
    2.54 -            self.assertEquals(my_codes[2], Zp(16))
    2.55 -        if runtime.id == 3:
    2.56 -            my_codes = codes[2]
    2.57 -            self.assertEquals(my_codes[0], Zp(7))
    2.58 -            self.assertEquals(my_codes[1], Zp(12))
    2.59 -            self.assertEquals(my_codes[2], Zp(17))
    2.60 -
    2.61 -    @protocol
    2.62      def test_messagelist(self, runtime):
    2.63          """Test loading of keys."""
    2.64