viff

changeset 1500:74ad8413cc11

BeDOZa: Renamed auth_codes to macs.
author Janus Dam Nielsen <janus.nielsen@alexandra.dk>
date Thu, 15 Jul 2010 11:37:48 +0200
parents 24cee22d06bc
children 522203844397
files viff/bedoza.py viff/test/test_bedoza_runtime.py
diffstat 2 files changed, 25 insertions(+), 27 deletions(-) [+]
line diff
     1.1 --- a/viff/bedoza.py	Thu Jul 15 11:37:46 2010 +0200
     1.2 +++ b/viff/bedoza.py	Thu Jul 15 11:37:48 2010 +0200
     1.3 @@ -76,7 +76,7 @@
     1.4      def cmul(self, c):
     1.5          zi = c * self.value
     1.6          zks = BeDOZaKeyList(self.keyList.alpha, map(lambda k: c * k, self.keyList.get_keys()))
     1.7 -        zms = BeDOZaMACList(map(lambda m: c * m, self.macs.auth_codes))
     1.8 +        zms = BeDOZaMACList(map(lambda m: c * m, self.macs.get_macs()))
     1.9          return BeDOZaShareContents(zi, zks, zms)
    1.10  
    1.11      def __str__(self):
    1.12 @@ -141,34 +141,34 @@
    1.13      
    1.14  class BeDOZaMACList(object):
    1.15  
    1.16 -    def __init__(self, auth_codes):
    1.17 -        self.auth_codes = auth_codes
    1.18 +    def __init__(self, macs):
    1.19 +        self.macs = macs
    1.20  
    1.21      def get_macs(self):
    1.22 -        return self.auth_codes
    1.23 +        return self.macs
    1.24  
    1.25      def get_mac(self, inx):
    1.26 -        return self.auth_codes[inx]
    1.27 +        return self.macs[inx]
    1.28          
    1.29      def __add__(self, other):
    1.30          """Addition."""
    1.31 -        auth_codes = []
    1.32 -        for c1, c2 in zip(self.auth_codes, other.auth_codes):
    1.33 -            auth_codes.append(c1 + c2)
    1.34 -        return BeDOZaMACList(auth_codes)
    1.35 +        macs = []
    1.36 +        for c1, c2 in zip(self.macs, other.macs):
    1.37 +            macs.append(c1 + c2)
    1.38 +        return BeDOZaMACList(macs)
    1.39  
    1.40      def __sub__(self, other):
    1.41          """Subtraction."""
    1.42 -        auth_codes = []
    1.43 -        for c1, c2 in zip(self.auth_codes, other.auth_codes):
    1.44 -            auth_codes.append(c1 - c2)
    1.45 -        return BeDOZaMACList(auth_codes)
    1.46 +        macs = []
    1.47 +        for c1, c2 in zip(self.macs, other.macs):
    1.48 +            macs.append(c1 - c2)
    1.49 +        return BeDOZaMACList(macs)
    1.50  
    1.51      def __eq__(self, other):
    1.52 -        return self.auth_codes == other.auth_codes
    1.53 +        return self.macs == other.macs
    1.54  
    1.55      def __str__(self):
    1.56 -        return str(self.auth_codes)
    1.57 +        return str(self.macs)
    1.58  
    1.59      def __repr__(self):
    1.60          return str(self)
    1.61 @@ -186,19 +186,19 @@
    1.62  
    1.63      def generate_share(self, field, value):
    1.64          my_keys = self.generate_keys(field)
    1.65 -        auth_codes = self.generate_auth_codes(self.id, value)
    1.66 -        return BeDOZaShare(self, field, value, my_keys, auth_codes)
    1.67 +        macs = self.generate_auth_codes(self.id, value)
    1.68 +        return BeDOZaShare(self, field, value, my_keys, macs)
    1.69  
    1.70      def generate_auth_codes(self, playerId, value):
    1.71          keys = map(lambda (alpha, akeys): (alpha, akeys[playerId - 1]), self.keys.values())
    1.72 -        auth_codes = self.authentication_codes(keys, value)
    1.73 -        return auth_codes
    1.74 +        macs = self.authentication_codes(keys, value)
    1.75 +        return macs
    1.76  
    1.77      def authentication_codes(self, keys, v):
    1.78 -        auth_codes = []
    1.79 +        macs = []
    1.80          for alpha, beta in keys:
    1.81 -            auth_codes.append(alpha * v + beta)
    1.82 -        return BeDOZaMACList(auth_codes)
    1.83 +            macs.append(alpha * v + beta)
    1.84 +        return BeDOZaMACList(macs)
    1.85  
    1.86      def generate_keys(self, field):
    1.87          alpha, betas = self.get_keys()
    1.88 @@ -284,8 +284,6 @@
    1.89              pc = tuple(self.program_counter)
    1.90              keyLists = []
    1.91              for other_id in receivers:
    1.92 -                # self.protocols[other_id].sendShare(pc, xi)
    1.93 -                # self.protocols[other_id].sendShare(pc, codes.auth_codes[other_id - 1])
    1.94                  message_string = ""
    1.95                  for inx, beDOZaContents in enumerate(ls):
    1.96                      keyLists.append(beDOZaContents.get_keys())
     2.1 --- a/viff/test/test_bedoza_runtime.py	Thu Jul 15 11:37:46 2010 +0200
     2.2 +++ b/viff/test/test_bedoza_runtime.py	Thu Jul 15 11:37:48 2010 +0200
     2.3 @@ -43,9 +43,9 @@
     2.4          m1 = BeDOZaMACList([Zp(2), Zp(34)])
     2.5          m2 = BeDOZaMACList([Zp(11), Zp(4)])
     2.6          m3 = m1 + m2
     2.7 -        self.assertEquals(m3.auth_codes[0], 13)
     2.8 -        self.assertEquals(m3.auth_codes[1], 38)
     2.9 -        self.assertEquals(len(m3.auth_codes), 2)
    2.10 +        self.assertEquals(m3.macs[0], 13)
    2.11 +        self.assertEquals(m3.macs[1], 38)
    2.12 +        self.assertEquals(len(m3.macs), 2)
    2.13          return m3
    2.14          
    2.15