Implementation of the Binary Random Number Generator Using the Knight Tour Problem

A random number can be defined as a set of numbers produced by a numerical function, in which the next number is unpredictable and a relationship between successive occurrences is lacking. Moreover, these sequences cannot be reproduced unless the same generator function with an exact initial value is used. The design of a random number generator must overcome the previous problems of a low periodic and the capacity to reproduce the same sequence. This paper proposes the knight tour as a tool for generating pseudo random numbers. These random numbers can be use in the encryption process or in a password generator for network administrators. The randomness test suite is used to ensure the randomness of outcome sequences. Roughly, 75% of the test results obtained is better than the results from other works. The statistical properties and security analysis indicate that the knight tour application is highly successful in generating a pseudo random number with good statistical results, high linear complexity and strong capacity to withstand attacks.


Introduction
Random numbers are widely used for many applications, such as keys for encryption and decryption, numerical analysis, simulating and modelling, as well as for selecting random samples from larger data sets (Li, 2012;Mahmood & Rahim, 2014;Tong, Liu, Zhang, Xu, & Wang, 2015).A random number can be generated by measuring random physical phenomena, such as temperature, wind speed and sunlight level.This type of generator is called a true random number generator (TRNG).TRNG requires additional equipment to produce random numbers and lacks the capacity to regenerate the same sequence unless the same initial key is used.It hardly ever regenerates the same random sequence because the sequence produced comes from the natural particular physical phenomenon.Another type of generator, called pseudorandom number generator (PRNG), uses mathematical algorithms to generate the random numbers.PRNG is more suitable for generating crypto keys because it is capable of regenerating the same random sequence and additional equipment to obtain the initial seed is unnecessary.PRNGs are also periodic generators, that is, they regenerate the same sequence after a certain round.
Generators for random numbers are characterized by several general properties.Firstly, they cannot predict the next number in the sequence.Secondly, the appearance probability of any element in the sequence is equal to other elements in the same sequence.Thirdly, the random sequence cannot be reproduced unless the same initial value is used (Rahman et al., 2014).Several methods for generating random numbers can be employed, such as genetic algorithms, neural networks and shift registers (Dubrova, Naslund, & Selander, 2014;Hrdy, Prazan, & Holoubek, 2014;Shenoy, Srikanth, & Srinivas, 2013;Toso & Resende, 2014).
The proposed method generates a pseudo binary random number sequence by implementing the knight tour problem.The knight tour problem is a mathematical problem involving the identification of a sequence of moves of a knight (on a chessboard) based on the knight movement rule in a chess game.The produced sequence is tested with a statistical test suite and security analysis is performed to verify that such sequence meets the specification of random numbers.The obtained results indicate that the proposed method could successfully generate pseudo random numbers with good statistical and security properties and high linear complexity.
This paper is organized into several sections.Section 2 briefly examines previous works on random number generators.Section 3 provides a detailed explanation of knight tour.Section 4 provides the general definition of random numbers.Section 5 describes the statistical tests.Section 6 discusses the proposed system.Section 7 details the experimental results.Finally, Section 8 presents the conclusions.

Related Works
Several methods for generating random number have been proposed indecent years.Most of the methods were implemented in hardware rather than software (De Schryver et al., 2012;VishnuRaj & Yuvaraj, 2014).These methods provide a maximum periodic of random sequence and high throughput rate while adhering to established statistical standards by applying a seeding mechanism.To generate random numbers, previous generator shave used prime number theory (Kumar & Dhiman, 2015), audio and video sources (Chen, 2013), mouse motion and one-dimensional chaotic map (Hu, Liu, & Ding, 2013;Liu, Yang, Zhang, & Du, 2014), biometric feature of human iris (Taherdoost, Chaeikar, Jafari, & Shojae Chaei Kar, 2013) and even the contents of input/output buffers (Pardo, 2012).
However, most of these methods require large initial values to start (Chen, 2013;Deng, Hu, Xiong, Xiong, & Liu, 2015).This requirement is undesirable if the generator is used to produce cryptography keys.In the management of cryptographic keys, in which these keys need to be exchanged between sender and recipient, a large initial key will require additional efforts or resources to be sent; this requirement slows down delivery and spurs security problems.Furthermore, not all of the previous generators are 're-generate able' (Hu et al., 2013;Xingyuan et al., 2012).
When a key sequence must be reproduced, the same initial value has to be used.Hence, generators that depend on a physical initial seed (i.e.wind speed and temperature) would be incapable of regenerating the same key sequence because the same initial value is impossible to obtain.Moreover, some of the previous generators fail in randomness statistical tests because the generated sequences are insufficiently random (Pashley, 2014).To overcome these issues and obtain a good random sequence, this paper proposes the use of the knight tour problem, which is described in detail in the next sections.

