viff

changeset 645:ed0992a4915d

Method for generating multiplication triples.
author Martin Geisler <mg@daimi.au.dk>
date Sat, 05 Apr 2008 00:00:24 +0200
parents cc58a62d507c
children 89187d5b7d6a
files viff/runtime.py
diffstat 1 files changed, 30 insertions(+), 0 deletions(-) [+]
line diff
     1.1 --- a/viff/runtime.py	Sat Apr 05 00:00:24 2008 +0200
     1.2 +++ b/viff/runtime.py	Sat Apr 05 00:00:24 2008 +0200
     1.3 @@ -1003,6 +1003,36 @@
     1.4          # the verifying step.
     1.5          return rvec1.rows[0][:T], rvec2.rows[0][:T]
     1.6  
     1.7 +    def generate_triples(self, field):
     1.8 +        """Generate multiplication triples.
     1.9 +
    1.10 +        These are random numbers M{a}, M{b}, and M{c} such that M{c =
    1.11 +        ab}.
    1.12 +
    1.13 +        @return: C{list} of 3-tuples.
    1.14 +        @returntype: C{list} of C{(Share, Share, Share)}
    1.15 +        """
    1.16 +        n = self.num_players
    1.17 +        t = self.threshold
    1.18 +        T = n - 2*t
    1.19 +
    1.20 +        # Generate normal random sharings.
    1.21 +        a_t = [self.prss_share_random(field) for _ in range(T)]
    1.22 +        b_t = [self.prss_share_random(field) for _ in range(T)]
    1.23 +        c_2t = []
    1.24 +        for i in range(T):
    1.25 +            # Multiply a[i] and b[i] without resharing.
    1.26 +            ci = gather_shares([a_t[i], b_t[i]])
    1.27 +            ci.addCallback(lambda (ai, bi): ai * bi)
    1.28 +            c_2t.append(ci)
    1.29 +
    1.30 +        r_t, r_2t = self.double_share_random(T, t, 2*t, field)
    1.31 +        d_2t = [c_2t[i] - r_2t[i] for i in range(T)]
    1.32 +        d = [self.open(d_2t[i], threshold=2*t) for i in range(T)]
    1.33 +        c_t = [r_t[i] + d[i] for i in range(T)]
    1.34 +
    1.35 +        return zip(a_t, b_t, c_t)
    1.36 +
    1.37      @increment_pc
    1.38      def _broadcast(self, sender, message=None):
    1.39          """Perform a Bracha broadcast.