http://hg.viff.dk/viff/rev/e810a006c2bf
changeset: 1100:e810a006c2bf
user:      Martin Geisler <[email protected]>
date:      Mon Feb 09 10:50:57 2009 +0100
summary:   Better documentation for shamir_share method.

diffstat:

1 file changed, 26 insertions(+)
viff/passive.py |   26 ++++++++++++++++++++++++++

diffs (36 lines):

diff -r cc706ddd9376 -r e810a006c2bf viff/passive.py
--- a/viff/passive.py   Wed Feb 04 23:40:56 2009 +0100
+++ b/viff/passive.py   Mon Feb 09 10:50:57 2009 +0100
@@ -440,6 +440,32 @@
         unless there is only one inputter in which case the
         share is returned directly.
 
+        In code it is used like this::
+
+            a, b, c = runtime.shamir_share([1, 2, 3], Zp, x)
+
+        where ``Zp`` is a field and ``x`` is a Python integer holding
+        the input of each player (three inputs in total).
+
+        If only a subset of the players provide input it looks like
+        this::
+
+            if runtime.id == 1:
+                a = runtime.shamir_share([1], Zp, x)
+            else:
+                a = runtime.shamir_share([1], Zp)
+
+        Instead of branching when calling :meth:`shamir_share`, one
+        can give ``None`` as input::
+
+            if runtime.id == 1:
+                x = int(raw_input("Input x: "))
+            else:
+                x = None
+            a = runtime.shamir_share([1], Zp, x)
+
+        which might be practical in some cases.
+
         Communication cost: n elements transmitted.
         """
         assert number is None or self.id in inputters
_______________________________________________
viff-commits mailing list
[email protected]
http://lists.viff.dk/listinfo.cgi/viff-commits-viff.dk

Reply via email to