Public Key Cipher with Signature Based on Diffie-Hellman and the Magic Square Problem

: In the present paper, we developed a new variant of asymmetric cipher (Public Key) algorithm based on the Discrete Logarithm Problem (DLP) uses Diffie-Hellman key exchange protocol and the mathematical features of magic square. The proposed method exploits the DLP problem in the key exchange by using the final value of Diffie-Hellman key agreement, just as the dimension to the magic construction and through which determines the type of magic square construction if it is (odd, singly-even or doubly-even) magic square as well as through which determines starting number and the difference value. From the other point, it exploits the magic squares problem in encryption/decryption and signing/verifying operations. The developed method extremely speed in the Encryption/Decryption process as well as in the digital signature that uses a Secure Hash Algorithm SHA-1, since the proposed cipher does not use logarithm and the factorization as the traditional algorithms in ciphering and deciphering operations just in the mutual exchanging, but it depends mainly upon the magic constant and magic sum as alternate that deduced from the result of multiplied fixed value, which selected randomly and imposes to keep secret, as we shall explained in the next sections.

Discrete Logarithm Problem on Algebraic Tori: This is another problem also related to the DLP in a finite field of order Fq.mainly, the DLP on an algebraic torus Tn (Fq) that is equivalent to the DLP in the subgroup of order ⱷn(q).Where ⱷn (q) equivalent to the n-th cyclotomic polynomial [8].

Magic Square Construction
The magic squares problem leads to work into the areas of mathematics such as group theories, algebraic notations, matrices, geometric aspects, number theory, and congruence arithmetic.It is widely used in cryptography, steganography, watermarking, computer games, error correcting codes, statistics and mathematical field [9].The magic square is an array of n x n cells, filled with integers that are all different values.This array contains the numbers with consecutive order as 1; 2… n 2 .The sum of elements in any row, column, or diagonals is the same.The below Figure ( 1) is a magic square of order 3 with 9 values consecutively arranged in magical arrangement.So, suppose M is the number that each row, column and diagonal must add up to vector numbers.In such summation notation, for the series or different consecutive numbers the summation is:∑ . .This is just for the normal magic square which uses this formula for the sum of magic vector but not for other square such as the semi or Latin square etc.The pivot element (center element) for any magic square of odd order can be calculated as the following formula:P , P and so on 10 .The magic constant can be calculated by, gives .Thus, a 3*3 normal magic square must have its rows, columns and diagonals adding to 15, 4*4 to M = 34, 5*5 to M= 65 and 8*8 to M = 260, and so on [11].The normal magic square of order n is a matrix with the following representation M=(a ij ) n x n , where i, j =1, 2, …, n, a ij ∈ {1, 2, …, n 2 } with a ij ≠ a kl, for all i≠ k or j ≠1 and it holds that gives the MCof the magic square that involves the sum of each row, column and diagonal is the same, as stated in the following Eq(1) : There exists another derivative formula to determine the magic constant of a magic square as it is explained below in the following Eq(2).This formula works for squares that contain consecutive integers from 1 to n 2 .Recall that the sum of the series is: With magic squares.We then divide by n.So that it will give the sum for the rows and columns, which gives us: For the Magic Sum (MS) that includes the summation to the all numbers in magic square uses the following formula inEq(3).
The MS for 3*3 =45, MS for 4*4 =136, MS for 5*5= 325,MS for 8*8=2080 and so on, other method for calculating MS is by multiply MC * dimension of the magic square [12].There are various methods for constructing magic squares that have evolved through the ages.When considering these characteristics and methods, it is useful to categorize magic squares in three classes as the following: Magic Squares of Odd Order One of the three types of magic square where the order n is of the form 2m+ 1, where m may be any positive integer (1, 2, 3, etc.).Example includes the De la Loubère's method.The matrix dimension will be 3*3, 5*5, and 7*7 and so on.

Magic Squares of Doubly Even Order
The Doubly even order squares where the order n is of the form 4m, such as (4, 8, 12, 16, 32, etc.).The order of doubly even square can be divided by 2 and 4. Example includes the Albrecht Dürer's method.The matrix dimension will be 4*4, 8*8, and 12*12 and so on.

