# A Note on the Computation of the Modular Inverse for Cryptography

^{1}

^{2}

^{3}

^{*}

## Abstract

**:**

## 1. Introduction

## 2. Main Approaches to the Computation of Modulus

#### 2.1. Naive Method (Recursive Multiplications)

**Example**

**1.**

#### 2.2. Euler’s Phi Function

**Example**

**2.**

#### 2.3. Extended Euclidean Algorithm

**Example**

**3.**

## 3. The Sequence ${\mathit{z}}_{\mathit{j}}$: Definition and Properties

#### 3.1. Definitions and Main Results

**Definition**

**1.**

**Proposition**

**1.**

**Proof.**

**Proposition**

**2.**

**Proof.**

**Corollary**

**1.**

**Theorem**

**1.**

**Proof.**

#### 3.2. Properties of the Sequence ${z}_{j}$

**Proposition**

**3.**

**Proof.**

**Corollary**

**2.**

**Proof.**

- (i)
- The $j=0$ is trivial.
- (ii)
- If $0<j<a$, we have$${z}_{j}=a(jm-{\phi}_{j}+1)-jn=a(1-{\phi}_{j})<a<n.$$
- (iii)
- The case $j=a$ may be proved analogously to ii).

**Example**

**4.**

#### 3.3. Limitations and Future Challenges

**Proof.**

**Example**

**5.**

## 4. Conclusions

## Author Contributions

## Funding

## Institutional Review Board Statement

## Informed Consent Statement

## Data Availability Statement

## Conflicts of Interest

## References

- Rivest, R.L.; Shamir, A.; Adleman, L.M. Cryptographic Communications System and Method. U.S. Patent 4,405,829, 20 September 1983. [Google Scholar]
- Somani, U.; Lakhani, K.; Mundra, M. Implementing digital signature with RSA encryption algorithm to enhance the Data Security of cloud in Cloud Computing. In Proceedings of the 2010 First International Conference On Parallel, Distributed and Grid Computing (PDGC 2010), Solan, India, 28–30 October 2010; pp. 211–216. [Google Scholar]
- Mezher, A.E. Enhanced RSA cryptosystem based on multiplicity of public and private keys. Int. J. Electr. Comput. Eng.
**2018**, 8, 3949. [Google Scholar] [CrossRef] [Green Version] - Kumar, V.; Kumar, R.; Pandey, S. An enhanced and secured RSA public key cryptosystem algorithm using Chinese remainder theorem. In Proceedings of the International Conference on Next, Generation Computing Technologies, Dehradun, India, 30–31 October 217; Springer: Berlin/Heidelberg, Germany, 2017; pp. 543–554. [Google Scholar]
- Islam, M.A.; Islam, M.A.; Islam, N.; Shabnam, B. A modified and secured RSA public key cryptosystem based on “n” prime numbers. J. Comput. Commun.
**2018**, 6, 78. [Google Scholar] [CrossRef] [Green Version] - Raja shree, S.; Chilambu Chelvan, A.; Rajesh, M. An efficient RSA cryptosystem by applying cuckoo search optimization algorithm. Concurr. Comput. Pract. Exp.
**2019**, 31, e4845. [Google Scholar] [CrossRef] - Mumtaz, M.; Ping, L. Forty years of attacks on the RSA cryptosystem: A brief survey. J. Discret. Math. Sci. Cryptogr.
**2019**, 22, 9–29. [Google Scholar] [CrossRef] - Crandall, R.; Pomerance, C.B. Prime Numbers: A Computational Perspective; Springer Science & Business Media: Berlin/Heidelberg, Germany, 2006; Volume 182. [Google Scholar]
- Rivest, R.L.; Shamir, A.; Adleman, L. A method for obtaining digital signatures and public-key cryptosystems. Commun. ACM
**1978**, 21, 120–126. [Google Scholar] [CrossRef] - Verkhovsky, B. Overpass-Crossing Scheme for Digital Signature. In Proceedings of the International Conference on System Research, Informatics and Cybernetics, Baden-Baden, Germany, 30 July–4 August 2001; Volume 30. [Google Scholar]
- ElGamal, T. A public key cryptosystem and a signature scheme based on discrete logarithms. IEEE Trans. Inf. Theory
**1985**, 31, 469–472. [Google Scholar] [CrossRef] - Rabin, M.O. Digitalized Signatures and Public-Key Functions as Intractable as Factorization; Technical Report; Massachusetts Inst of Tech Cambridge Lab for Computer Science: Cambridge, MA, USA, 1979. [Google Scholar]
- Hoffstein, J.; Pipher, J.; Silverman, J.H.; Silverman, J.H. An Introduction to Mathematical Cryptography; Springer: Berlin/Heidelberg, Germany, 2008; Volume 1. [Google Scholar]
- Verkhovsky, B. Enhanced Euclid Algorithm for Modular Multiplicative Inverse and Its Application in Cryptographic Protocols. IJCNS
**2010**, 3, 901–906. [Google Scholar] [CrossRef] - Sosa-Gómez, G.; Paez-Osuna, O.; Rojas, O.; Madarro-Capó, E.J. A New Family of Boolean Functions with Good Cryptographic Properties. Axioms
**2021**, 10, 42. [Google Scholar] [CrossRef] - Yakymenko, I.; Kasianchuk, M.; Ivasiev, S.; Melnyk, A.; Nykolaichuk, Y.M. Realization of RSA cryptographic algorithm based on vector-module method of modular exponention. In Proceedings of the 2018 14th International Conference on Advanced Trends in Radioelecrtronics, Telecommunications and Computer Engineering (TCSET), Lviv-Slavske, Ukraine, 20–24 February 2018; pp. 550–554. [Google Scholar]
- Ore, O. Number Theory and Its History; Dover Books on Mathematics Series; Dover: Mineola, New York, USA, 1988; ISBN 9780486656205. [Google Scholar]

