My favorites | Sign in
Project Home Downloads Wiki Issues Source
Repository:
Checkout   Browse   Changes   Clones  
Changes to /tests/test_dwbo.py
4ee4950a92b1 vs. a7887d5d8446 Compare: vs.  Format:
Revision a7887d5d8446
Go to: 
Project members, sign in to write a code review
/tests/test_dwbo.py   4ee4950a92b1 /tests/test_dwbo.py   a7887d5d8446
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 2
3 import sys, time 3 import sys, time
4 4
5 PATH_INSTALL = "./" 5 PATH_INSTALL = "./"
6 sys.path.append(PATH_INSTALL + "/core") 6 sys.path.append(PATH_INSTALL + "/core")
7 sys.path.append(PATH_INSTALL + "/core/wm") 7 sys.path.append(PATH_INSTALL + "/core/wm")
8 sys.path.append(PATH_INSTALL + "/core/analysis") 8 sys.path.append(PATH_INSTALL + "/core/analysis")
9 sys.path.append(PATH_INSTALL + "/core/bytecodes") 9 sys.path.append(PATH_INSTALL + "/core/bytecodes")
10 10
11 import misc 11 import misc
12 from wm import DWBO, DWBOCheck 12 from wm import DWBO, DWBOCheck
13 13
14 def test(obc, secret, x) : 14 def test(obc, secret, x) :
15 r = obc.verify_with_X( x ) 15 r = obc.verify_with_X( x )
16 print "%s x:%d solutions:%d" % ( secret in r, len(x), len(r) ) 16 print "%s x:%d solutions:%d" % ( secret in r, len(x), len(r) )
17 17
18 18
19 SECRET = "ANDROGUARD" 19 SECRET = "ANDROGUARD"
20 J1 = [ 2, 3, 4, 5, 6 ] 20 J1 = [ 2, 3, 4, 5, 6 ]
21 J2 = [ 2, 3, 6, 20, 40, 1, 30, 15, 25, 10 ] 21 J2 = [ 2, 3, 6, 20, 40, 1, 30, 15, 25, 10 ]
22 22
23 T = [ 23 T = [
24 [ 2, 3, 6, 20, 40, 1, 30, 15, 25, 10, 40 ], 24 [ 2, 3, 6, 20, 40, 1, 30, 15, 25, 10, 40 ],
25 [ 98364, 846388, 114078, 504558, 838754, 118930, 941266, 582751, 968751, 946943 ], 25 [ 98364, 846388, 114078, 504558, 838754, 118930, 941266, 582751, 968751, 946943 ],
26 [ 169402, 307842, 140128, 204405, 815962, 639408, 748573, 131504, 844589, 32945 ], 26 [ 169402, 307842, 140128, 204405, 815962, 639408, 748573, 131504, 844589, 32945 ],
27 [ 6, 5, 4, 3, 2 ], 27 [ 6, 5, 4, 3, 2 ],
28 ] 28 ]
29 29
30 ob = DWBO( SECRET, J1 ) 30 ob = DWBO( SECRET, J1 )
31 secret_long = misc.str2long(ob.get_secret()) 31 secret_long = misc.str2long(ob.get_secret())
32 print "%s %d --> threshold:%d y:%s" % ( ob.get_secret(), secret_long, ob.get_threshold(), ob.get_y() ) 32 print "%s %d --> threshold:%d y:%s" % ( ob.get_secret(), secret_long, ob.get_threshold(), ob.get_y() )
33 33
34 obc = DWBOCheck( ob.get_y(), ob.get_threshold() ) 34 obc = DWBOCheck( ob.get_y(), ob.get_threshold() )
35 35
36 t1 = time.clock() 36 t1 = time.clock()
37 for i in T : 37 for i in T :
38 test(obc, secret_long, i) 38 test(obc, secret_long, i)
39 t2 = time.clock() 39 t2 = time.clock()
40 print t2 - t1 40 print t2 - t1
Powered by Google Project Hosting