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 wrap: on
line diff
--- a/viff/bedoza_triple.py	Tue Jul 20 16:52:06 2010 +0200
+++ b/viff/bedoza_triple.py	Tue Jul 20 16:55:40 2010 +0200
@@ -267,13 +267,13 @@
              partial_shares.append(gen.generate_share(self.random.randint(0, self.Zp.modulus - 1)))
 
 
-        partial_shares_c = self._full_mul(partial_shares[0:n], partial_shares[n:2*n], self.Zp)
+        partial_shares_c = self._full_mul(partial_shares[0:n], partial_shares[n:2*n])
 
-        full_shares = self._add_macs(partial_shares + partial_shares_c, self.Zp)
+        full_shares = self._add_macs(partial_shares + partial_shares_c)
 
         return full_shares
     
-    def _add_macs(self, partial_shares, field):
+    def _add_macs(self, partial_shares):
         """Adds macs to the set of PartialBeDOZaShares.
         
         Returns a deferred which yields a list of full shares, e.g.
@@ -327,7 +327,7 @@
             self.runtime.schedule_callback(received_cs, finish_sharing, partial_share_contents, lists_of_mac_keys, result_shares)
             return received_cs
 
-        result_shares = [Share(self.runtime, field) for x in xrange(len(partial_shares))]
+        result_shares = [Share(self.runtime, self.Zp) for x in xrange(len(partial_shares))]
         self.runtime.schedule_callback(gatherResults(partial_shares),
                                        do_add_macs,
                                        result_shares)
@@ -418,7 +418,7 @@
         r.addCallback(wrap, inx, jnx)
         return r
 
-    def _full_mul(self, a, b, field):
+    def _full_mul(self, a, b):
         """Multiply each of the PartialShares in the list *a* with the
         corresponding PartialShare in the list *b*.
         
@@ -458,7 +458,7 @@
             d = gatherResults(deferreds)
             d.addCallback(compute_shares, len_shares, result_shares)
             return d
-        result_shares = [Share(self.runtime, field) for x in a]
+        result_shares = [Share(self.runtime, self.Zp) for x in a]
         self.runtime.schedule_callback(gatherResults(a + b),
                                        do_full_mul,
                                        result_shares)
--- a/viff/test/test_bedoza_triple.py	Tue Jul 20 16:52:06 2010 +0200
+++ b/viff/test/test_bedoza_triple.py	Tue Jul 20 16:55:40 2010 +0200
@@ -317,7 +317,7 @@
         shares.append(partial_share(random, runtime, Zp, secret + 2, paillier=paillier))
         shares.append(partial_share(random, runtime, Zp, secret + 3, paillier=paillier))
 
-        zs = triple_generator._add_macs(shares, Zp)
+        zs = triple_generator._add_macs(shares)
         def verify(open_shares):
             inx = secret
             for open_share in open_shares:
@@ -455,7 +455,7 @@
         share_bs.append(partial_share(random, runtime, GF(p), 3, paillier=paillier))
 
 
-        share_zs = triple_generator._full_mul(share_as, share_bs, Zp)
+        share_zs = triple_generator._full_mul(share_as, share_bs)
         def check(shares):
             def test_sum(ls):
                 self.assertEquals(8, Zp(sum(ls[0])))
@@ -493,7 +493,7 @@
         share_as.append(partial_share(random, runtime, GF(p), 2, paillier=paillier))
         share_bs.append(partial_share(random, runtime, GF(p), 3, paillier=paillier))
 
-        share_zs = triple_generator._full_mul(share_as, share_bs, Zp)
+        share_zs = triple_generator._full_mul(share_as, share_bs)
         def check(shares):
             all_enc_shares = []
             for share in shares: