changeset 194:411188503c72

secret_if: use_range_within For checking the appropriateness of the range of a condition
author Sigurd Meldgaard <stm@daimi.au.dk>
date Wed, 16 Dec 2009 16:55:15 +0100
parents e603a159704a
children 06e52f99cb67
files pysmcl/secret_ifs.py
diffstat 1 files changed, 2 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/pysmcl/secret_ifs.py	Wed Dec 16 16:54:07 2009 +0100
+++ b/pysmcl/secret_ifs.py	Wed Dec 16 16:55:15 2009 +0100
@@ -8,7 +8,7 @@
 import pysmcl.ast_wrapper as ast
 import pysmcl.secret_annotator
 import pysmcl.setup
-from pysmcl.range_analysis import RangeVisitor
+from pysmcl.range_analysis import RangeVisitor, interval_within
 
 from pysmcl.util import error
 
@@ -106,7 +106,7 @@
         self.generic_visit(node)
         if(pysmcl.secret_annotator.expr_secret(node.test)):
             range_visitor = RangeVisitor(pysmcl.setup.Zp.modulus, node.in_values["range"])
-            if range_visitor.visit(node.test) != (0,1):
+            if not interval_within(range_visitor.visit(node.test), (0,1)):
                 error("The condition cannot be proven to be in the range (0, 1)", node.test)
             self.changed = True
             replacement = []