viff

changeset 1570:6a727af6cb6c

BeDOZa: Removed unused methods from share generator.
author Thomas P Jakobsen <tpj@cs.au.dk>
date Mon, 04 Oct 2010 10:27:01 +0200
parents 7cfd212041ac
children cb800e02f5bd
files viff/bedoza/bedoza_triple.py viff/bedoza/share_generators.py viff/test/bedoza/test_bedoza_triple.py
diffstat 3 files changed, 1 insertions(+), 64 deletions(-) [+]
line diff
     1.1 --- a/viff/bedoza/bedoza_triple.py	Mon Oct 04 10:27:01 2010 +0200
     1.2 +++ b/viff/bedoza/bedoza_triple.py	Mon Oct 04 10:27:01 2010 +0200
     1.3 @@ -30,7 +30,7 @@
     1.4  from viff.util import rand
     1.5  from viff.bedoza.shares import BeDOZaShare, BeDOZaShareContents, PartialShare
     1.6  from viff.bedoza.shares import PartialShareContents
     1.7 -from viff.bedoza.share_generators import ShareGenerator, PartialShareGenerator
     1.8 +from viff.bedoza.share_generators import PartialShareGenerator
     1.9  from viff.bedoza.keylist import BeDOZaKeyList
    1.10  from viff.bedoza.maclist import BeDOZaMACList
    1.11  from viff.bedoza.add_macs import add_macs
     2.1 --- a/viff/bedoza/share_generators.py	Mon Oct 04 10:27:01 2010 +0200
     2.2 +++ b/viff/bedoza/share_generators.py	Mon Oct 04 10:27:01 2010 +0200
     2.3 @@ -45,25 +45,6 @@
     2.4          self.runtime.schedule_callback(enc_shares, create_partial_share, share)
     2.5          return enc_shares
     2.6  
     2.7 -    def generate_random_shares(self, n):
     2.8 -        self.runtime.increment_pc()
     2.9 -        N_squared_list = [self.runtime.players[player_id].pubkey['n_square']
    2.10 -                          for player_id in self.runtime.players]
    2.11 -        shares = [PartialShare(self.runtime, self.Zp) for _ in xrange(n)]
    2.12 -        for inx in xrange(n):
    2.13 -            r = self.random.randint(0, self.Zp.modulus - 1)
    2.14 -            ri = self.Zp(r)
    2.15 -            enc_share = self.paillier.encrypt(ri.value)
    2.16 -            enc_shares = _convolute(self.runtime, enc_share)
    2.17 -            def create_partial_share(enc_shares, ri, s, N_squared_list):
    2.18 -                s.callback(PartialShareContents(ri, enc_shares,
    2.19 -                                                N_squared_list))
    2.20 -            self.runtime.schedule_callback(enc_shares,
    2.21 -                                           create_partial_share,
    2.22 -                                           ri,
    2.23 -                                           shares[inx],
    2.24 -                                           N_squared_list)
    2.25 -        return shares
    2.26  
    2.27  class ShareGenerator(PartialShareGenerator):
    2.28  
    2.29 @@ -78,9 +59,3 @@
    2.30          full_share = add_macs(self.runtime, self.Zp, self.u_bound, self.alpha,
    2.31                               self.random, self.paillier, [partial_share])
    2.32          return full_share[0]
    2.33 -    
    2.34 -    def generate_random_shares(self, n):
    2.35 -        self.runtime.increment_pc()
    2.36 -        partial_shares = PartialShareGenerator.generate_random_shares(self, n)
    2.37 -        return add_macs(self.runtime, self.Zp, self.u_bound, self.alpha,
    2.38 -                        self.random, self.paillier, partial_shares)
     3.1 --- a/viff/test/bedoza/test_bedoza_triple.py	Mon Oct 04 10:27:01 2010 +0200
     3.2 +++ b/viff/test/bedoza/test_bedoza_triple.py	Mon Oct 04 10:27:01 2010 +0200
     3.3 @@ -190,13 +190,6 @@
     3.4      gen = PartialShareGenerator(Zp, runtime, share_random, paillier)
     3.5      return gen.generate_share(Zp(val))
     3.6  
     3.7 -def partial_random_shares(random, runtime, Zp, n, paillier=None):
     3.8 -    if not paillier:
     3.9 -        paillier_random = Random(random.getrandbits(128))
    3.10 -        paillier = ModifiedPaillier(runtime, paillier_random)
    3.11 -    share_random = Random(random.getrandbits(128))
    3.12 -    gen = PartialShareGenerator(Zp, runtime, share_random, paillier)
    3.13 -    return gen.generate_random_shares(n)
    3.14  
    3.15  class PartialShareGeneratorTest(BeDOZaTestCase):
    3.16   
    3.17 @@ -237,37 +230,6 @@
    3.18          runtime.schedule_callback(share, decrypt)
    3.19          return share
    3.20  
    3.21 -    @protocol
    3.22 -    def test_random_shares_have_correct_type(self, runtime):
    3.23 -        Zp = GF(23)
    3.24 -        shares = partial_random_shares(Random(23499), runtime, Zp, 7)
    3.25 -        for share in shares:
    3.26 -            def test(share):
    3.27 -                self.assertEquals(Zp, share.value.field)
    3.28 -            runtime.schedule_callback(share, test)
    3.29 -            
    3.30 -        return shares
    3.31 - 
    3.32 -    @protocol
    3.33 -    def test_encrypted_random_shares_decrypt_correctly(self, runtime):
    3.34 -        random = Random(3423993)
    3.35 -        modulus = 17
    3.36 -        Zp = GF(modulus)
    3.37 -        paillier = ModifiedPaillier(runtime, Random(random.getrandbits(128)))
    3.38 -        shares = partial_random_shares(random, runtime, Zp, 7, paillier=paillier)
    3.39 -        expected_result = [9,16,7,12,3,5,6]
    3.40 -        for inx, share in enumerate(shares):
    3.41 -            def decrypt(share, expected_result):
    3.42 -                decrypted_share = paillier.decrypt(share.enc_shares[runtime.id - 1])
    3.43 -                decrypted_shares = _convolute(runtime, decrypted_share)
    3.44 -                def test_sum(vals, expected_result):
    3.45 -                    v = Zp(sum(vals))
    3.46 -                    self.assertEquals(expected_result, v)
    3.47 -                runtime.schedule_callback(decrypted_shares, test_sum, expected_result)
    3.48 -            runtime.schedule_callback(share, decrypt, expected_result[inx])
    3.49 -            
    3.50 -        return shares
    3.51 -
    3.52  class ShareGeneratorTest(BeDOZaTestCase):
    3.53  
    3.54      @protocol