viff

changeset 1536:4e36cad23bc1

Added doctest for shamir.recombine().
author Thomas P Jakobsen <tpj@cs.au.dk>
date Wed, 11 Aug 2010 11:04:19 +0200
parents b4451e4ac76d
children 9c938858c46b
files viff/shamir.py
diffstat 1 files changed, 9 insertions(+), 0 deletions(-) [+]
line diff
     1.1 --- a/viff/shamir.py	Tue Aug 10 16:03:54 2010 +0200
     1.2 +++ b/viff/shamir.py	Wed Aug 11 11:04:19 2010 +0200
     1.3 @@ -96,6 +96,15 @@
     1.4  
     1.5      Shares is a list of *threshold* + 1 ``(player id, share)`` pairs.
     1.6      Recombination is done in the optional point *x_recomb*.
     1.7 +    
     1.8 +    >>> from field import GF
     1.9 +    >>> Zp = GF(19)
    1.10 +    >>> shares = [(Zp(i), 7 * Zp(i) + 3) for i in range(1, 4)]
    1.11 +    >>> print shares
    1.12 +    [({1}, {10}), ({2}, {17}), ({3}, {5})]
    1.13 +    >>> del(shares[1])
    1.14 +    >>> recombine(shares)
    1.15 +    {3}
    1.16      """
    1.17      xs, ys = zip(*shares)
    1.18      key = xs + (x_recomb, )