Knight Tour
Knight tour is an arithmetical problem relating to a knight's move on a chessboard.The knight is positioned on an empty board and peddling according to the rules of the knight moves in a chess game, where each square must be visited exactly once (Elkies, Stanley, Kleber, & Vakil, 2003).Five sets of moves are possible for the knight according to its position on the chessboard, as illustrated in Figure1.If the knight is at the corner of the chessboard, then it can be moved to two positions, as shown in Figure1 (a).The nearer the knight's position in the centre, the more choices of movements it has, as depicted in Figures 1(b), (c) and (d).All of the possible movements can be expressed in a single representation, as demonstrated in Figure1 (e).The precise number of moves in an open tour remains unidentified, whereas the number of moves in a closed tour can be approximately determined by the number of moves in an equal chessboard size (n × n) (Gusfield, 1997;Löbbing & Wegener, 1996).Furthermore, researchers have suggested several methods for identifying the knight moves in an unequal chessboard (n × m) (Pampara, 2012).This type of generation can be classified into a 2 3 4 4 4 4 3 2   3 4 6 6 6 6 4 3   4 6 8 8 8 8 6 4   4 6 8 8 8 8 6 4   4 6 8 8 8 8 6 4   4 6 8 8 8 8 6 4   3 4 6 6 6 6 4 3   2 3 4 4 4 4 3 2 (e) deterministic random number generator (Blum, Blum, & Shub, 1986).

Random Numbers
The sequence of numbers can be called a random number if the numbers lack a relationship with one other, and the possibility of appearance is equal to all of the sequence numbers (Barker & Kelsey, 2007).
Two fundamental methods are used in generating random numbers.The first method, called non-deterministic, depends on physical processes that are changeable; these processes include radioactive decay, thermal noise, transistor noise, computer clock, keyboard and mouse movements.The second method computes random bits using an algorithm; this class of random bit generator is known as deterministic random bit generator (Armknecht, Maes, Sadeghi, Standaert, & Wachsmann, 2011).
Table 1.General Properties of Random Number Generator

Property Description
Impervious An attacker who is aware of a portion of the input to the generator should be unable to use this information to recover the generator's state.

Opposing
An attacker who is able to feed a chosen input to the generator should be unable to influence its state in any predictable manner.

Resistant to analysis
An attacker who recovers a portion of the generators output; should be unable to recover any other generator state information from this.

Protect internal state
A generator should take steps to protect its internal state to ensure that it cannot recover through techniques.

Unequivocal for any activities
Explicit any actions such as extracting data in order to allow the conformance of the code to the generator design for easily checked.

Information leakage
Any leakage of internal states that would allow an attacker to predict further generator output should be regard as a catastrophic failure of the generator.

Tests
Perform any viable tests on the generated sequence to ensure that it is not producing bad output or is stuck in a cycle and repeatedly producing the same output.

Randomness Statistical Tests
Many tests can be applied to measure the randomness strength in the generated sequence (Fernández, Quintas, Sánchez, & Arias, 2015;Zhou, Liao, Wong, Hu, & Xiao, 2009).A binary string can be considered a random stream if no observable relationship exists between the individual bits of the sequence.The sequence generated by any algorithm should not be periodic (i.e.recurring at intervals of time).Sequences that are periodic cannot be regarded as true random sequences, but pseudorandom sequences (Abdulbari Ali, 2005;Pareschi, Setti, & Rovatti, 2010).
The NIST-SP-800-22 test suite is used in this work because it is one of the most extensively employed inspection standards thus far; moreover, this test suite can be applied on a binary sequence.This test contains 15 methods.The value of each test is named as P-value, which represents the degree of randomness of the tested binary sequence.A P-value larger than 0.01 indicates that the sequence passes the test, and is thus considered a random sequence (Rukhin et al., 2013).

Proposed System
From a functional viewpoint, the proposed system will apply the knight's tour problem as a tool for generating a pseudo random number that can be used as an encryption key or password generator.Several randomness tests are also used to verify the randomness strength of the numbers produced.The proposed work is presented in Figure 3.The above figure represents the main steps for generating a random number.Three steps are applied for the generating process; these steps can be described as the following, choosing initial position on the chessboard and consider it as a seed for the generator.Apply the knight tour to fill the chessboard with the different moves.Then convert the sets of moves to binary number and tests them during statistical tests.
The following steps are under taken in the proposed work and describe the detail descriptions of the implementation of the proposed method, all which explained in figure 4, which represents the pseudo code of the proposed method:

Experiment Results and Discussion
The process of generating random numbers begins with the specification of the start cell of the knight in an 8 × 8 chessboard.The generated tour is an open tour because the end cell is not in the same position as that of the start cell.Each run can generate 64 random numbers, and these numbers can subsequently become a 512-bit number when converted to a binary format.Figure 5 illustrates the sequence of generating the random binary bits.The implementation of the proposed method explained in previous figure, where this figure describes the details descriptions of the generating steps.While choosing the initial position and then generating the knight moves to fill the chess board then convert these moves to binary sequence.

