Area–Time-Efficient High-Radix Modular Inversion Algorithm and Hardware Implementation for ECC over Prime Fields
Abstract
:1. Introduction
- Extended Euclidean algorithm (EEA) without using divisions.
- Using Fermat’s little theorem [1]: .
2. ECC and Modular Inversion Algorithms
2.1. Elliptic Curve Cryptography
2.2. Point Addition and Point Doubling
2.2.1. Point Addition
Algorithm 1 PA (P, Q, m, a) (Point Addition in Affine Coordinates). |
inputs: Points and ; m and a in output: begin 1 , , , , 2 if return Q /* */ 3 if return P /* */ 4 if 5 if return /* */ 6 else return PD (P, m, a) /* */ 7 8 9 10 return /* */ end |
2.2.2. Point Doubling
Algorithm 2 PD (P, m, a) (Point Doubling in Affine Coordinates). |
inputs: Point ; m and a in output: begin 1 , , 2 if return /* vertical tangent */ 3 4 5 6 return /* */ end |
2.3. Modular Inversion Algorithms
Algorithm 3 modinv_fermat (a, m) (Modinv using Fermat’s little theorem). |
inputs: Prime m and a with output: begin 1 ; ; 2 while 3 if k is odd 4 /* modular multiply */ 5 /* modular squaring */ 6 7 return x end |
Algorithm 4 modinv1 (b, a, m) (Modular Inversion Algorithm 1). |
inputs: Prime m, a, and b with output: begin 1 /* and */ 2 /* and */ 3 while 4 /* q: integer quotient */ 5 6 7 return end |
Algorithm 5 modinv2 (b, a, m) (Modular Inversion Algorithm 2). |
inputs: Prime m, a, and b with output: begin 1 2 3 while 4 if else 1 5 6 7 return end |
Algorithm 6 modinv3 (b, a, m) (Modular Inversion Algorithm 3). |
inputs: Prime m, a, and b with output: begin 1 2 3 while and 4 if 5 else 6 if return 7 else return end |
Algorithm 7 modinv4 (b, a, m) (Modular Inversion Algorithm 4). |
inputs: Prime m, a, and b with output: begin 1 2 3 while and 4 while u is even 5 6 if x is even: 7 else 8 while v is even 9 10 if y is even: 11 else 12 if 13 else 14 if return 15 else return end |
Algorithm 8 modinv5 (b, a, m) (Modular Inversion Algorithm 5). |
inputs: Prime m, a, and b with output: begin 1 2 3 while and 4 while u is even 5 6 if x is even: 7 else 8 while v is even 9 10 if y is even: 11 else 12 if 13 14 if y is even: 15 else 16 else 17 18 if x is even: 19 else 20 if return 21 else return end |
Algorithm 9 modinv6 (b, a, m) (Modular Inversion Algorithm 6). |
inputs: Prime m, a, and b with output: begin 1 2 3 while and 4 if u is odd: 5 else 6 if v is odd: 7 else 8 9 10 if is even: 11 else 12 if 13 else 14 if return 15 else return end |
Algorithm 10 modinv7 (b, a, m) (Modular Inversion Algorithm 7). |
inputs: Prime m, a, and b with output: begin 1 2 3 while 4 if u is odd: 5 else 6 else if v is odd: 7 else else 8 else 9 else 10 if is even: 11 else 12 if 13 else 14 if 15 else 16 if 17 return x end |
3. Proposed Radix-8 Modular Inversion Algorithm and Its Performance
Algorithm 11 modinv_radix8 (b, a, m) (Radix-8 Modular Inversion Algorithm). |
inputs: Prime m, a, and b with output: begin 1 2 3 while 4 if u is odd: 5 else 6 if v is odd: 7 else 8 /* is even */ 9 if /* radix 8 */ 10 11 if 12 if 13 if 14 else 15 else 16 if 17 else 18 else 19 if 20 else 21 if 22 else 23 if 24 else 25 else 26 if /* radix 4 */ 27 28 if 29 if 30 else 31 else 32 if 33 else 34 else /* radix 2 */ 35 36 if 37 else 38 if 39 else 40 if 41 else 42 if 43 return x end |
4. ECC Implementation with Proposed Modular Inversion Algorithm
Algorithm 12 ScaMul (d, P, m, a) (Scalar Point Multiplication). |
inputs: and point ; m and a in output: begin 1 , , /* and */ 2 while do 3 if 4 PA (Q, R, m, a) /* (Algorithm 1) */ 5 PD (R, m, a) /* (Algorithm 2) */ 6 7 endwhile 8 return Q /* */ end |
Algorithm 13 ScaMulMont (d, P, m, a) (Montgomery Ladder Scalar Point Multiplication). |
inputs: and point ; m and a in output: begin 1 , PD (P, m, a) /* and */ 2 for downto 0 do 3 if 4 PA (Q, R, m, a) /* (Algorithm 1) */ 5 PD (R, m, a) /* (Algorithm 2) */ 6 else 7 PA (Q, R, m, a) /* (Algorithm 1) */ 8 PD (Q, m, a) /* (Algorithm 2) */ 9 endfor 10 return Q /* */ end |
5. Discussion of Design Issues
6. Concluding Remarks
Funding
Data Availability Statement
Conflicts of Interest
Appendix A. EEA-Based Modular Inversion Algorithms in Python
Appendix B. Elliptic Curve Diffie–Hellman (ECDH) Key Exchange Algorithm in Python
References
- Burton, D. The History of Mathematics/An Introduction, 7th ed.; McGraw-Hill: New York, NY, USA, 2011. [Google Scholar] [CrossRef]
- Hankerson, D.; Menezes, A.; Vanstone, S. Guide to Elliptic Curve Cryptography; Springer: New York, NY, USA, 2004. [Google Scholar] [CrossRef]
- Hossain, M.S.; Kong, Y. High-Performance FPGA Implementation of Modular Inversion over F_256 for Elliptic Curve Cryptography. In Proceedings of the 2015 IEEE International Conference on Data Science and Data Intensive Systems, Sydney, Australia, 11–13 December 2015; pp. 169–174. [Google Scholar] [CrossRef]
- Daly, A.; Marnane, W.; Kerins, T.; Popovici, E. Division in GF(p) for Application in Elliptic Curve Cryptosystems on Field Programmable Logic. In New Algorithms, Architectures and Applications for Reconfigurable Computing; Springer: Boston, MA, USA, 2005; pp. 219–229. [Google Scholar] [CrossRef]
- Mrabet, A.; El-Mrabet, N.; Bouallegue, B.; Mesnager, S.; Machhout, M. An efficient and scalable modular inversion/division for public key cryptosystems. In Proceedings of the 2017 International Conference on Engineering & MIS (ICEMIS), Monastir, Tunisia, 8–10 May 2017; pp. 1–6. [Google Scholar] [CrossRef]
- Chen, C.; Qin, Z. Fast Algorithm and Hardware Architecture for Modular Inversion in GF(p). In Proceedings of the 2009 Second International Conference on Intelligent Networks and Intelligent Systems, Tianjin, China, 1–3 November 2009; pp. 43–45. [Google Scholar] [CrossRef]
- Choi, P.; Lee, M.K.; Kong, J.T.; Kim, D.K. Efficient Design and Performance Analysis of a Hardware Right-shift Binary Modular Inversion Algorithm in GF(p). J. Semicond. Technol. Sci. 2017, 17, 425–437. [Google Scholar] [CrossRef]
- Wang, D.; Lin, Y.; Hu, J.; Zhang, C.; Zhong, Q. FPGA Implementation for Elliptic Curve Cryptography Algorithm and Circuit with High Efficiency and Low Delay for IoT Applications. Micromachines 2023, 14, 1037. [Google Scholar] [CrossRef] [PubMed]
- Yang, D.; Dai, Z.; Li, W.; Chen, T. An Efficient ASIC Implementation of Public Key Cryptography Algorithm SM2 Based on Module Arithmetic Logic Unit. In Proceedings of the 2019 IEEE 13th International Conference on ASIC (ASICON), Chongqing, China, 29 October–1 November 2019; pp. 1–4. [Google Scholar] [CrossRef]
- Yan, X.; Li, S. Modified modular inversion algorithm for VLSI implementation. In Proceedings of the 2007 7th International Conference on ASIC, Guilin, China, 22–25 October 2007; pp. 90–93. [Google Scholar] [CrossRef]
- Dong, X.; Zhang, L.; Gao, X. An Efficient FPGA Implementation of ECC Modular Inversion over F256. In Proceedings of the 2nd International Conference on Cryptography, Security and Privacy, Guiyang, China, 16–18 March 2018; pp. 29–33. [Google Scholar] [CrossRef]
- Hao, Y.; Zhong, S.; Ma, M.; Jiang, R.; Huang, S.; Zhang, J.; Wang, W. Lightweight Architecture for Elliptic Curve Scalar Multiplication over Prime Field. Electronics 2022, 11, 2234. [Google Scholar] [CrossRef]
- Guo, K.Y.; Fang, W.C.; Fahier, N. An Efficient Hardware Design of Prime Field Modular Inversion/Division for Public Key Cryptography. In Proceedings of the 2023 IEEE International Symposium on Circuits and Systems (ISCAS), Monterey, CA, USA, 21–25 May 2023; pp. 1–5. [Google Scholar] [CrossRef]
- Koblitz, N. Elliptic curve cryptosystems. Math. Comput. 1987, 48, 203–209. Available online: https://www.ams.org/journals/mcom/1987-48-177/S0025-5718-1987-0866109-5/S0025-5718-1987-0866109-5.pdf (accessed on 10 October 2024). [CrossRef]
- Miller, V.S. Use of Elliptic Curves in Cryptography. In Proceedings of the Advances in Cryptology—CRYPTO ’85 Proceedings; Springer: Berlin/Heidelberg, Germany, 1986; pp. 417–431. Available online: https://link.springer.com/content/pdf/10.1007/3-540-39799-X_31.pdf?pdf=inline%20link (accessed on 10 October 2024).
- Certicom Corp. Standards for Efficient Cryptography. SEC 2: Recommended Elliptic Curve Domain Parameters. 2010. Available online: http://www.secg.org/sec2-v2.pdf (accessed on 10 October 2024).
- Barker, E.; Chen, L.; Roginsky, A.; Vassilev, A.; Davis, R. SP 800-56A Rev. 3, Recommendation for Pair-Wise Key-Establishment Schemes Using Discrete Logarithm Cryptography; National Institute of Standards and Technology: Gaithersburg, MD, USA, 2018. Available online: https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-56Ar3.pdf (accessed on 10 October 2024).
- Li, Y. Hardware Implementations of Elliptic Curve Cryptography Using Shift-Sub Based Modular Multiplication Algorithms. Cryptography 2023, 7, 1–29. [Google Scholar] [CrossRef]
- Li, Y.; Chu, W. Shift-Sub Modular Multiplication Algorithm and Hardware Implementation for RSA Cryptography. In Proceedings of the 17th International Conference on Information Assurance and Security, Lecture Notes in Networks and Systems; Springer: Cham, Switzerland; 2021; pp. 541–552. [Google Scholar] [CrossRef]
- Oliveira, T.; López, J.; Rodríguez-Henríquez, F. The Montgomery ladder on binary elliptic curves. J. Cryptogr. Eng. 2018, 8, 241–258. [Google Scholar] [CrossRef]
Expose an Elliptic Curve and a Point P on the Elliptic Curve to the World | |
---|---|
Alice | Bob |
Generate a secret | Generate a secret |
Calculate | Calculate |
Expose | Expose |
Get from Bob | Get from Alice |
Calculate | Calculate |
Use x of as the key | Use x of as the key |
i | u | v | x | y | q | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 3 | = | a | 11 | = | m | 1 | = | b | 0 | q | = | |||
0 | u | = | v | v | = | x | = | y | y | = | |||||
1 | 0 | = | |||||||||||||
1 | 11 | = | v | 3 | = | 0 | = | y | 1 | = | |||||
2 | 3 | = | |||||||||||||
2 | 3 | = | v | 2 | = | 1 | = | y | = | ||||||
3 | 1 | = | |||||||||||||
3 | 2 | = | v | 1 | = | = | y | 4 | = | ||||||
4 | 2 | = | |||||||||||||
4 | 1 | = | v | 0 | = | 4 | = | y | = | ||||||
End | u | = | 1 | v | = | 0 | x | = | 4 |
i | u | v | x | y | q |
---|---|---|---|---|---|
0 | 3 | 11 | 1 | 0 | 0 |
1 | 11 | 3 | 0 | 1 | 1 |
2 | 3 | 8 | 1 | 0 | |
3 | 8 | 3 | 1 | 1 | |
4 | 3 | 5 | 1 | 0 | |
5 | 5 | 3 | 1 | 1 | |
6 | 3 | 2 | 1 | 1 | |
7 | 2 | 1 | 4 | 1 | |
8 | 1 | 1 | 4 | 1 | |
9 | 1 | 0 | 11 |
i | u | v | x | y |
---|---|---|---|---|
0 | 3 | 11 | 1 | 0 |
1 | 3 | 8 | 1 | |
2 | 3 | 5 | 1 | |
3 | 3 | 2 | 1 | |
4 | 1 | 2 | 4 |
txy | m | Comment | ||||
---|---|---|---|---|---|---|
000 | xx1 | |||||
100 | xx1 | 100 | ||||
010 | x01 | 010 | ||||
110 | x11 | 110 | ||||
010 | x11 | 110 | ||||
110 | x01 | 010 | ||||
001 | 001 | |||||
011 | 011 | |||||
101 | 101 | |||||
111 | 111 | |||||
001 | 101 | 010 | 111 | |||
011 | 111 | 110 | 101 | |||
101 | 001 | 010 | 011 | |||
111 | 011 | 110 | 001 | |||
001 | 111 | |||||
011 | 101 | |||||
101 | 011 | |||||
111 | 001 | |||||
001 | 011 | 110 | 001 | |||
011 | 001 | 010 | 011 | |||
101 | 111 | 110 | 101 | |||
111 | 101 | 010 | 111 |
txy | m | Comment | ||
---|---|---|---|---|
00 | x1 | |||
10 | x1 | 10 | ||
01 | 01 | |||
11 | 11 | |||
01 | 11 | |||
11 | 01 |
Algorithm | Cycles | Freq. (MHz) | Latency (μs) | ALMs | Registers | AT |
---|---|---|---|---|---|---|
[1] 2011, Burton | 66,264 | 57.54 | 1151.63 | 2004 | 2775 | 5503.66 |
[2] 2004, Hankerson | 534 | 54.66 | 9.77 | 2619 | 1302 | 38.31 |
[3] 2015, Hossain | 535 | 54.52 | 9.81 | 3735 | 1303 | 49.42 |
[4] 2005, Daly | 358 | 39.73 | 9.01 | 2474 | 1038 | 31.64 |
[5] 2017, Mrabet | 1205 | 64.55 | 18.67 | 1596 | 1043 | 49.26 |
[6] 2009, Chen | 723 | 72.21 | 10.01 | 1968 | 1042 | 30.13 |
[7] 2017, Choi | 358 | 63.60 | 5.63 | 959 | 1037 | 11.24 |
[8] 2023, Wang | 423 | 59.56 | 7.10 | 3475 | 1303 | 33.92 |
[9] 2019, Yang | 356 | 60.43 | 5.89 | 3950 | 1057 | 29.50 |
[10] 2007, Yan | 423 | 54.99 | 7.69 | 3644 | 1303 | 38.05 |
[11] 2018, Dong | 334 | 56.93 | 5.87 | 5276 | 1057 | 37.15 |
[12] 2022, Hao | 534 | 54.66 | 9.77 | 2619 | 1302 | 38.31 |
[13] 2023, Guo | 356 | 33.95 | 10.49 | 1653 | 1039 | 28.23 |
Ours | 208 | 56.71 | 3.67 | 1227 | 1037 | 8.30 |
Curve | Algorithm | Cycles | Freq. (MHz) | Latency (μs) | ALMs | Registers | AT |
---|---|---|---|---|---|---|---|
Secp192k1 | [2] | 404 | 67.78 | 5.96 | 1965 | 982 | 17.57 |
Ours | 151 | 59.38 | 2.54 | 940 | 781 | 4.38 | |
Secp256k1 | [2] | 534 | 54.66 | 9.77 | 2619 | 1302 | 38.31 |
Ours | 208 | 56.71 | 3.67 | 1227 | 1037 | 8.30 | |
Secp521r1 | [2] | 1109 | 36.36 | 30.50 | 5678 | 2627 | 253.31 |
Ours | 429 | 33.60 | 12.77 | 2245 | 2097 | 55.44 |
Weight | Point Addition | Point Doubling | |
---|---|---|---|
Initial | |||
1 | |||
2 | |||
4 | |||
8 | |||
16 |
Algorithm | Cycles | Freq. (MHz) | Latency (ms) | ALMs | Registers | AT |
---|---|---|---|---|---|---|
[2] 2004, Hankerson | 402,145 | 15.94 | 25.23 | 15,043 | 8355 | 590,300.42 |
[3] 2015, Hossain | 402,400 | 15.58 | 25.83 | 17,585 | 8355 | 669,977.92 |
[4] 2005, Daly | 357,262 | 16.06 | 22.25 | 14,975 | 7821 | 507,107.38 |
[5] 2017, Mrabet | 570,142 | 16.07 | 35.48 | 13,292 | 7834 | 749,522.08 |
[6] 2009, Chen | 455,425 | 16.15 | 28.20 | 14,211 | 7831 | 621,577.58 |
[7] 2017, Choi | 356,878 | 16.01 | 22.29 | 12,114 | 7820 | 444,347.67 |
[8] 2023, Wang | 372,127 | 15.98 | 23.29 | 17,292 | 8353 | 597,196.30 |
[9] 2019, Yang | 352,761 | 15.72 | 22.44 | 17,841 | 7860 | 576,737.31 |
[10] 2007, Yan | 372,127 | 16.08 | 23.14 | 18,548 | 8355 | 622,595.32 |
[11] 2018, Dong | 346,194 | 15.88 | 21.80 | 20,716 | 7859 | 622,952.99 |
[12] 2022, Hao | 402,145 | 15.89 | 25.31 | 15,041 | 8354 | 592,081.96 |
[13] 2023, Guo | 356,496 | 15.64 | 22.79 | 13,571 | 7824 | 487,674.68 |
Ours | 317,681 | 16.13 | 19.70 | 12,160 | 7822 | 393,546.29 |
Algorithm | Cycles | Freq. (MHz) | Latency (ms) | ALMs | Registers | AT |
---|---|---|---|---|---|---|
Traditional (Algorithm 12) | 317,681 | 16.13 | 19.70 | 12,160 | 7822 | 393,546.29 |
Mont.ladder (Algorithm 13) | 318,831 | 15.86 | 20.10 | 12,723 | 7577 | 408,087.60 |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2024 by the author. 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
Li, Y. Area–Time-Efficient High-Radix Modular Inversion Algorithm and Hardware Implementation for ECC over Prime Fields. Computers 2024, 13, 265. https://doi.org/10.3390/computers13100265
Li Y. Area–Time-Efficient High-Radix Modular Inversion Algorithm and Hardware Implementation for ECC over Prime Fields. Computers. 2024; 13(10):265. https://doi.org/10.3390/computers13100265
Chicago/Turabian StyleLi, Yamin. 2024. "Area–Time-Efficient High-Radix Modular Inversion Algorithm and Hardware Implementation for ECC over Prime Fields" Computers 13, no. 10: 265. https://doi.org/10.3390/computers13100265
APA StyleLi, Y. (2024). Area–Time-Efficient High-Radix Modular Inversion Algorithm and Hardware Implementation for ECC over Prime Fields. Computers, 13(10), 265. https://doi.org/10.3390/computers13100265