Martin Geisler <[EMAIL PROTECTED]> writes:

> That would be a good idea, also for performance. I suggest that we use
> a round-robin system where we determine the perticipating subset based
> on the current program counter.

Code for this would look like this:

diff --git a/viff/runtime.py b/viff/runtime.py
--- a/viff/runtime.py
+++ b/viff/runtime.py
@@ -39,7 +39,7 @@
 from collections import deque
 
 from viff import shamir
-from viff.prss import prss, prss_lsb, prss_zero
+from viff.prss import prss, prss_lsb, prss_zero, generate_subsets
 from viff.field import GF256, FieldElement
 from viff.util import wrapper, rand
 
@@ -703,6 +703,18 @@
     def __init__(self, player, threshold, options=None):
         """Initialize runtime."""
         BasicRuntime.__init__(self, player, threshold, options)
+        self.subsets = {}
+
+    def select_subset(self, threshold):
+        """Select subset for *threshold* based on current program counter."""
+        try:
+            subsets = self.subsets[threshold]
+        except KeyError:
+            players = frozenset(range(1, self.num_players+1))
+            subsets = list(generate_subsets(players, 2*threshold + 1))
+            self.subsets[threshold] = subsets
+        return subsets[hash(tuple(self.program_counter)) % len(subsets)]
+

     @increment_pc
     def open(self, share, receivers=None, threshold=None):

(perhaps with an @increment_pc decorator...)

> So far I have a failing unit test which clearly shows the bug, I'll
> try and fix it now.

I've pushed the new unit tests as revision 4daa42544157, but I'm afraid
I'm too tired to fix things tonight... feel free to jump in :-)

-- 
Martin Geisler

Attachment: pgpO73AHmQUgo.pgp
Description: PGP signature

_______________________________________________
viff-devel mailing list (http://viff.dk/)
viff-devel@viff.dk
http://lists.viff.dk/listinfo.cgi/viff-devel-viff.dk

Reply via email to