The Proposed Public Key (Asymmetric Cipher)
The proposed cipher is a new variant of asymmetric cipher (Public Key) algorithm based on the Discrete Logarithm Problem (DLP) uses Diffie-Hellman key exchange protocol and the mathematical features of magic square.The proposed method exploits the DLP problem only in the key exchange by using the final value of Diffie-Hellman key agreement, just as the dimension to the magic construction and through which determines the type of magic square construction if it is (odd, singly-even or doubly-even) magic square, as well as through which determines starting number and the difference value.From the other point it exploits the magic squares problem in encryption/decryption and signing/verifying operations.The developed method extremely speed in the Encryption/Decryption process as well as in the digital signature that uses a Secure Hash Algorithm SHA-1, since the proposed cipher does not uses logarithm and the factorization as the traditional algorithms in ciphering and deciphering operations just in the mutual exchanging, but it depends mainly upon the magic constant and magic sum as alternate that deduced from the result of multiplied fixed value, which selected randomly and imposes to keep secret, as we shall explained in the next sections.The proposed cipher formulated the problem of transfer a secret key to both intercommunicated parties before establishing the trusted communication, besides encrypts and signs the message using a new approach of public key based on the magic square problem.Since, the encryption and decryption process represent the difficult task, because it needs a secure channel.The proposed cipher mainly based on the Diffie-Hellman key exchange and the magic square construction problem which comprises several factors for the predisposing the agreement: The dimension of magic square (type of magic square), the start number, the difference between the numbers and the fixed multiplied value that enlarged the magic sum and magic square.The cube dimensions include six of dependent magic square each one has a magic constant and magic sum that can be used as a private key for the encryption and decryption procedures.This technique can be generalized for more than two entities up to six parties for each face of magic cube.So these parties can be increased rapidly with the number of magic cub construction.The algorithm below explains the full notation step by step with manual solution for simple example.

Table (1) The Proposed Public Key Algorithm 1)
Initialization of Algorithm a.
Alice and Bob choose a Finite Field (Fq).b.
Alice and Bob choose a primitive element (p).
Alice chooses a secret random integer (a), 1< a < p-1, and she compute (P a mod Fq).b.
Makes P a and P b public and keep a,b secret as the Diffie-Hellman.d.
Alice compute D1=(P a ) b and Bob compute D2=(P b ) a , hence D1=D2 Since it is exchange key which will consider the Dimension of Magic Square (D) and it will illustrates the type of Magic Square if it (odd magic square, even magic square or odd even magic square).e.
Announce the Starting element (S) which selected randomly and then multiplied by the secret value of D privately to give new start number.f.
Announce the Difference number (DF) which selected randomly and then subtracted by the secret value of D secretly privately to give new difference.

3)
Calculation the Secret Key a.
Build the magic square according to the dimension (D), Starting element (S) and Difference number (DF).

b.
Select a random number integer as a fixed multiplied value (FV) for the magic square to regenerate the magic square with other big values.c.
Compute the Init value as follow: Compute the Magic Sum (MS) or the summation for all the magic square values and consider the result as a secret key.e.
Compute the Magic Constant (MC) for the magic square that uses in the Signature computation.

4)
Encryption and Decryption  Encryption Process a.
Alice encrypt the message (M) as follow: C =M * MS mod p b.
Alice sends (Init , C) to Bob  Decryption Process a.
Bob compute the Fixed Value (FV) as follow: FV = Init *D -1 c.
Bob generate the magic square and multiplied it by FV d.
Bob compute the MS and MC from the new magic square e.
Bob decrypt the ciphertext (C) as follow M = C * MS -1 The Proposed Signature Algorithm The proposed signature algorithm which responsible of the signing and verifying operations is one of the simplest algorithms that similar to the traditional signature algorithm, that depends upon the magic constant vector as a private key that represented by vector summation in magic square matrix (row, column or diagonal values), in addition to the outcome message digest of secure hash algorithm.

Table (2) The Proposed Signature Algorithm Signature Algorithm 
Singing the Message 1) Alice computes the message digest by using Hash Function SHA-512 h=H(M) mod p.

2)
Alice computes the ciphertext as follow: C=MC * h mod p. and sends the (C) to the Bob.

Verifying the Message 1)
Bob receives the ciphertext (C) and computes the message digest As follow: h'=C*MC -1 mod p

2)
If h= h' then accept else reject the signature

5)
Suppose the result starting number is (1) and the difference value also (1) to alleviate the computation burden on the reader and makes the track process easy only for this example.

6)
Select a random number as a fixed multiplied value (FV) =7 and multiplied the magic square by 7 to generate new magic square as the stated in the following magic square : The result of MS= 35350 after multiplied by 7 The result ofMC= 3535 after multiplied by 7

