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 wrap: on
line diff
--- a/viff/comparison.py	Mon Mar 24 13:23:17 2008 +0100
+++ b/viff/comparison.py	Tue Mar 25 14:54:42 2008 +0100
@@ -24,6 +24,8 @@
 
 """
 
+import math
+
 from viff.util import rand
 from viff.runtime import Runtime, Share, gather_shares, increment_pc
 from viff.field import GF256, FieldElement
@@ -155,16 +157,7 @@
     @increment_pc
     def convert_bit_share(self, share, dst_field):
         """Convert a 0/1 share into dst_field."""
-
-        def log(x):
-            # TODO: Don't do log like this...
-            result = 0
-            while x > 1:
-                result += 1
-                x //= 2
-            return result+1 # Error for powers of two...
-
-        l = self.options.security_parameter + log(dst_field.modulus)
+        l = self.options.security_parameter + math.log(dst_field.modulus)
         # TODO assert field sizes are OK...
 
         this_mask = rand.randint(0, (2**l) -1)