viff

changeset 629:31d157dedca9

Add a threshold argument to shamir_share.
author Martin Geisler <mg@daimi.au.dk>
date Mon, 31 Mar 2008 13:48:03 +0200
parents a444dd00be4c
children d497fab5e1ec
files viff/runtime.py
diffstat 1 files changed, 8 insertions(+), 3 deletions(-) [+]
line diff
     1.1 --- a/viff/runtime.py	Sat Mar 29 21:05:21 2008 +0100
     1.2 +++ b/viff/runtime.py	Mon Mar 31 13:48:03 2008 +0200
     1.3 @@ -896,20 +896,25 @@
     1.4          return result
     1.5  
     1.6      @increment_pc
     1.7 -    def shamir_share(self, inputters, field, number=None):
     1.8 +    def shamir_share(self, inputters, field, number=None, threshold=None):
     1.9          """Secret share C{number} over C{field} using Shamir's method.
    1.10  
    1.11 -        Returns a list of shares.
    1.12 +        The number is shared using polynomial of degree C{threshold}
    1.13 +        (defaults to L{self.threshold}). Returns a list of shares
    1.14 +        unless unless there is only one inputter in which case the
    1.15 +        share is returned directly.
    1.16  
    1.17          Communication cost: n elements transmitted.
    1.18          """
    1.19          assert number is None or self.id in inputters
    1.20 +        if threshold is None:
    1.21 +            threshold = self.threshold
    1.22  
    1.23          results = []
    1.24          for peer_id in inputters:
    1.25              if peer_id == self.id:
    1.26                  pc = tuple(self.program_counter)
    1.27 -                shares = shamir.share(field(number), self.threshold,
    1.28 +                shares = shamir.share(field(number), threshold,
    1.29                                        self.num_players)
    1.30                  for other_id, share in shares:
    1.31                      if other_id.value == self.id: