changeset 1100:e810a006c2bf

Better documentation for shamir_share method.
author Martin Geisler <mg@daimi.au.dk>
date Mon, 09 Feb 2009 10:50:57 +0100
parents cc706ddd9376
children b79734a2fdbf
files viff/passive.py
diffstat 1 files changed, 26 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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