Barrett reduction
In modular arithmetic, Barrett reduction is a reduction algorithm introduced in 1986 by P.D. Barrett.[1] A naive way of computing
would be to use a fast division algorithm. Barrett reduction is an algorithm designed to optimize this operation assuming is constant, and , replacing divisions by multiplications.
General idea
Let be the inverse of as a floating point number. Then
where denotes the floor function. The result is exact, as long as m is computed with sufficient accuracy.
Barrett algorithm
Barrett algorithm is a fixed-point analog which expresses everything in terms of integers. Let k be the smallest integer such that . Think of n as representing the fixed-point number . We precompute m such that . Then m represents the fixed-point number .
Let
and
.
Because of the floor function, is an integer and . Also, if then . In that case
Barrett algorithm for polynomials
It is also possible to use Barrett algorithm for polynomial division, by reversing polynomials and using X-adic arithmetic.
See also
Montgomery reduction is another similar algorithm.
References
- ↑ Barrett, P. (2006). "Implementing the Rivest Shamir and Adleman Public Key Encryption Algorithm on a Standard Digital Signal Processor". Advances in Cryptology — CRYPTO' 86. Lecture Notes in Computer Science 263. pp. 311–323. doi:10.1007/3-540-47721-7_24. ISBN 978-3-540-18047-0.
Sources
- Chapter 14 of Alfred J. Menezes, Paul C. van Oorschot, and Scott A. Vanstone. Handbook of Applied Cryptography. CRC Press, 1996. ISBN 0-8493-8523-7.
- Bosselaers, et al., "Comparison of Three Modular Reduction Functions," Advances in Cryptology-Crypto'93, 1993.
- W. Hasenplaugh, G. Gaubatz, V. Gopal, "Fast Modular Reduction", ARITH 18