Mercurial > pysmcl
changeset 344:54b28b30f310
Changed name of setup.py to be compatible with nosetests
author | Sigurd Meldgaard <stm@daimi.au.dk> |
---|---|
date | Mon, 19 Jul 2010 15:11:56 +0200 |
parents | ebbb77e339f8 |
children | 4f53fe56b5de |
files | pysmcl/editor_info.py pysmcl/functions.py pysmcl/range_analysis.py pysmcl/secret_ifs.py pysmcl/setup.py pysmcl/setup_env.py pysmcl/test/unit/test_proof_burden.py pysmcl/test/unit/test_secret_ifs.py |
diffstat | 8 files changed, 32 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/pysmcl/editor_info.py Wed Jul 07 16:28:23 2010 +0200 +++ b/pysmcl/editor_info.py Mon Jul 19 15:11:56 2010 +0200 @@ -1,15 +1,14 @@ import sys import pysmcl.ast_wrapper as ast -import pysmcl.setup import pysmcl.pretty_print as pp -from pysmcl.range_analysis import RangeAnalysis from pysmcl.secret_annotator import secret_analysis, expr_secret import pysmcl.secret_ifs as secret_ifs from pysmcl.util import error from pysmcl.bad_calls import bad_calls from pysmcl.ideal_functionality import transform_ifs_fixpoint + def main(): try: prog = ast.parse(file(sys.argv[1]).read())
--- a/pysmcl/functions.py Wed Jul 07 16:28:23 2010 +0200 +++ b/pysmcl/functions.py Mon Jul 19 15:11:56 2010 +0200 @@ -1,5 +1,5 @@ from twisted.internet.defer import inlineCallbacks -import pysmcl.setup +import pysmcl.setup_env as setup from random import randint def input(runtime, prompt, player, lower, upper): @@ -13,9 +13,9 @@ # a = randint(lower, upper);print "chose %d for you!" % a if(a < lower or a >= upper): raise RuntimeError("Invalid value shared") - return runtime.shamir_share([player], pysmcl.setup.Zp, a) + return runtime.shamir_share([player], setup.Zp, a) else: - return runtime.shamir_share([player], pysmcl.setup.Zp) + return runtime.shamir_share([player], setup.Zp) def precondition(args): pass @@ -27,10 +27,10 @@ return runtime.id def random(runtime): - return runtime.prss_share_random(pysmcl.setup.Zp) + return runtime.prss_share_random(setup.Zp) def random_bit(runtime): - return runtime.prss_share_random(pysmcl.setup.Zp, True) + return runtime.prss_share_random(setup.Zp, True) def result(x): """Just the id function, marks results for the verifier"""
--- a/pysmcl/range_analysis.py Wed Jul 07 16:28:23 2010 +0200 +++ b/pysmcl/range_analysis.py Mon Jul 19 15:11:56 2010 +0200 @@ -8,7 +8,7 @@ import numbers import pysmcl.ast_wrapper as ast from pysmcl import flow -import pysmcl.setup as setup +import pysmcl.setup_env as setup # Switch to True for debug output printed to std. out. debug = False
--- a/pysmcl/secret_ifs.py Wed Jul 07 16:28:23 2010 +0200 +++ b/pysmcl/secret_ifs.py Mon Jul 19 15:11:56 2010 +0200 @@ -7,7 +7,6 @@ import pysmcl.ast_wrapper as ast import pysmcl.secret_annotator -import pysmcl.setup from pysmcl.range_analysis import RangeVisitor, Range from pysmcl.util import error
--- a/pysmcl/setup.py Wed Jul 07 16:28:23 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,5 +0,0 @@ -from viff.field import GF -from viff.util import find_prime - -num_players=3 -Zp = GF(find_prime(2**64, blum=True))
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pysmcl/setup_env.py Mon Jul 19 15:11:56 2010 +0200 @@ -0,0 +1,5 @@ +from viff.field import GF +from viff.util import find_prime + +num_players=3 +Zp = GF(find_prime(2**64, blum=True))
--- a/pysmcl/test/unit/test_proof_burden.py Wed Jul 07 16:28:23 2010 +0200 +++ b/pysmcl/test/unit/test_proof_burden.py Mon Jul 19 15:11:56 2010 +0200 @@ -33,8 +33,8 @@ def test_nothing(self): r = do_proof_burden(\ """def f(): - y = input("x",1,0,1) - result(y) + x = input("x",1,0,1) + result(x) """) expected = """For the function: f Nothing has to be proved @@ -44,7 +44,7 @@ def test_input(self): r = do_proof_burden(\ """def f(): - y = input("x",1,0,1) + x = input("x",1,0,1) y = output(x) z = input("a",1,0,1) result(y) @@ -55,3 +55,20 @@ From: """ self.assertEquals(r, expected) + + def test_if(self): + r = do_proof_burden(\ +"""def f(): + x = input("x",1,0,1) + y = output(x) + if(y): + result(y) +""") + expected = """For the function: f + Show that you can compute: + The value of x in line 3 + From: +""" + print r + print expected + self.assertEquals(r, expected)
--- a/pysmcl/test/unit/test_secret_ifs.py Wed Jul 07 16:28:23 2010 +0200 +++ b/pysmcl/test/unit/test_secret_ifs.py Mon Jul 19 15:11:56 2010 +0200 @@ -1,5 +1,4 @@ import unittest -import pysmcl.setup from pysmcl.range_analysis import RangeAnalysis from pysmcl.ast_wrapper import parse from pysmcl.pretty_print import pprint_string