Design and Implementation of Stream Cipher Using Neural Network

The centaral problem in stream cipher cryptograph is the the difficulty to generate a long unpredicatable sequence of binary signals from short and random key. Unpredicatable sequence are desirable in cryptography because it is impossible, given a reasonable segment of its signals and computer resources, to find out more about them. Pseudorandom bit generators have been widely used to construct these sequences. The paper presents a PN sequence generator that uses neural network. Computer simulation tests have been carried out to check the randomness of the generated through statistical tests. There tests have shown the successful PN sequence generator passes all the recommended tests. The paper also proposes and validates the data encryption and decryption process using neural network instead of using traditional methods (Exclusive or). This task increases the difficulty in the breaking the cipher.


Introduction
Stream ciphers can be designed to be exceptionally fast, much faster than any block cipher.They are used in applications where plaintext comes in quantities of unknowable length, for example, a secure wireless connection (e.g.W-LAN and Bluetooth).If a block cipher were to be used in this type of application, considerable bandwidth would end up being wasted by padding, since block ciphers cannot work on blocks shorter than their block size.For example, if a 64bit block cipher received separate 32-bit bursts of plaintext, half of the data transmitted would be padding.Stream ciphers eliminate this by operating on the smallest unit that can be transmitted [1].
Further advantages of stream cipher systems are: 1-Speed of encryption/decryption: since each bit of the message is encrypted independently of other plaintext bits, each bit can be encrypted as soon as it is read.
2-Low propagation error: since each bit is encrypted and decrypted separately, decryption of a bit that have been corrupted in transmission produces an error to the one corresponding message bit and no others.
An Artificial Neural Network (ANN) is an information processing paradigm that is inspired by the way biological nervous systems, such as the brain.The key element of this paradigm is the novel structure of the information processing system.It is composed of a large number of highly interconnected processing elements (neurones) working in unison to solve specific problems.ANNs, like people, learn by example.An ANN is configured for a specific application, such as pattern recognition or data classification, through a learning process.Learning in biological systems involves adjustments to the synaptic connections that exist between the neurones [3].Researchers have also tried to use neural networks in Cryptography.In January 2002, the Physicists Kanter, Kinzel and Kanter proposeda new key exchange protocol between two parties A and B. It uses the new notion of chaotic synchronization, which makes it possible for two weakly interacting chaotic systems to converge even though each one of them (viewed individually)continues to move in a chaotic way [4].Neural network now typically have size of hundreds input and output allowing a huge mapping function to be implemented.Also the non-linearity produiced by neural network mapping is desired in cryptography.
The implementation of neural networkcan be reduced to complexity of one using existing hardwre technologies [5].

Stream Cipher
Most stream ciphers consist of a pseudorandom number generator (PRNG).For encryption the PRNG is initialized with a key and provides its output as a sequence of bits known as the (pseudo) random key stream.Randomness is very important because it completely destroys any statistically properties in the message.Key stream generators are often constructed using linear feedback shift registers (LFSR).The LFSR method is an attempt to simulate a one-time pad by generating a long key sequence from a little information.As with any such attempt, if the key is shorter than the message itself, breaking part of the ciphertext gives the cryptanalyst information about other parts of the ciphertext.For an LFSR, a known plaintext attack can reveal parts of the key sequence [1].
The key stream is combined (XOR) with the plaintext bit by bit typically by an XOR gate.To decrypt the message the ciphertext bits are XORed with the corresponding key stream bits again.So an error in a single bit of ciphertext results in a single bit of plaintext error.This is very useful when the transmission error rate is high [6].Some ciphers, called self-synchronizing stream ciphers, use several previous ciphertext bits to compute the key stream.They depend on the data and its encryption.A single-bit error will result in a long burst of garble, but the cipher will eventually recover from a lost bit after the damaged and incorrect bit falls off the shift register.The opposite are the synchronous stream ciphers, in which the key stream is generated independently of the plaintext and the ciphertext.They generate bits from a source other than the message itself.The simplest such cipher extracts bits from a register to use as the key.The contents of the register change on the basis of the current contents of the register.Most stream cipher designs are for synchronous stream ciphers [1].
The one-time pad is a form of stream cipher that can be proven secure.In this cipher each key character is randomly generated and is used only once [7].The ciphertext gives opponent no additional information on the plaintext [8].

