scyther/spdl/multiparty/test-variants.py

78 lines
1.7 KiB
Python
Raw Normal View History

#!/usr/bin/python
#
#
2005-07-05 10:54:00 +01:00
# Idea:
#
# We test all variants [0..31] until we are sure they work. Thus,
# we slowly refine the tests.
#
import commands
def startset():
return range(0,32)
2005-08-12 14:52:38 +01:00
mainlist = [11, 15]
print "Starting with", mainlist
return mainlist
def tuplingchoice(variant,P,runs,latupling):
# variant is in range [0..64>,
# where we use the highest bid to signify the
# associativity of the tupling.
extraflags = ""
if latupling:
extraflags += " --la-tupling"
s = "./multinsl-generator.py"
2005-07-05 10:54:00 +01:00
s += " %i %s" % (P,variant)
s += " | scyther -a -r%i -m2 --summary %s" % (runs, extraflags)
2005-07-05 10:54:00 +01:00
#s += " | scyther -a -r%i --summary" % runs
#print s
s += " | grep \"failed:\""
out = commands.getoutput(s)
if out == "":
2005-07-05 10:54:00 +01:00
#print "Okay"
return True
else:
2005-07-05 10:54:00 +01:00
#print out
return False
def testvariant(v,p,r):
if not tuplingchoice (v,p,r, False):
return False
else:
return tuplingchoice (v,p,r, True)
2005-07-05 10:54:00 +01:00
def removeattacks (testlist, P, runs):
okaylist = []
for v in testlist:
if testvariant (v, P, runs):
okaylist.append(v)
return okaylist
def scan(testlist, P, runs):
print "Testing using P %i and %i runs." % (P,runs)
results = removeattacks (testlist, P, runs)
if len(results) < len(testlist):
attacked = []
for i in range(0,len(testlist)):
if testlist[i] not in results:
attacked.append(testlist[i])
print "Using P %i and %i runs, we find attacks on %s" % (P,runs, str(attacked))
print "Therefore, we are left with %i candidates: " % (len(results)), results
2005-07-05 10:54:00 +01:00
return results
def main():
candidates = startset()
for P in range(3,7):
for runs in range(P-1,P+3):
2005-07-05 10:54:00 +01:00
candidates = scan(candidates,P,runs)
print
print "Good variants:"
2005-07-05 10:54:00 +01:00
print candidates
main()