English

An Elementary Method For Fast Modular Exponentiation With Factored Modulus

Number Theory 2024-09-13 v4

Abstract

We present a fast algorithm for modular exponentiation when the factorization of the modulus is known. Let a,n,ma,n,m be positive integers and suppose mm factors canonically as i=1kpiei\prod_{i=1}^k p_i^{e_i}. Choose integer parameters ti[1,ei]t_i\in [1, e_i] for 1ik1\le i\le k. Then we can compute the modular exponentiation an(modm)a^n\pmod{m} in O(max(ei/ti)+i=1ktilogpi)O(\max(e_i/t_i)+\sum_{i=1}^k t_i\log p_i) steps (i.e., modular operations). We go on to analyze this algorithm mathematically and programmatically, showing significant asymptotic improvement in specific cases. Specifically, for an infinite family of mm we achieve a complexity of O(logm)O(\sqrt{\log m}) steps, much faster than the Repeated Squaring Algorithm, which has complexity O(logm)O(\log m). Additionally, we extend our algorithm to matrices and hence general linear recurrences. The complexity is similar; with the same setup we can exponentiate matrices in GLd(Z/mZ)GL_d(\mathbb{Z}/m\mathbb{Z}) in less than O(max(ei/ti)+d2i=1ktilogpi)O(\max(e_i/t_i)+d^2\sum_{i=1}^k t_i\log p_i) steps. This improves Fiduccia's algorithm and the results of Bostan and Mori in the case of Z/mZ\mathbb{Z}/m\mathbb{Z}. We prove analogous results for Z/pkZ\mathbb{Z}/p^k\mathbb{Z} ring extensions.

Keywords

Cite

@article{arxiv.2401.10497,
  title  = {An Elementary Method For Fast Modular Exponentiation With Factored Modulus},
  author = {Anay Aggarwal and Manu Isaacs},
  journal= {arXiv preprint arXiv:2401.10497},
  year   = {2024}
}

Comments

18 pages, 4 figures, Presented at 2023 West Coast Number Theory Conference

R2 v1 2026-06-28T14:21:12.492Z