Artificial Neural Networks
Artificial neural networks (ANNs) are highly parallel interconnections of simple processing elements or neurons that function as a collective system.There exist various problems in pattern recognition that humans seem more efficient in solving as compared to computers.Neural networks may be seen as an attempt to emulate such human performance.These networks can be broadly categorized as those that learn adaptively by updating their connection weights during training and whose parameters are timeinvariant.
Artificial neural network consists of a large number of simple processing elements (PEs) densely interconnected, analogous to neurons of human brain.The neural network is made up of several layers of processing elements connected together via unidirectional signal channels associated with weights, analogous to synapses.These processing elements work in unision to slove a problem.The knowledge of the networks represented by its weights [9].Every useful artificial neural net has a minimum of three layers: an input layer through which data is given to the network, an output layer that holds the response relative to the input and optional layer between the input and output layers called the hidden layer where learning takes place.The number of neurons in the input and output layers can be determined by the number of input and output variables in the physical system.The number of hidden layers and the nunber of neurons in the hidden layers are arbitrary and can vary from zero to any finite number.(1) With this system activition, the output y is given by, where θ is the threshold that define the output.Generally there are two types of neural network archticecturte, Feed-forward networks and the Feedback networks.
In neural network, there are several network topologies.Each topology is designed to solve a specific problem or to represent certain point of view.Each topology has some drawbacks and benefits.These topologies can be categorized in three main categories: fully interconnected, feed forward connection, and mixed connectivity [11,12].
In Feed forward connection, the neurons are organized in multiple layers, so that a neuron in a certain layer is connected only to neurons on the next layer as shown in Figure (2).Multilayer perceptrons belong to this category [9].

The Proposed Artificial Neural Network PN Sequence Generator
The generation process of the key using backpropagation neural network cosist of there phases.The first phase is the feedforward and the second is a backpropagation process if there are errors.The third phase concerned with weights adjustments.
During a feedforward where input data is transmited from input unit i P and calculate the activition function and sends its input data to each hidden unit i h in hidden layer.In each hidden unit, the output of activition function is calculate to transform into output unit.
During training phase each output unit is compared with the target to determine the error rate.When the error is found, the error is propagate back to the input layer for weights adjusting(third phase).This process is repeated until the desired output obtained.
The algorithm below shows the procedure to achives the three phases: 1.Initiliazation network weight values 2.Sums weighted input and apply activition function to compute the output of the hidden layer using: where i h is the actual output of hidden neuron j.
i P is the input signal of input neuron i. ij W is the weight between input neuron i and hidden neuron j. j b is the bias of hidden neuron j.
f is the activition function.
3. Sums weighted output of hidden layer and apply activition function to compute the output of output layer neurons using: where k a is the actual output of output neuron k. ij W is the weight between hidden neuron j and output neuron k.
k b is the bias of the output neuron k.
4. Compute backpropagation error using:  5. Calculate weight and bias correction output layer using: ) ( where α is the learning rate.
6. Add delta input for each hidden unit and calculate the error term using: Calculate the weight and the bais correction for the hidden layer using: ) ( 8. Update weights and biases using: The randomness of the generated key from the backpropagation neural network can be justified using statistical tests.If the justification passees, the key can be used for data encryption.

Computer Simulation and Evalution of the PN Sequence Generator
In this section some of the statistical randomness tests have been applied to binary sequences to test these sequences.These tests include frequency, poker, serial and autocorrelation tests.

─ The Frequency Test
The frequency test involves the calculation of 2 χ using [2]:

─ 5.2 The Serial Test
The serial test involves the calculation of 2 χ using [2]:  The poker test involves the calculation of 2 χ using [2]: M is the length of block i Y is the number of m-bit subsequences having i 1's and (m-i) 0's, and so on.The calculated value should be compared table for 2 χ with m 2 -1 degrees of freedom.This will find the critical region as before using a statistical table.This test can be applied as χ is less than or equal 11.1 then the sequence is said to pass this test, otherwise it is failed.the results presented in Table (3) clearly show that the proposed sequence passes the poker test.

─The Autocorrelation Test
The autocorrelation test equation involves the calculation of 2 χ using :    4) that all sequences tested pass the autocorrelation test since the value of A(d) for all are less than 1.96 as recommended by equation 21.

