Enhanced Euclid Algorithm for Modular Multiplicative Inverse and Its Application in Cryptographic Protocols

Numerous cryptographic algorithms (ElGamal, Rabin, RSA, NTRU etc) require multiple computations of modulo multiplicative inverses. This paper describes and validates a new algorithm, called the Enhanced Euclid Algorithm, for modular multiplicative inverse (MMI). Analysis of the proposed algorithm shows that it is more efficient than the Extended Euclid algorithm (XEA). In addition, if a MMI does not exist, then it is not necessary to use the Backtracking procedure in the proposed algorithm; this case requires fewer operations on every step (divisions, multiplications, additions, assignments and push operations on stack), than the XEA. Overall, XEA uses more multiplications, additions, assignments and twice as many variables than the proposed algorithm.

A new algorithm, called the Enhanced-Euclid Algorithm (NEA), for modular multiplicative inverse (MMI) is described and validated in this paper.
Definition 1: Given relatively prime integers and , there exists an unique integer x such that ( Then x is defined as the modular multiplicative inverse of 1 p modulo or, for short, MMI. The NEA finds for two relatively prime integers 0 and 1 an integer number x that satisfies the Equation (1).And if and are not relatively prime, then NEA finds a gcd( 0 , 1 ).The Extended-Euclid algorithm (XEA) also finds a MMI of modulo if and only if gcd( , ) = 1 [1,2,7].This paper proves the validity of NEA and provides its analysis.The analysis demonstrates that NEA is faster than the Extended Euclid algorithm.Preliminary results of this paper are published in [8].

Basic Arrays and Their Properties
Let's consider five finite integer arrays: Definition 2: Let   i p and   i c be integer arrays defined according to the following generating rules: Given two relatively prime integers 0 p and 1 p su that 0 p  be an arbitrary integer array for all ; let for initially specified 0 1 0 and 1 the following generating rules be defined for all : Proof: Consider k and substitute in the left column the values of k and defined in (4).After simplifications we derive that , which recursively implies (6).
Then is a multiplicative inverse of for every .
k Proof: Indeed, since , then (5) implies that or that Then from (7) it follows that where the superscript R means that the arrays  

Enhanced Euclid Algorithm for MMI
The proposed algorithm uses stack as a data structure, [2].vars: r; L; M; S; t: all integer numbers; b: Boolean; procedure Forward: until the stack is empty; output x: = L; {if x < 0, then x: = x + }. 0 Remark 3: r is the height of the stack and is used below for analysis of the proposed algorithm.

Two Illustrative Examples
Let's demonstrate how NEA finds a multiplicative inverse x of 27,182,845 modulo 31,415,926.Table 1 below shows the computation of remainders in the upper row and stores the quotients in the middle row (the stack).Then the Backtracking procedure is used to compute from right to left until the stack is empty.The inputs and MMI are shown in bold, and the stack values are in italics.Since the total number of steps (the height of the stack) is equal to fourteen (i.e., even), then x = 13,939,773.
In the second numerical example we need to find the MMI z of 27,319,913 modulo 177,276,627 {see Table 2}.Since the height of the stack is odd, then z = 177276627-34480855 = 142795772.
Direct computation verifies that z is indeed the MMI of 27319913, since 27319913 * 142795772 mod 177276627 = 1.

Complexity Analysis of MMI Algorithm
Consider four non-negative integer arrays , Then ( 3) and (14) : i.e., for all j = 1, , s e ists at least one h that .Th or al the there x j s  l l l 1  equalities hold: Proof: Assuming that the stat , it can also be demonstrated by Consi ement (15) holds for all induction that 1 i j   (15) also holds for i j  .der .
Since 0 0 p q  , then ( 14) holds for all j  s .
Q ) a unary a property for all non-negative integer numbers t and u: 1) Here the Fibonacci num .bers with or For all pairs, listed above, exactly r steps are required to find the MMI.However, all these pairs are special cases of a pair of seeds where b; and Consider Therefore for all 0 i r   -transform approach, we deduce that for all 0 Then for a large r The relation (18) implies that for a large r implies that the height of a stack satisfies the following inequality: [8].

Example 3: In this example (see
% smaller than the upper bound in (21).

Extended-Euclid Algorithm (XE
XEA also finds a multiplicative inverse of 1 p

  
, 3 : 7. Comparative analysis of NEA vs. XEA for ard rocedure in (10), and Q in (22), respectively.Theoretical analysis of space complexity of the Enhanced-Euclid algorithm shows that it requires relatively small bit-storage for its execution.This storage does not On the other hand, computer simulations demonstrate that the average bit-storage is actually 40% smaller than 2K.Hence NEA can be executed if necessary by a custom-built chip with relativ l st memory, [7].This property of the Enhanced is especially useful fo vironments such as smart or PC cards, cell phones, wearable computers and other integrated devices.

)
push t {onto the top of the stack}; L: = M; M: = S; (11) until S = 1; Remark 2: if S = 0, then ; therefore the MMI does not exist; ; {by (9) in the Theorem 1}; repeat pop t {from the top of the stack}; p

) 1 
one that generates a uotients and b) a decreasing integer array where the r th remainder eq pairs of seeds hav o uals one.Indeed, the following e the same of the Lucas 3zero and negative indices are computed in acc dance with the formula: r implementation of encryption in low memory en of this aper; and to A. Koripella for her assistance in running .van Oorschot and S. A. Vanstone, "Handbook of Applied Cryptography," CRC Press, Boca ] R. L. Rivest, A. Shamir and L. Adleman, "A Method for :

Size of stack.
one multiplication, one addition, one push operation and five assignments per every step.Yet XEA still requires the same number of operations per step as in the case if a MMI does exist.Hence, overall XEA uses more multiplications, more additions, more assignments and twice as many variables than the proposed algorithm. 8.

Average Complexity of XEA and NEA
nea w -worst-case specific complexity of NEA xea a -average-case specific complexity of XEA;