viff

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 diff
     1.1 --- a/viff/passive.py	Wed Feb 04 23:40:56 2009 +0100
     1.2 +++ b/viff/passive.py	Mon Feb 09 10:50:57 2009 +0100
     1.3 @@ -440,6 +440,32 @@
     1.4          unless there is only one inputter in which case the
     1.5          share is returned directly.
     1.6  
     1.7 +        In code it is used like this::
     1.8 +
     1.9 +            a, b, c = runtime.shamir_share([1, 2, 3], Zp, x)
    1.10 +
    1.11 +        where ``Zp`` is a field and ``x`` is a Python integer holding
    1.12 +        the input of each player (three inputs in total).
    1.13 +
    1.14 +        If only a subset of the players provide input it looks like
    1.15 +        this::
    1.16 +
    1.17 +            if runtime.id == 1:
    1.18 +                a = runtime.shamir_share([1], Zp, x)
    1.19 +            else:
    1.20 +                a = runtime.shamir_share([1], Zp)
    1.21 +
    1.22 +        Instead of branching when calling :meth:`shamir_share`, one
    1.23 +        can give ``None`` as input::
    1.24 +
    1.25 +            if runtime.id == 1:
    1.26 +                x = int(raw_input("Input x: "))
    1.27 +            else:
    1.28 +                x = None
    1.29 +            a = runtime.shamir_share([1], Zp, x)
    1.30 +
    1.31 +        which might be practical in some cases.
    1.32 +
    1.33          Communication cost: n elements transmitted.
    1.34          """
    1.35          assert number is None or self.id in inputters