viff

changeset 1512:bd9cdea06338

BeDOZa: No need for the field argument.
author Janus Dam Nielsen <janus.nielsen@alexandra.dk>
date Tue, 20 Jul 2010 16:55:40 +0200
parents 90338602985d
children 71038263d036
files viff/bedoza_triple.py viff/test/test_bedoza_triple.py
diffstat 2 files changed, 9 insertions(+), 9 deletions(-) [+]
line diff
     1.1 --- a/viff/bedoza_triple.py	Tue Jul 20 16:52:06 2010 +0200
     1.2 +++ b/viff/bedoza_triple.py	Tue Jul 20 16:55:40 2010 +0200
     1.3 @@ -267,13 +267,13 @@
     1.4               partial_shares.append(gen.generate_share(self.random.randint(0, self.Zp.modulus - 1)))
     1.5  
     1.6  
     1.7 -        partial_shares_c = self._full_mul(partial_shares[0:n], partial_shares[n:2*n], self.Zp)
     1.8 +        partial_shares_c = self._full_mul(partial_shares[0:n], partial_shares[n:2*n])
     1.9  
    1.10 -        full_shares = self._add_macs(partial_shares + partial_shares_c, self.Zp)
    1.11 +        full_shares = self._add_macs(partial_shares + partial_shares_c)
    1.12  
    1.13          return full_shares
    1.14      
    1.15 -    def _add_macs(self, partial_shares, field):
    1.16 +    def _add_macs(self, partial_shares):
    1.17          """Adds macs to the set of PartialBeDOZaShares.
    1.18          
    1.19          Returns a deferred which yields a list of full shares, e.g.
    1.20 @@ -327,7 +327,7 @@
    1.21              self.runtime.schedule_callback(received_cs, finish_sharing, partial_share_contents, lists_of_mac_keys, result_shares)
    1.22              return received_cs
    1.23  
    1.24 -        result_shares = [Share(self.runtime, field) for x in xrange(len(partial_shares))]
    1.25 +        result_shares = [Share(self.runtime, self.Zp) for x in xrange(len(partial_shares))]
    1.26          self.runtime.schedule_callback(gatherResults(partial_shares),
    1.27                                         do_add_macs,
    1.28                                         result_shares)
    1.29 @@ -418,7 +418,7 @@
    1.30          r.addCallback(wrap, inx, jnx)
    1.31          return r
    1.32  
    1.33 -    def _full_mul(self, a, b, field):
    1.34 +    def _full_mul(self, a, b):
    1.35          """Multiply each of the PartialShares in the list *a* with the
    1.36          corresponding PartialShare in the list *b*.
    1.37          
    1.38 @@ -458,7 +458,7 @@
    1.39              d = gatherResults(deferreds)
    1.40              d.addCallback(compute_shares, len_shares, result_shares)
    1.41              return d
    1.42 -        result_shares = [Share(self.runtime, field) for x in a]
    1.43 +        result_shares = [Share(self.runtime, self.Zp) for x in a]
    1.44          self.runtime.schedule_callback(gatherResults(a + b),
    1.45                                         do_full_mul,
    1.46                                         result_shares)
     2.1 --- a/viff/test/test_bedoza_triple.py	Tue Jul 20 16:52:06 2010 +0200
     2.2 +++ b/viff/test/test_bedoza_triple.py	Tue Jul 20 16:55:40 2010 +0200
     2.3 @@ -317,7 +317,7 @@
     2.4          shares.append(partial_share(random, runtime, Zp, secret + 2, paillier=paillier))
     2.5          shares.append(partial_share(random, runtime, Zp, secret + 3, paillier=paillier))
     2.6  
     2.7 -        zs = triple_generator._add_macs(shares, Zp)
     2.8 +        zs = triple_generator._add_macs(shares)
     2.9          def verify(open_shares):
    2.10              inx = secret
    2.11              for open_share in open_shares:
    2.12 @@ -455,7 +455,7 @@
    2.13          share_bs.append(partial_share(random, runtime, GF(p), 3, paillier=paillier))
    2.14  
    2.15  
    2.16 -        share_zs = triple_generator._full_mul(share_as, share_bs, Zp)
    2.17 +        share_zs = triple_generator._full_mul(share_as, share_bs)
    2.18          def check(shares):
    2.19              def test_sum(ls):
    2.20                  self.assertEquals(8, Zp(sum(ls[0])))
    2.21 @@ -493,7 +493,7 @@
    2.22          share_as.append(partial_share(random, runtime, GF(p), 2, paillier=paillier))
    2.23          share_bs.append(partial_share(random, runtime, GF(p), 3, paillier=paillier))
    2.24  
    2.25 -        share_zs = triple_generator._full_mul(share_as, share_bs, Zp)
    2.26 +        share_zs = triple_generator._full_mul(share_as, share_bs)
    2.27          def check(shares):
    2.28              all_enc_shares = []
    2.29              for share in shares: