You are on page 1of 1

In 

[11]: N = 10; # number of nodes + 1

minConnect = 4;

maxConnect = 10;

"checky" checks the possibility for a jump between two non-adjacent nodes

In [12]: def checky(visit,inp):

if isinstance(inp, list):

return sum(visit[i] == maxVisit for i in inp) == 3

else:

return visit[inp] == maxVisit

"totalPatternFromCur" finds total pattern starting from current cell

In [13]: def totalPatternFromCur(visit, jump, cur, toTouch,maxVisit):

if (toTouch <= 0):

if (toTouch == 0):

return 1;

else:

return 0;

ways = 0;

visit[cur] += 1;

for i in range(1, N):

if (visit[i] < maxVisit and (jump[i][cur] == 0 or checky(visit,jump[i][cur]))):

ways += totalPatternFromCur(visit, jump, i, toTouch - 1,maxVisit);

visit[cur] -= 1;

return ways;

"waysOfConnection" returns number of pattern with minimum 'm' and maximum 'n'
connections

In [14]: def waysOfConnection(jump,m, n, maxVisit):

visit = [0]*N;

return sum(totalPatternFromCur(visit, jump,j,i-1,maxVisit) for i in range(m, n + 1) for


j in range(1,n))

Note: One can also take advantage of the symmetry associated with a given network

Below is the illustration associated with the classic mobile lock pattern

1, 3, 7, 9 are symmetric so multiplying by 4

ways += 4 * totalPatternFromCur(visit, jump, 1, i - 1);

2, 4, 6, 8 are symmetric so multiplying by 4

ways += 4 * totalPatternFromCur(visit, jump, 2, i - 1);

ways += totalPatternFromCur(visit, jump, 5, i - 1);

Jump matrix for classic mobile lock pattern problem

Mentioned although not relevant due to its profound relevance to the problem statement in Q2

In [15]: jump_android = [[0 for i in range(N)] for j in range(N)];

# 2 lies between 1 and 3

jump_android[1][3] = jump_android[3][1] = 2;

# 8 lies between 7 and 9

jump_android[7][9] = jump_android[9][7] = 8;

# 4 lies between 1 and 7

jump_android[1][7] = jump_android[7][1] = 4;

# 6 lies between 3 and 9

jump_android[3][9] = jump_android[9][3] = 6;

# 5 lies between 1, 9 2, 8 3, 7 and 4, 6

jump_android[1][9] = jump_android[9][1] = jump_android[2][8] = jump_android[8][2] = jump_and


roid[3][7] = jump_android[7][3] = jump_android[4][6] = jump_android[6][4] = 5;

In [16]: jump_a = [[0 for i in range(N)] for j in range(N)];

# 2 lies between 1 and 3

jump_a[1][3] = jump_a[3][1] = 2;

# 4 lies between 3 and 5

jump_a[3][5] = jump_a[5][3] = 4;

# 6 lies between 3 and 7

jump_a[3][7] = jump_a[7][3] = 6;

In [17]: jump_b = [[0 for i in range(N)] for j in range(N)];

In [18]: jump_c = [[0 for i in range(N)] for j in range(N)];

# 2 lies between 1 and 3

jump_c[1][3] = jump_c[3][1] = 2;

# 2,3 lies between 1 and 4

jump_c[1][4] = jump_c[4][1] = [2,3];

# 2,3,4 lies between 1 and 5

jump_c[1][5] = jump_c[5][1] = [2,3,4];

# 7 lies between 3 and 6

jump_c[3][6] = jump_c[6][3] = 7;

# 3,7 lies between 6 and 8

jump_c[6][8] = jump_c[8][6] = [3,7];

# 3,7,8 lies between 6 and 9

jump_c[6][9] = jump_c[9][6] = [3,7,8];

a) If a dot can be used only once

In [24]: maxVisit_a = 1

print("Total possible permutations for the classic mobile lock pattern = ",waysOfConnection(
jump_android, minConnect, maxConnect,maxVisit_a),end = "\n\n")

print("Total possible permutations for Pattern 'a' = ",waysOfConnection(jump_a, minConnect,


maxConnect,maxVisit_a),end = "\n\n")

print("Total possible permutations for Pattern 'b' = ",waysOfConnection(jump_b, minConnect,


maxConnect,maxVisit_a),end = "\n\n")

print("Total possible permutations for Pattern 'c' = ",waysOfConnection(jump_c, minConnect,


maxConnect,maxVisit_a),end = "\n\n")

Total possible permutations for the classic mobile lock pattern = 389112

Total possible permutations for Pattern 'a' = 690240

Total possible permutations for Pattern 'b' = 985824

Total possible permutations for Pattern 'c' = 343464

b) If a dot can be used twice

In [25]: %%time

maxVisit_b = 2

print("Total possible permutations for the classic mobile lock pattern = ",waysOfConnection(
jump_android, minConnect, maxConnect,maxVisit_b),end = "\n\n")

print("Total possible permutations for Pattern 'a' = ",waysOfConnection(jump_a, minConnect,


maxConnect,maxVisit_b),end = "\n\n")

print("Total possible permutations for Pattern 'b' = ",waysOfConnection(jump_b, minConnect,


maxConnect,maxVisit_b),end = "\n\n")

print("Total possible permutations for Pattern 'c' = ",waysOfConnection(jump_c, minConnect,


maxConnect,maxVisit_b),end = "\n\n")

Total possible permutations for the classic mobile lock pattern = 379054512

Total possible permutations for Pattern 'a' = 834071040

Total possible permutations for Pattern 'b' = 1317699144

Total possible permutations for Pattern 'c' = 372248772

Wall time: 20min 47s

c) One cannot conclude that higher the possible permutations for a pattern higher is the security level based on our
following arguments:

Given a sample dusted with fingerprint powder (prepared via any mode), one could heist an information extraction attack
via several available image processing techniques that discerns the password input of a touchscreen device such as a cell
phone or tablet computer from fingerprint smudges. It is least probable that one directly arrive at the correct password rather
one could (at best case) arrive at the correct nodes and edges between them in the target password. If the pattern involves lot
of jumping restrictions (associated with points lying in a straight line), one could easily crack the password since the number
of possible passwords that could be generated with the hints about nodes and edges will be relatively less (thus decreasing
the security level) than a pattern with very less jumping restrictions that has a better security level.

Increasing order of security level: c < a < b


Comments:

'c' has higher degree of jumping restrictions ie., 5 points lying in two straight lines!
'a' has three sets of three points in a line and two free points
'b' has no jumping restrictions ie., every nine point is a free point which means there is no restriction to go from one point
to any point in the pattern

You might also like