changeset 930:a1aa8bc840e1

Use Shamir instead of PRSS to generate shares.
author Martin Geisler <mg@daimi.au.dk>
date Wed, 17 Sep 2008 15:01:13 +0200
parents 1d8345e936a0
children 4237dbc953fd
files apps/benchmark.py
diffstat 1 files changed, 13 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/apps/benchmark.py	Wed Sep 17 14:59:43 2008 +0200
+++ b/apps/benchmark.py	Wed Sep 17 15:01:13 2008 +0200
@@ -68,7 +68,7 @@
 from viff.comparison import ComparisonToft05Mixin, ComparisonToft07Mixin
 from viff.paillier import PaillierRuntime
 from viff.config import load_config
-from viff.util import find_prime
+from viff.util import find_prime, rand
 
 last_timestamp = time.time()
 start = 0
@@ -178,9 +178,18 @@
             self.begin(None)
 
     def begin(self, _):
-        print "Runtime ready, starting protocol"
-        self.a_shares = [self.rt.prss_share_random(Zp) for _ in range(count)]
-        self.b_shares = [self.rt.prss_share_random(Zp) for _ in range(count)]
+        print "Runtime ready, generating shares"
+        self.a_shares = []
+        self.b_shares = []
+        for i in range(count):
+            inputter = (i % len(self.rt.players)) + 1
+            if inputter == self.rt.id:
+                a = rand.randint(0, Zp.modulus)
+                b = rand.randint(0, Zp.modulus)
+            else:
+                a, b = None, None
+            self.a_shares.append(self.rt.shamir_share([inputter], Zp, a))
+            self.b_shares.append(self.rt.shamir_share([inputter], Zp, b))
         shares_ready = gather_shares(self.a_shares + self.b_shares)
         shares_ready.addCallback(self.sync_test)