viff

changeset 664:77ad363d79ae

Make generate_triples use single_share_random. It used to use prss_share_random, but this function does not scale very well when the number of players increase.
author Martin Geisler <mg@daimi.au.dk>
date Sun, 13 Apr 2008 17:46:10 +0200
parents 8f2e45ecc8b4
children 876f98730e4c
files viff/runtime.py
diffstat 1 files changed, 16 insertions(+), 13 deletions(-) [+]
line diff
     1.1 --- a/viff/runtime.py	Sun Apr 13 17:20:24 2008 +0200
     1.2 +++ b/viff/runtime.py	Sun Apr 13 17:46:10 2008 +0200
     1.3 @@ -1229,25 +1229,28 @@
     1.4          t = self.threshold
     1.5          T = n - 2*t
     1.6  
     1.7 -        # Generate normal random sharings.
     1.8 -        a_t = [self.prss_share_random(field) for _ in range(T)]
     1.9 -        b_t = [self.prss_share_random(field) for _ in range(T)]
    1.10 -        c_2t = []
    1.11 -        for i in range(T):
    1.12 -            # Multiply a[i] and b[i] without resharing.
    1.13 -            ci = gather_shares([a_t[i], b_t[i]])
    1.14 -            ci.addCallback(lambda (ai, bi): ai * bi)
    1.15 -            c_2t.append(ci)
    1.16 +        def make_triple(shares):
    1.17 +            a_t, b_t, (r_t, r_2t) = shares
    1.18  
    1.19 -        def make_triple((r_t, r_2t)):
    1.20 +            c_2t = []
    1.21 +            for i in range(T):
    1.22 +                # Multiply a[i] and b[i] without resharing.
    1.23 +                ci = gather_shares([a_t[i], b_t[i]])
    1.24 +                ci.addCallback(lambda (ai, bi): ai * bi)
    1.25 +                c_2t.append(ci)
    1.26 +
    1.27              d_2t = [c_2t[i] - r_2t[i] for i in range(T)]
    1.28              d = [self.open(d_2t[i], threshold=2*t) for i in range(T)]
    1.29              c_t = [r_t[i] + d[i] for i in range(T)]
    1.30              return zip(a_t, b_t, c_t)
    1.31  
    1.32 -        double = self.double_share_random(T, t, 2*t, field)
    1.33 -        double.addCallback(make_triple)
    1.34 -        return double
    1.35 +        single_a = self.single_share_random(T, t, field)
    1.36 +        single_b = self.single_share_random(T, t, field)
    1.37 +        double_c = self.double_share_random(T, t, 2*t, field)
    1.38 +
    1.39 +        result = gatherResults([single_a, single_b, double_c])
    1.40 +        result.addCallback(make_triple)
    1.41 +        return result
    1.42  
    1.43      @increment_pc
    1.44      def _broadcast(self, sender, message=None):