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 wrap: on
line diff
--- a/viff/shamir.py	Tue Aug 10 16:03:54 2010 +0200
+++ b/viff/shamir.py	Wed Aug 11 11:04:19 2010 +0200
@@ -96,6 +96,15 @@
 
     Shares is a list of *threshold* + 1 ``(player id, share)`` pairs.
     Recombination is done in the optional point *x_recomb*.
+    
+    >>> from field import GF
+    >>> Zp = GF(19)
+    >>> shares = [(Zp(i), 7 * Zp(i) + 3) for i in range(1, 4)]
+    >>> print shares
+    [({1}, {10}), ({2}, {17}), ({3}, {5})]
+    >>> del(shares[1])
+    >>> recombine(shares)
+    {3}
     """
     xs, ys = zip(*shares)
     key = xs + (x_recomb, )