viff

changeset 1496:4892a9b5ceb7

BeDOZa: Added accessor method to KeyList.
author Janus Dam Nielsen <janus.nielsen@alexandra.dk>
date Thu, 15 Jul 2010 11:35:21 +0200
parents 8a2f88e9f800
children eb00115f7755
files viff/bedoza.py
diffstat 1 files changed, 10 insertions(+), 7 deletions(-) [+]
line diff
     1.1 --- a/viff/bedoza.py	Thu Jul 15 11:35:20 2010 +0200
     1.2 +++ b/viff/bedoza.py	Thu Jul 15 11:35:21 2010 +0200
     1.3 @@ -61,18 +61,18 @@
     1.4      def add_public(self, c, my_id):
     1.5          if my_id == 1:
     1.6              self.value = self.value + c
     1.7 -        self.keyList.keys[0] = self.keyList.keys[0] - self.keyList.alpha * c
     1.8 +        self.keyList.get_keys()[0] = self.keyList.get_keys()[0] - self.keyList.alpha * c
     1.9          return self
    1.10      
    1.11      def sub_public(self, c, my_id):
    1.12          if my_id == 1:
    1.13              self.value = self.value - c
    1.14 -        self.keyList.keys[0] = self.keyList.keys[0] + self.keyList.alpha * c
    1.15 +        self.keyList.get_keys()[0] = self.keyList.get_keys()[0] + self.keyList.alpha * c
    1.16          return self
    1.17  
    1.18      def cmul(self, c):
    1.19          zi = c * self.value
    1.20 -        zks = BeDOZaKeyList(self.keyList.alpha, map(lambda k: c * k, self.keyList.keys))
    1.21 +        zks = BeDOZaKeyList(self.keyList.alpha, map(lambda k: c * k, self.keyList.get_keys()))
    1.22          zms = BeDOZaMessageList(map(lambda m: c * m, self.macs.auth_codes))
    1.23          return BeDOZaShareContents(zi, zks, zms)
    1.24  
    1.25 @@ -108,6 +108,9 @@
    1.26          self.alpha = alpha
    1.27          self.keys = keys
    1.28  
    1.29 +    def get_keys(self):
    1.30 +        return self.keys
    1.31 +
    1.32      def __add__(self, other):
    1.33          """Addition."""
    1.34          assert self.alpha == other.alpha
    1.35 @@ -252,7 +255,7 @@
    1.36              values = num_shares * [0]
    1.37              isOK = num_shares * [True]
    1.38              for iny in xrange(num_shares):
    1.39 -                keys = keyLists[iny].keys
    1.40 +                keys = keyLists[iny].get_keys()
    1.41                  for inx, xs in enumerate(player_shares_codes):
    1.42                      xi, mi = xs[iny]
    1.43                      beta = keys[inx]
    1.44 @@ -331,9 +334,9 @@
    1.45  
    1.46              n = len(self.players)
    1.47              alpha_a = keyList_a.alpha
    1.48 -            keys_a = keyList_a.keys
    1.49 +            keys_a = keyList_a.get_keys()
    1.50              alpha_b = keyList_b.alpha
    1.51 -            keys_b = keyList_b.keys
    1.52 +            keys_b = keyList_b.get_keys()
    1.53  
    1.54              a = 0
    1.55              b = 0
    1.56 @@ -407,7 +410,7 @@
    1.57              isOK = True
    1.58              n = len(self.players)
    1.59              alpha = keyList.alpha
    1.60 -            keys = keyList.keys
    1.61 +            keys = keyList.get_keys()
    1.62              x = 0
    1.63              for inx in xrange(0, n):
    1.64                  xi = shares_codes[inx]