Paper 2025/1068 Original: eprint.iacr.org/2025/1068 ↗

Efficient Modular Multiplication Using Vector Instructions on Commodity Hardware

Simon Langowski
Srini Devadas
Abstract

Modular arithmetic is the computational backbone of many cryptographic and scientific algorithms. In particular, modular multiplication in a large prime field is computationally expensive and dictates the runtime of many algorithms. While it is relatively easy to utilize vectorization to accelerate batches of independent modular multiplications, our goal is to reduce the latency of a $\textit{single}$ modular multiplication under a generic prime using vectorization, while maintaining constant-time execution. We investigate the technique of Residue Number System (RNS) Montgomery modular multiplication. We first contribute a unified view of algorithmic optimizations in prior art. This view enables us to further reduce the number of elementwise multiplications in an algorithm with a simplified structure that we prove correct. We explore AVX512 acceleration on CPUs, and show how to map our algorithm to vector instructions. We implement our algorithm in C++ and achieve $\approx 4 \times$ speedup, which is nearly maximal, for $1024+$-bit primes on a CPU with AVX512 over optimized library implementations of standard Montgomery modular multiplication algorithms. GPUs contain vector cores that each support tens of physical threads. We show how to intelligently map our algorithm to threads in a vector core, ``overparallelizing'' to minimize latency. We show substantial speedups over a commercial library implementation of standard modular multiplication algorithms across a wide range of prime sizes.

Metadata
Available format(s)
PDF
Category
Foundations
Publication info
Preprint.
History
2025-06-06: last updated
2025-06-06: published
Short URL
https://ia.cr/2025/1068
License
https://creativecommons.org/licenses/by/4.0/

BibTeX

@misc{cryptoeprint:2025/1068,
      author = {Simon Langowski and Srini Devadas},
      title = {Efficient Modular Multiplication Using Vector Instructions on Commodity Hardware},
      howpublished = {Cryptology {ePrint} Archive, Paper 2025/1068},
      year = {2025},
      url = {https://eprint.iacr.org/2025/1068}
}
Note: In order to protect the privacy of readers, this archive does not use cookies or embedded third party content.