**Figure 1.**Sequence ${\left({z}_{j}\right)}_{1\le j\le 203}$ when $a=131$ and $n=621$. The red line highlights the entire sequence ${\left({z}_{j}\right)}_{j\ge 1}$ between two consecutive unitary ${z}_{i}$’s (red circles).

1. Initialize $i=0$, ${a}_{i}=a,\phantom{\rule{0.277778em}{0ex}}{b}_{i}=b$ and $Flag=0$; |

2.while$Flag=0$ |

3. set ${d}_{i}={a}_{i}-{b}_{i}$; |

4.. if ${a}_{i}-{b}_{i}={b}_{i}$ |

5. set $Flag=1$; |

6.else set $i=i+1$, ${a}_{i}=max\{{a}_{i-1}-{b}_{i-1},{b}_{i-1}\}$, and ${b}_{i}=min\{{a}_{i-1}-{b}_{i-1},{b}_{i-1}\}$; |

7.end |

8.end |

9. set $\mathrm{GCD}(a,b)={d}_{i}$. |

1. Initialize $i=0$, ${a}_{i}=a,\phantom{\rule{0.277778em}{0ex}}{b}_{i}=b$, and let ${q}_{i}$, ${r}_{i}$ be the quotient and the remainder of ${a}_{i}/{b}_{i}$, respectively; |

2.if ${r}_{0}=0$ |

3. let $\mathrm{GCD}(a,b)=b$; |

4.else |

5.while ${r}_{i}\ne 0$ |

6. set $i=i+1$, ${a}_{i}={b}_{i-1}$,${b}_{i}={r}_{i-1}$, and let ${q}_{i}$, ${r}_{i}$ be the quotient and the remainder of ${a}_{i}/{b}_{i}$, respectively; |

7.end |

8. set $\mathrm{GCD}(a,b)={r}_{i-1}$. |

9.end |

1. Compute ${q}_{j},{r}_{j}$, $-2\le j\le i$ (where ${r}_{-1}=a,\phantom{\rule{0.166667em}{0ex}}{r}_{-2}=n$ and ${r}_{i}=1$ is the last remainder) by the extended Euclidean algorithm (see Table 2) between a and n; |

2.for $j=i:-1:-2$ |

3. write ${r}_{j}$ as linear combination of ${r}_{j-1}$ and ${r}_{j-2}$; |

4.end |

5. set ${a}^{-1}$ equal to the coefficient multiplied by a in the final recursive relation. |

**Table 4.**Pseudocode of a simple algorithm to solve (12).

1. Initialize $j=0$, ${z}_{j}=0$ and set $m=n/a$, $\phi =(a-1)/a$; |

2.while${z}_{j}\ne 1$ |

3. set ${z}_{j}=a(jm-\phi +1)-jn$ and $j=j+1$; |

4.end |

5. set $i=j-1$ and ${a}^{-1}=a(im-\phi +1)$. |

Publisher’s Note: MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations. |

© 2021 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).

## Share and Cite

**MDPI and ACS Style**

Bufalo, M.; Bufalo, D.; Orlando, G.
A Note on the Computation of the Modular Inverse for Cryptography. *Axioms* **2021**, *10*, 116.
https://doi.org/10.3390/axioms10020116

**AMA Style**

Bufalo M, Bufalo D, Orlando G.
A Note on the Computation of the Modular Inverse for Cryptography. *Axioms*. 2021; 10(2):116.
https://doi.org/10.3390/axioms10020116

**Chicago/Turabian Style**

Bufalo, Michele, Daniele Bufalo, and Giuseppe Orlando.
2021. "A Note on the Computation of the Modular Inverse for Cryptography" *Axioms* 10, no. 2: 116.
https://doi.org/10.3390/axioms10020116