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 wrap: on
line diff
--- a/viff/bedoza/bedoza_triple.py	Mon Oct 04 10:27:01 2010 +0200
+++ b/viff/bedoza/bedoza_triple.py	Mon Oct 04 10:27:01 2010 +0200
@@ -30,7 +30,7 @@
 from viff.util import rand
 from viff.bedoza.shares import BeDOZaShare, BeDOZaShareContents, PartialShare
 from viff.bedoza.shares import PartialShareContents
-from viff.bedoza.share_generators import ShareGenerator, PartialShareGenerator
+from viff.bedoza.share_generators import PartialShareGenerator
 from viff.bedoza.keylist import BeDOZaKeyList
 from viff.bedoza.maclist import BeDOZaMACList
 from viff.bedoza.add_macs import add_macs
--- a/viff/bedoza/share_generators.py	Mon Oct 04 10:27:01 2010 +0200
+++ b/viff/bedoza/share_generators.py	Mon Oct 04 10:27:01 2010 +0200
@@ -45,25 +45,6 @@
         self.runtime.schedule_callback(enc_shares, create_partial_share, share)
         return enc_shares
 
-    def generate_random_shares(self, n):
-        self.runtime.increment_pc()
-        N_squared_list = [self.runtime.players[player_id].pubkey['n_square']
-                          for player_id in self.runtime.players]
-        shares = [PartialShare(self.runtime, self.Zp) for _ in xrange(n)]
-        for inx in xrange(n):
-            r = self.random.randint(0, self.Zp.modulus - 1)
-            ri = self.Zp(r)
-            enc_share = self.paillier.encrypt(ri.value)
-            enc_shares = _convolute(self.runtime, enc_share)
-            def create_partial_share(enc_shares, ri, s, N_squared_list):
-                s.callback(PartialShareContents(ri, enc_shares,
-                                                N_squared_list))
-            self.runtime.schedule_callback(enc_shares,
-                                           create_partial_share,
-                                           ri,
-                                           shares[inx],
-                                           N_squared_list)
-        return shares
 
 class ShareGenerator(PartialShareGenerator):
 
@@ -78,9 +59,3 @@
         full_share = add_macs(self.runtime, self.Zp, self.u_bound, self.alpha,
                              self.random, self.paillier, [partial_share])
         return full_share[0]
-    
-    def generate_random_shares(self, n):
-        self.runtime.increment_pc()
-        partial_shares = PartialShareGenerator.generate_random_shares(self, n)
-        return add_macs(self.runtime, self.Zp, self.u_bound, self.alpha,
-                        self.random, self.paillier, partial_shares)
--- a/viff/test/bedoza/test_bedoza_triple.py	Mon Oct 04 10:27:01 2010 +0200
+++ b/viff/test/bedoza/test_bedoza_triple.py	Mon Oct 04 10:27:01 2010 +0200
@@ -190,13 +190,6 @@
     gen = PartialShareGenerator(Zp, runtime, share_random, paillier)
     return gen.generate_share(Zp(val))
 
-def partial_random_shares(random, runtime, Zp, n, paillier=None):
-    if not paillier:
-        paillier_random = Random(random.getrandbits(128))
-        paillier = ModifiedPaillier(runtime, paillier_random)
-    share_random = Random(random.getrandbits(128))
-    gen = PartialShareGenerator(Zp, runtime, share_random, paillier)
-    return gen.generate_random_shares(n)
 
 class PartialShareGeneratorTest(BeDOZaTestCase):
  
@@ -237,37 +230,6 @@
         runtime.schedule_callback(share, decrypt)
         return share
 
-    @protocol
-    def test_random_shares_have_correct_type(self, runtime):
-        Zp = GF(23)
-        shares = partial_random_shares(Random(23499), runtime, Zp, 7)
-        for share in shares:
-            def test(share):
-                self.assertEquals(Zp, share.value.field)
-            runtime.schedule_callback(share, test)
-            
-        return shares
- 
-    @protocol
-    def test_encrypted_random_shares_decrypt_correctly(self, runtime):
-        random = Random(3423993)
-        modulus = 17
-        Zp = GF(modulus)
-        paillier = ModifiedPaillier(runtime, Random(random.getrandbits(128)))
-        shares = partial_random_shares(random, runtime, Zp, 7, paillier=paillier)
-        expected_result = [9,16,7,12,3,5,6]
-        for inx, share in enumerate(shares):
-            def decrypt(share, expected_result):
-                decrypted_share = paillier.decrypt(share.enc_shares[runtime.id - 1])
-                decrypted_shares = _convolute(runtime, decrypted_share)
-                def test_sum(vals, expected_result):
-                    v = Zp(sum(vals))
-                    self.assertEquals(expected_result, v)
-                runtime.schedule_callback(decrypted_shares, test_sum, expected_result)
-            runtime.schedule_callback(share, decrypt, expected_result[inx])
-            
-        return shares
-
 class ShareGeneratorTest(BeDOZaTestCase):
 
     @protocol