changeset 178:99ac425d17d3

ideal_functionality: don't print debug statements, remember secret_functions.
author Sigurd Meldgaard <stm@daimi.au.dk>
date Mon, 14 Dec 2009 15:27:08 +0100
parents 4ed3600a9448
children 00836287599e
files pysmcl/ideal_functionality.py
diffstat 1 files changed, 14 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/pysmcl/ideal_functionality.py	Mon Dec 14 15:25:56 2009 +0100
+++ b/pysmcl/ideal_functionality.py	Mon Dec 14 15:27:08 2009 +0100
@@ -9,16 +9,17 @@
 from pysmcl.runtime_sugar import runtime_sugar
 from pysmcl.bad_calls import bad_calls
 
+debug = True
+
+
 def ideal_functionality(range={}):
     def ideal_functionality_helper(f):
-        print "ideal"
         source_str = inspect.getsource(f)
         source_ast = ast.parse(source_str) # Returns a module
         function_ast = source_ast.body[0] # We want only the function
-        pysmcl.pretty_print.PrettyPrinter().visit(source_ast)
-        # We don't want recursive applications of this decorator
-        #function_ast.decorator_list.remove[0]
-        print "-"*80
+        if(debug):
+            pysmcl.pretty_print.pprint(source_ast)
+            print "-"*80
         pysmcl.compatibility_check.CompatibilityChecker().visit(function_ast)
         transform_ifs = pysmcl.secret_ifs.TransformIfs()
         pysmcl.secret_annotator.secret_analysis(function_ast)
@@ -28,14 +29,21 @@
             t = transform_ifs.visit(function_ast)
         pysmcl.secret_annotator.secret_analysis(function_ast)
         bad_calls(function_ast)
+
+        pysmcl.secret_annotator.non_compromising_functions.add(function_ast.name)
+        if(pysmcl.secret_annotator.returns_secret(function_ast)):
+            pysmcl.secret_annotator.secret_functions.add(function_ast.name)
+
         runtime_sugar(function_ast)
         t.decorator_list.pop()
 #         pysmcl.proof_burden.proof_burden(t)
-        pysmcl.pretty_print.PrettyPrinter().visit(t)
+        if(debug):
+            pysmcl.pretty_print.pprint(source_ast)
         g = f.__globals__
         env = {}
         ast.increment_lineno(t, 3)
         exec compile(ast.Module([t]), f.__code__.co_filename, "exec") in g, env
         f = env[function_ast.name]
         return inlineCallbacks(f)
+
     return ideal_functionality_helper