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 wrap: on
line diff
--- a/viff/bedoza.py	Wed Jul 07 10:56:22 2010 +0200
+++ b/viff/bedoza.py	Wed Jul 07 13:11:56 2010 +0200
@@ -116,23 +116,24 @@
 class RandomShareGenerator:
 
     def generate_random_shares(self, field, number_of_shares):
-        def keys_N_codes(value):
-            auth_codes = self.generate_auth_codes(self.id, v)
-            my_keys = self.generate_keys()
-            return BeDOZaShare(self, field, v, my_keys, auth_codes)
         shares = []
         for i in xrange(0, number_of_shares):
             if self.id == 1:
                 v = field(1)
-                shares.append(keys_N_codes(v))
+                shares.append(self.generate_share(field, v))
             if self.id == 2:
                 v = field(2)
-                shares.append(keys_N_codes(v))
+                shares.append(self.generate_share(field, v))
             if self.id == 3:
                 v = field(3)
-                shares.append(keys_N_codes(v))
+                shares.append(self.generate_share(field, v))
         return shares
 
+    def generate_share(self, field, value):
+        auth_codes = self.generate_auth_codes(self.id, value)
+        my_keys = self.generate_keys()
+        return BeDOZaShare(self, field, value, my_keys, auth_codes)
+
     def generate_auth_codes(self, playerId, value):
         keys = map(lambda (alpha, akeys): (alpha, akeys[playerId - 1]), self.keys.values())
         auth_codes = self.authentication_codes(keys, value)