viff

changeset 1467:f1d0c720a269

BeDOZa: Added a generate_share method.
author Janus Dam Nielsen <janus.nielsen@alexandra.dk>
date Wed, 07 Jul 2010 13:11:56 +0200
parents 6b96a1fdb751
children f69a5db4ecfc
files viff/bedoza.py
diffstat 1 files changed, 8 insertions(+), 7 deletions(-) [+]
line diff
     1.1 --- a/viff/bedoza.py	Wed Jul 07 10:56:22 2010 +0200
     1.2 +++ b/viff/bedoza.py	Wed Jul 07 13:11:56 2010 +0200
     1.3 @@ -116,23 +116,24 @@
     1.4  class RandomShareGenerator:
     1.5  
     1.6      def generate_random_shares(self, field, number_of_shares):
     1.7 -        def keys_N_codes(value):
     1.8 -            auth_codes = self.generate_auth_codes(self.id, v)
     1.9 -            my_keys = self.generate_keys()
    1.10 -            return BeDOZaShare(self, field, v, my_keys, auth_codes)
    1.11          shares = []
    1.12          for i in xrange(0, number_of_shares):
    1.13              if self.id == 1:
    1.14                  v = field(1)
    1.15 -                shares.append(keys_N_codes(v))
    1.16 +                shares.append(self.generate_share(field, v))
    1.17              if self.id == 2:
    1.18                  v = field(2)
    1.19 -                shares.append(keys_N_codes(v))
    1.20 +                shares.append(self.generate_share(field, v))
    1.21              if self.id == 3:
    1.22                  v = field(3)
    1.23 -                shares.append(keys_N_codes(v))
    1.24 +                shares.append(self.generate_share(field, v))
    1.25          return shares
    1.26  
    1.27 +    def generate_share(self, field, value):
    1.28 +        auth_codes = self.generate_auth_codes(self.id, value)
    1.29 +        my_keys = self.generate_keys()
    1.30 +        return BeDOZaShare(self, field, value, my_keys, auth_codes)
    1.31 +
    1.32      def generate_auth_codes(self, playerId, value):
    1.33          keys = map(lambda (alpha, akeys): (alpha, akeys[playerId - 1]), self.keys.values())
    1.34          auth_codes = self.authentication_codes(keys, value)