The Proposed Artificial Neural Network Scrambling Function
A new approach for data scrambling has been proposed from the standard backpropagation algorithm.The proposed approach uses the generated key from the neural network proposed in section 4 as input with the key weight instead of bias and

∑ ∑
Table ( 4): Autocorrelation test results for the different length sequences .
i P is the input signal of input neuron i. ij W is the weight between input neuron i and hidden neuron j.
i K is the key of hidden neuron j. ij Wk is the key weight.
f is the the activition function.
3. Sums weighted output of hidden layer and apply activition function to compute the output of output layer neurons using: where k a is the the actual output of output neuron k.

Figure( 1 )
Figure(1) shows a simple network architecture with four inputs and one output.The circles in the figure denote the PEs arranged in layers.A processing element (PE) can have many input paths and combines, usually by a simple summation, the values of these input paths.The network learns by adapting the weights of its connections according to surrounding environment.The behavior of the output unit depends on the activity of the hidden and input units.They are data driven devices.Neural networks are exceptionally effective for predicting events when the networks have large training data sets to pull

Figure.( 2
Figure.(2):Information processing of a single process element derivative of the activation function.

kt
is the target output neuron k.

9 .
Repeat from step 2 to 8 if error tolerance is not satisfied.

N 1 N
is the number of occurrences of 0's in the N-bit sequence.is the number of occurrences of 1's in the N-bit sequence.The results showing the value of 2 χ for different values of N is as shown in

11 N
be the number of occurrences of 00,01,10 and 11 respectively in the N-bit sequence.The results showing the value of 2 χ for different value of N as shown The factor of d is shift in bits between the sequences i U and d i U + .If there is correlation between the sequences, A(d) should satisfy on the following relations[2]: plaintext as the second input as shown by the flowchart shown in Figure (3).The same technique is used for decrypting the ciphertext shown by the flowchart shown in Figure (4).The procedure used in the proposed algorithm is as follow: 1.Initiliazation network weight values 2.Sums weighted input and apply activition function to compute the output of the hidden layer using: where i h is the the actual output of hidden neuron j.

ijW
is the weight between hidden neuron j and output neuron k.4.Compute backpropagation error using: the derivative of the activation function.

kt 6 . 7 .
is the the target output neuron k.5.Calculate weight and key weight correction output layer using: Add delta input for each hidden unit and calculate the error term using: Calculate the weight and the key weight correction for the hidden layer.
(1)s less than or equal 0.384 then the sequence is said to pass this test, otherwise it is failed.theresultspresented in Table(1)clearly shows that the proposed sequence passes the frequency test.Table (1): Frequency test result for the different length sequence.(16) (2)le(2).Here, if 2 χ is less than or equal 5.99 then the sequence is said to pass this test, otherwise it is failed.The results presented in Table(2)clearly show that the proposed sequence passes the serial test.

Table ( 2
): Serial test result for the different length sequences.manytimesfor different values of m.The results showing the value of 2 χ for different value of m is as shown Table(3) for different degrees of freedom.

Table ( 3
): Poker test result for the different length sequences and different degree of freedom.