viff

changeset 1338:c7403cb56ace

active: Reasonable number of PRSS triples for big fields at a time.
author Marcel Keller <mkeller@cs.au.dk>
date Tue, 27 Oct 2009 19:25:33 +0100
parents 568f9c696979
children 99ae184a2674
files viff/active.py
diffstat 1 files changed, 6 insertions(+), 2 deletions(-) [+]
line diff
     1.1 --- a/viff/active.py	Tue Oct 27 11:43:37 2009 +0100
     1.2 +++ b/viff/active.py	Tue Oct 27 19:25:33 2009 +0100
     1.3 @@ -19,6 +19,8 @@
     1.4  
     1.5  from math import ceil
     1.6  
     1.7 +from gmpy import numdigits
     1.8 +
     1.9  from twisted.internet.defer import gatherResults, Deferred, succeed
    1.10  
    1.11  from viff import shamir
    1.12 @@ -419,7 +421,7 @@
    1.13          result = self.generate_triples(field, quantity=1, gather=False)
    1.14          return result[0]
    1.15  
    1.16 -    def generate_triples(self, field, quantity=20, gather=True):
    1.17 +    def generate_triples(self, field, quantity=1, gather=True):
    1.18          """Generate *quantity* multiplication triples using PRSS.
    1.19  
    1.20          These are random numbers *a*, *b*, and *c* such that ``c =
    1.21 @@ -428,7 +430,9 @@
    1.22          Returns a tuple with the number of triples generated and a
    1.23          Deferred which will yield a singleton-list with a 3-tuple.
    1.24          """
    1.25 -        quantity = min(quantity, 20)
    1.26 +
    1.27 +        # This adjusted to the PRF based on SHA1 (160 bits).
    1.28 +        quantity = min(quantity, max(int(160 /numdigits(field.modulus - 1, 2)), 1))
    1.29  
    1.30          a_t = self.prss_share_random_multi(field, quantity)
    1.31          b_t = self.prss_share_random_multi(field, quantity)