7)
Compute the Magic Sum (MS) and the Magic Constant (MC) for the new Magic square MS=35350 and MC=3535
D1=D2 represent the (D) Dimension of the magic square for the two parties.


Sign the Message  Verify the Message

Motivations and Limitations
There are several motivations to design the proposed public key model, since the most of the public key methods mainly depend upon the discrete logarithm problem and integer factorization problem and these methods highly cost time.Magic square construction is a complex and hard permutation problem, there is only one 3x3 normal magic square, and there are 880 4x4 normal magic squares and there are over 13 million normal 5x5magic squares.The number of magic squares increases dramatically as the size of the square increases [14].The core idea for the proposed model concentrates on the design a fast and strong method that based on the magic square mathematical problem, in order to guarantee the complete security and invulnerability against the malicious attacks.The complexity of this cipher includes that the eavesdroppers should tries all possible probabilities of construction the magic square matrix starting from the unknown random value that acts as starting value for the construction and unknown dimension value, which need a lot of estimation and guessing.These schemes allow fast encryption and decryption process in addition to the fast signature generation and verification, as well as to enlarges the search space against the brute force attack and consequently increases the complexity.There are several negatives and limitations in this field of the cryptosystem.One of the main problems and the limited side in the public-key cryptography is to prove that the public key is authentic, i.e., it has not been altered or changed with other key by intruder or unknown intercepted person.Perhaps the most vulnerable attack on the public key cipher is the man-in-the-middle attack, in which a third malicious party impersonate the personality of the authorized person by the intercepts and modifies the public key.An active adversary in the middle communication manipulates and modifies the messages and the implication deceives the two communicated parties.In order to agree on a key which is exclusively shared between Alice and Bob, these principals must make sure that the messages they receive in a protocol run are indeed from the intended principals.A trusted third party can be used to act as a certificate authority, which ensures the identity of parties using the system.The public key in general term or asymmetric cryptosystem compared with the symmetric cryptosystem take much more time in established key for encryption and decryption processes.Since, it uses sophisticated mathematical problems in its construction.The random choices for some numbers to construct the magic square whence starting value, difference value and the fixed multiplied value to generate the private key give a more resistant against the attacks.Unacceptable choices for these random numbers represent a basic restriction and may be open the door in front of the attacks.So, it should be ensures the identity of parties using a trusted third party.The proposed method implemented by Visual Studio 2013 using Visual C# programming language.

Analysis and Experimental Results
The security of the proposed cipher based on the mixed more than one mathematical problem to apply high margin of security.An efficient, secure and fast algorithm employed to apply secure digital communication which is based on the hardness of some problems in number theory.The magic square construction also based on various techniques that give more strength to defeats the attacks and increases the probability of resistant in front the statistical analysis.The efficiency of a proposed cipher is relied on the time elapsed for encryption/decryption and the way it produces different cipher-text from a plaintext.With respect to efficiency, as it well known that the most of the public-key cipher suffers from the difficulty of the key generation and the parameters selection for the session establishment and the key agreement.The proposed cipher on the software platforms offers a cost effective and flexible solution for the key exchange (key agility) and encryption/decryption.The adoption of the magic square mathematical problem could significantly change the nature of public key cryptography and the manner through which will be treated, in addition to the behavior and the style of attacks.We have introduced a simple comparison among three different public key ciphers in the below as explained in figure(4)which illustrates the implementation of run time in seconds to achieve the encryption and decryption operation for the three messages with different size (1000 char, 2000 char, and 3000 char) respectively.Figure (5) submits the running time of the signature and verification algorithms for the same message.In this test there is no need to take different messages lengths, because the execution time will be based on the message digest of the original message.

CONCLUSIONS
We have shown that the proposed model give a good insight and introduced a smart method in the designing processes that paved the way front the new mathematical comprehension which related to the probability of dimension for the magic square construction.Since the search space and the complexity increased dramatically with the increasing dimension.The basic idea described in this paper focused on the clue of creates a confidential communication channel with a secret sharing between the communicating parties in the presence of malicious adversaries.The magic square mathematical problem has been exploited and played a vital role in encryption/decryption and signing/verifying operations.It gives a remarkable significant speed and reduced the costs as well as improves the efficiency and security margin.
Figure (1) Magic Square of order 3 Figure (2) K=A b mod p = (g a mod p) b mod p = g ab mod p = (g b mod p) a mod p = B a mod p = ( D ) Dimension of Magic Square

Figure
Figure (3) The Proposed Algorithm of Diffie-Hellman with Magic Square