viff

changeset 747:18ef1b1ca1e1

Function to convert replicated shares to Shamir shares.
author Martin Geisler <mg@daimi.au.dk>
date Tue, 13 May 2008 13:46:20 +0200
parents e54784ca4f46
children fac2d1f8dbe1
files viff/prss.py
diffstat 1 files changed, 17 insertions(+), 10 deletions(-) [+]
line diff
     1.1 --- a/viff/prss.py	Tue May 13 13:37:54 2008 +0200
     1.2 +++ b/viff/prss.py	Tue May 13 13:46:20 2008 +0200
     1.3 @@ -66,6 +66,21 @@
     1.4      # the subset before using it.
     1.5      return [(s, prf(key)) for (s, prf) in prfs.iteritems() if j in s]
     1.6  
     1.7 +def convert_replicated_shamir(n, j, field, rep_shares):
     1.8 +    """Convert a set of replicated shares to a Shamir share.
     1.9 +
    1.10 +    The conversion is done for player *j* (out of *n*) and will be
    1.11 +    done over *field*.
    1.12 +    """
    1.13 +    result = 0
    1.14 +    all = frozenset(range(1, n+1))
    1.15 +    for subset, share in rep_shares:
    1.16 +        points = [(field(x), 0) for x in all-subset]
    1.17 +        points.append((0, 1))
    1.18 +        f_in_j = shamir.recombine(points, j)
    1.19 +        result += share * f_in_j
    1.20 +    return result
    1.21 +
    1.22  def prss(n, j, field, prfs, key):
    1.23      """Return a pseudo-random secret share for a random number.
    1.24  
    1.25 @@ -90,16 +105,8 @@
    1.26      We see that the sharing is consistent because each subset of two
    1.27      players will recombine their shares to ``{24}``.
    1.28      """
    1.29 -    result = 0
    1.30 -    all = frozenset(range(1, n+1))
    1.31 -    for subset, share in random_replicated_sharing(j, prfs, key):
    1.32 -        points = [(field(x), 0) for x in all-subset]
    1.33 -        points.append((0, 1))
    1.34 -        f_in_j = shamir.recombine(points, j)
    1.35 -        result += share * f_in_j
    1.36 -
    1.37 -    return result
    1.38 -
    1.39 +    rep_shares = random_replicated_sharing(j, prfs, key)
    1.40 +    return convert_replicated_shamir(n, j, field, rep_shares)
    1.41  
    1.42  def generate_subsets(orig_set, size):
    1.43      """Generates the set of all subsets of a specific size.