viff

changeset 1498:9432d8d0d17e

BeDOZa: Renamed MessageList MACList.
author Janus Dam Nielsen <janus.nielsen@alexandra.dk>
date Thu, 15 Jul 2010 11:37:33 +0200
parents eb00115f7755
children 24cee22d06bc
files viff/bedoza.py viff/bedoza_triple.py viff/test/test_bedoza_runtime.py viff/test/test_bedoza_triple.py
diffstat 4 files changed, 17 insertions(+), 17 deletions(-) [+]
line diff
     1.1 --- a/viff/bedoza.py	Thu Jul 15 11:35:22 2010 +0200
     1.2 +++ b/viff/bedoza.py	Thu Jul 15 11:37:33 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 = BeDOZaMessageList(map(lambda m: c * m, self.macs.auth_codes))
     1.8 +        zms = BeDOZaMACList(map(lambda m: c * m, self.macs.auth_codes))
     1.9          return BeDOZaShareContents(zi, zks, zms)
    1.10  
    1.11      def __str__(self):
    1.12 @@ -139,7 +139,7 @@
    1.13      def __repr__(self):
    1.14          return str(self)
    1.15      
    1.16 -class BeDOZaMessageList(object):
    1.17 +class BeDOZaMACList(object):
    1.18  
    1.19      def __init__(self, auth_codes):
    1.20          self.auth_codes = auth_codes
    1.21 @@ -155,14 +155,14 @@
    1.22          auth_codes = []
    1.23          for c1, c2 in zip(self.auth_codes, other.auth_codes):
    1.24              auth_codes.append(c1 + c2)
    1.25 -        return BeDOZaMessageList(auth_codes)
    1.26 +        return BeDOZaMACList(auth_codes)
    1.27  
    1.28      def __sub__(self, other):
    1.29          """Subtraction."""
    1.30          auth_codes = []
    1.31          for c1, c2 in zip(self.auth_codes, other.auth_codes):
    1.32              auth_codes.append(c1 - c2)
    1.33 -        return BeDOZaMessageList(auth_codes)
    1.34 +        return BeDOZaMACList(auth_codes)
    1.35  
    1.36      def __eq__(self, other):
    1.37          return self.auth_codes == other.auth_codes
    1.38 @@ -198,7 +198,7 @@
    1.39          auth_codes = []
    1.40          for alpha, beta in keys:
    1.41              auth_codes.append(alpha * v + beta)
    1.42 -        return BeDOZaMessageList(auth_codes)
    1.43 +        return BeDOZaMACList(auth_codes)
    1.44  
    1.45      def generate_keys(self, field):
    1.46          alpha, betas = self.get_keys()
     2.1 --- a/viff/bedoza_triple.py	Thu Jul 15 11:35:22 2010 +0200
     2.2 +++ b/viff/bedoza_triple.py	Thu Jul 15 11:37:33 2010 +0200
     2.3 @@ -26,7 +26,7 @@
     2.4  from viff.constants import TEXT
     2.5  from viff.util import rand
     2.6  
     2.7 -from bedoza import BeDOZaKeyList, BeDOZaMessageList, BeDOZaShare
     2.8 +from bedoza import BeDOZaKeyList, BeDOZaMACList, BeDOZaShare
     2.9  
    2.10  # TODO: Use secure random instead!
    2.11  from random import Random
    2.12 @@ -263,7 +263,7 @@
    2.13          def finish_sharing(recevied_cs):
    2.14              mac_key_list = BeDOZaKeyList(self.alpha, mac_keys)
    2.15              decrypted_cs = [self.Zp(self.paillier.decrypt(c)) for c in received_cs.result]
    2.16 -            mac_msg_list = BeDOZaMessageList(decrypted_cs)
    2.17 +            mac_msg_list = BeDOZaMACList(decrypted_cs)
    2.18              # Twisted HACK: Need to pack share into tuple.
    2.19              return BeDOZaShare(self.runtime,
    2.20                                 partial_shares[i].value.field,
     3.1 --- a/viff/test/test_bedoza_runtime.py	Thu Jul 15 11:35:22 2010 +0200
     3.2 +++ b/viff/test/test_bedoza_runtime.py	Thu Jul 15 11:37:33 2010 +0200
     3.3 @@ -22,7 +22,7 @@
     3.4  from viff.test.util import RuntimeTestCase, protocol
     3.5  from viff.runtime import gather_shares, Share
     3.6  from viff.config import generate_configs
     3.7 -from viff.bedoza import BeDOZaRuntime, BeDOZaShare, BeDOZaShareContents, BeDOZaKeyList, BeDOZaMessageList
     3.8 +from viff.bedoza import BeDOZaRuntime, BeDOZaShare, BeDOZaShareContents, BeDOZaKeyList, BeDOZaMACList
     3.9  from viff.field import FieldElement, GF
    3.10  from viff.util import rand
    3.11  
    3.12 @@ -40,8 +40,8 @@
    3.13  
    3.14          Zp = GF(6277101735386680763835789423176059013767194773182842284081)
    3.15  
    3.16 -        m1 = BeDOZaMessageList([Zp(2), Zp(34)])
    3.17 -        m2 = BeDOZaMessageList([Zp(11), Zp(4)])
    3.18 +        m1 = BeDOZaMACList([Zp(2), Zp(34)])
    3.19 +        m2 = BeDOZaMACList([Zp(11), Zp(4)])
    3.20          m3 = m1 + m2
    3.21          self.assertEquals(m3.auth_codes[0], 13)
    3.22          self.assertEquals(m3.auth_codes[1], 38)
    3.23 @@ -80,12 +80,12 @@
    3.24  
    3.25          Zp = GF(6277101735386680763835789423176059013767194773182842284081)
    3.26         
    3.27 -        x = BeDOZaShareContents(Zp(2), BeDOZaKeyList(Zp(23), [Zp(3), Zp(4), Zp(1)]), BeDOZaMessageList([Zp(2), Zp(74), Zp(23), Zp(2)]))
    3.28 -        y = BeDOZaShareContents(Zp(2), BeDOZaKeyList(Zp(23), [Zp(5), Zp(2), Zp(7)]), BeDOZaMessageList([Zp(2), Zp(74), Zp(23), Zp(2)]))
    3.29 +        x = BeDOZaShareContents(Zp(2), BeDOZaKeyList(Zp(23), [Zp(3), Zp(4), Zp(1)]), BeDOZaMACList([Zp(2), Zp(74), Zp(23), Zp(2)]))
    3.30 +        y = BeDOZaShareContents(Zp(2), BeDOZaKeyList(Zp(23), [Zp(5), Zp(2), Zp(7)]), BeDOZaMACList([Zp(2), Zp(74), Zp(23), Zp(2)]))
    3.31          z = runtime._plus((x, y), Zp)
    3.32          self.assertEquals(z.get_value(), Zp(4))
    3.33          self.assertEquals(z.get_keys(), BeDOZaKeyList(Zp(23), [Zp(8), Zp(6), Zp(8)]))
    3.34 -        self.assertEquals(z.get_macs(), BeDOZaMessageList([Zp(4), Zp(148), Zp(46), Zp(4)]))
    3.35 +        self.assertEquals(z.get_macs(), BeDOZaMACList([Zp(4), Zp(148), Zp(46), Zp(4)]))
    3.36  
    3.37      @protocol
    3.38      def test_sum(self, runtime):
    3.39 @@ -161,12 +161,12 @@
    3.40  
    3.41          Zp = GF(6277101735386680763835789423176059013767194773182842284081)
    3.42         
    3.43 -        x = BeDOZaShareContents(Zp(2), BeDOZaKeyList(Zp(23), [Zp(5), Zp(4), Zp(7)]), BeDOZaMessageList([Zp(2), Zp(75), Zp(23), Zp(2)]))
    3.44 -        y = BeDOZaShareContents(Zp(2), BeDOZaKeyList(Zp(23), [Zp(3), Zp(2), Zp(1)]), BeDOZaMessageList([Zp(2), Zp(74), Zp(23), Zp(2)]))
    3.45 +        x = BeDOZaShareContents(Zp(2), BeDOZaKeyList(Zp(23), [Zp(5), Zp(4), Zp(7)]), BeDOZaMACList([Zp(2), Zp(75), Zp(23), Zp(2)]))
    3.46 +        y = BeDOZaShareContents(Zp(2), BeDOZaKeyList(Zp(23), [Zp(3), Zp(2), Zp(1)]), BeDOZaMACList([Zp(2), Zp(74), Zp(23), Zp(2)]))
    3.47          z = runtime._minus((x, y), Zp)
    3.48          self.assertEquals(z.get_value(), Zp(0))
    3.49          self.assertEquals(z.get_keys(), BeDOZaKeyList(Zp(23), [Zp(2), Zp(2), Zp(6)]))
    3.50 -        self.assertEquals(z.get_macs(), BeDOZaMessageList([Zp(0), Zp(1), Zp(0), Zp(0)]))
    3.51 +        self.assertEquals(z.get_macs(), BeDOZaMACList([Zp(0), Zp(1), Zp(0), Zp(0)]))
    3.52  
    3.53      @protocol
    3.54      def test_sub(self, runtime):
     4.1 --- a/viff/test/test_bedoza_triple.py	Thu Jul 15 11:35:22 2010 +0200
     4.2 +++ b/viff/test/test_bedoza_triple.py	Thu Jul 15 11:37:33 2010 +0200
     4.3 @@ -27,7 +27,7 @@
     4.4  from viff.constants import TEXT
     4.5  from viff.runtime import gather_shares, Share
     4.6  from viff.config import generate_configs
     4.7 -from viff.bedoza import BeDOZaRuntime, BeDOZaShare, BeDOZaKeyList, BeDOZaMessageList
     4.8 +from viff.bedoza import BeDOZaRuntime, BeDOZaShare, BeDOZaKeyList
     4.9  
    4.10  from viff.bedoza_triple import TripleGenerator, PartialShare, PartialShareContents, ModifiedPaillier
    4.11  from viff.bedoza_triple import _send, _convolute, _convolute_gf_elm