viff

changeset 604:7bf246416d4c

Use math.log.
author Martin Geisler <mg@daimi.au.dk>
date Tue, 25 Mar 2008 14:54:42 +0100
parents 2ab7f8d9f28c
children 05c7f58fae6e
files viff/comparison.py
diffstat 1 files changed, 3 insertions(+), 10 deletions(-) [+]
line diff
     1.1 --- a/viff/comparison.py	Mon Mar 24 13:23:17 2008 +0100
     1.2 +++ b/viff/comparison.py	Tue Mar 25 14:54:42 2008 +0100
     1.3 @@ -24,6 +24,8 @@
     1.4  
     1.5  """
     1.6  
     1.7 +import math
     1.8 +
     1.9  from viff.util import rand
    1.10  from viff.runtime import Runtime, Share, gather_shares, increment_pc
    1.11  from viff.field import GF256, FieldElement
    1.12 @@ -155,16 +157,7 @@
    1.13      @increment_pc
    1.14      def convert_bit_share(self, share, dst_field):
    1.15          """Convert a 0/1 share into dst_field."""
    1.16 -
    1.17 -        def log(x):
    1.18 -            # TODO: Don't do log like this...
    1.19 -            result = 0
    1.20 -            while x > 1:
    1.21 -                result += 1
    1.22 -                x //= 2
    1.23 -            return result+1 # Error for powers of two...
    1.24 -
    1.25 -        l = self.options.security_parameter + log(dst_field.modulus)
    1.26 +        l = self.options.security_parameter + math.log(dst_field.modulus)
    1.27          # TODO assert field sizes are OK...
    1.28  
    1.29          this_mask = rand.randint(0, (2**l) -1)