Statistical Analysis
For the statistical analysis, 10 set of pseudo random numbers are tested.The sets of numbers consist of 512 random bits for each set generated by the proposed method.The generated binary sequence by the proposed method passes the NIST-SP-800-22 (Rukhin et al., 2013) test suite.Table 2 and Figure   The result value obtained from each test represents the degree of randomness of the tested sequence.A value larger than 0.01 indicates that this sequence passes the test, and the sequence is considered a random number sequence (Rukhin et al., 2013).All of the results presented in Table 2 are larger than 0.01; thus, all 10 sequences can be regarded as random.However, the frequency test results shown in Table 2 are the same in all 10 sets of the generated sequences.This result occurs because the binary bits are generated from the same set of integer numbers, but with different positions in each set.Hence, the number of ones and zeroes will be equal in all sets, but a different consequence of zeroes and ones will emerge.In addition, the low values of the frequency test and nearness to the failure condition may be attributed to the process of converting the decimal numbers to a binary system.Each decimal number is equal to 8 bits in a binary system; by contrast, decimal numbers smaller than 64 indicate that most bits in any converted number are equal to zero.Consequently, the number of zeroes is higher than the number of ones in the generated binary sequence.
After proving that the proposed generator is a random generator with good statistical properties, the advantage of this generator over the other generators should be demonstrated through a comparison of the results with those of previous works.As illustrated in Table 3, the comparison between the average of the 10 generated sequences using the proposed generator and four different generators indicates that they all use NIST-SP-800-22 as a random test method.3 shows a comparison between the average results of the 10 random sets generated by the proposed method and four binary random generation methods (Tong et al., 2015), (Hu et al., 2013), (Deng et al., 2015)and (Zhou et al., 2009), respectively.All of these methods use NIST-SP-800-22 as a random testing suite.A comparison of the items in Table 3 suggests that several items of the proposed generator exhibit better results than those of the other four generators.This result is attributed to the dependence of the works of the pass tests on blocks, in which the probability of the occurrence of the redundancy of the block is extremely low against other tests whose works depend on the probability of bit occurrence.The proposed method clearly achieves the goal of generating random numbers with good statistical results compared with the other examined generators.However, the frequency test values do not meet the perfect value as explained in the preceding discussion of results.

Security Analysis
An excellent generator method must be robust against several types of cryptanalytic, statistical and brute force attacks.Different types of analysis are applied to measure the strength of the proposed generator method against different decryption trials, as described in the subsequent section.

Key Space Analysis
The size of the key space represents the overall number of keys used for encryption.A direct relationship exists between key space size and security.A proficient encryption method must have a large key space (i.e.approximately larger than 2 100 ) to render brute force attacks infeasible (Alvarez & Li, 2006).In the proposed generator, each round can generate 512 random bits from different 64 decimal numbers; the total number of different keys is equal to 2 512 ≈ 1.34 × 10 154 ; thus, this key space is sufficiently large for resisting all forms of brute force attack.

Key Sensitivity Analysis
Key sensitivity is examined by selecting a set of keys and performing a small alteration on it to produce new keys; the differences between these two sets are subsequently computed.For a good encryption algorithm, key sensitivity should be more than 50% (Saranya, Mohan, & Anusudha, 2014).The testing conducted in this work shows a variance ratio of approximately 62%, even if the change is small.The good results from this analysis indicate that the selected plain text attacks and linear cryptanalysis do not influence the generated keys; consequently, the encryption algorithm is unaffected.

Linear Complexity Analysis
The linear complexity of algorithm concerned on how fast or slow for particular performs.In the proposed generator can be defined as a slight recurrence in linear feedback shift register (LFSR) to generate the random sequences.A proficient Berlekamp-Massey algorithm of linear complexity is proposed in (Eidelman & Gohberg, 1997).

Figure 6. Linear Complexity Analyses
This algorithm computes the smallest LFSR.The results obtained from this analysis are presented in Figure 6, where the linear complexity is near the ideal values, thereby indicating that the generated sequences exhibit a linear complexity against different types of attack.

Conclusions
This paper has designed and tested the use of the knight tour algorithm as a pseudo random number generator; this process was achieved in two steps.Firstly, a knight move sequence was generated to fill an 8 × 8 chessboard, and these numbers were considered pseudo random numbers.Secondly, the NIST test suite was used in checking randomness and in considering the criteria of accepted randomness.The original goal was clearly achieved by solving most of the difficulties encountered by the generator designers of small initial value and not depending on the physical seed.The statistical tests and security analysis demonstrate that the proposed system is highly successful in generating pseudo random numbers with good statistical properties, large key space and resistance to various types of attacks.The proposed system can be used for generating cryptographic keys, as password generator, game key generator and probability in mathematics.

Figure 1 .
Figure 1.Different Knight Moves in a Chess Game, (a) Corner Position (b) Top Position (c) Semi-Top Position (d) Centre Position

Figure 2 .
Figure 2. Two Strategies of Knight Moves in a Chess Game

Figure 3 .
Figure 3. Flowchart of the Proposed System

Figure 4 .
Figure 4.The pseudo code of the Proposed method

Figure 5 .
Figure 5. Generating Sequence: (a) Select an initial position (b) Knight moves to fill the chessboard (c) Save the moves in an external file (d) Convert to a binary format 5 demonstrate the results obtained from the tests.

Table 3 .
Comparison of the Proposed NIST Test Results and the Results of Others Works