viff

changeset 639:c99ae4b6b054

Allow a threshold of zero for dummy Shamir sharings.
author Martin Geisler <mg@daimi.au.dk>
date Sat, 05 Apr 2008 00:00:02 +0200
parents 45ce0d082747
children a5f51b2f3fb2
files viff/shamir.py
diffstat 1 files changed, 13 insertions(+), 1 deletions(-) [+]
line diff
     1.1 --- a/viff/shamir.py	Fri Apr 04 23:59:11 2008 +0200
     1.2 +++ b/viff/shamir.py	Sat Apr 05 00:00:02 2008 +0200
     1.3 @@ -36,6 +36,18 @@
     1.4      >>> recombine(share(secret, 7, 15)[:8]) == secret
     1.5      True
     1.6  
     1.7 +    The threshold can range from zero (for a dummy-sharing):
     1.8 +
     1.9 +    >>> share(Zp(10), 0, 5)
    1.10 +    [({1}, {10}), ({2}, {10}), ({3}, {10}), ({4}, {10}), ({5}, {10})]
    1.11 +
    1.12 +    up to but not including C{num_players}:
    1.13 +
    1.14 +    >>> share(Zp(10), 5, 5)
    1.15 +    Traceback (most recent call last):
    1.16 +      ...
    1.17 +    AssertionError: Threshold out of range
    1.18 +
    1.19      @param secret: the secret to be shared.
    1.20      @type secret: a field element
    1.21  
    1.22 @@ -49,7 +61,7 @@
    1.23      @return: shares, one for each player.
    1.24      @returntype: C{list} of (player id, share) pairs
    1.25      """
    1.26 -    assert threshold > 0 and threshold < num_players
    1.27 +    assert threshold >= 0 and threshold < num_players, "Threshold out of range"
    1.28  
    1.29      coef = [secret]
    1.30      for j in range(threshold):