Bach's algorithm explained
Bach's algorithm is a probabilistic polynomial time algorithm for generating random numbers along with their factorizations. It was published by Eric Bach in 1988. No algorithm is known that efficiently factors random numbers, so the straightforward method, namely generating a random number and then factoring it, is impractical.[1]
The algorithm performs, in expectation, O(log n) primality tests. A simpler, but less efficient algorithm (performing, in expectation,
primality tests), is due to
Adam Kalai.
[2] [3] Bach's algorithm may be used as part of certain methods for key generation in cryptography.[4]
Overview
Bach's algorithm produces a number
uniformly at random in the range
(for a given input
), along with its factorization. It does this by picking a
prime number
and an exponent
such that
, according to a certain distribution. The algorithm then recursively generates a number
in the range
, where
, along with the factorization of
. It then sets
, and appends
to the factorization of
to produce the factorization of
. This gives
with logarithmic distribution over the desired range;
rejection sampling is then used to get a uniform distribution.
[1] [5] Further reading
- Bach, Eric. Analytic methods in the Analysis and Design of Number-Theoretic Algorithms, MIT Press, 1984. Chapter 2, "Generation of Random Factorizations", part of which is available online here.
Notes and References
- Bach . Eric . Eric Bach . 10.1137/0217012 . 2 . . 935336 . 179–193 . How to generate factored random numbers . 17 . 1988.
- Kalai . Adam . 10.1007/s00145-003-0051-5 . 4 . . 2002046 . 287–289 . Generating random factored numbers, easily . 16 . 2003. 17271671 . free .
- Book: Shoup . Victor . A Computational Introduction to Number Theory and Algebra . 2008 . Cambridge University Press . Cambridge, UK . 305 . Version 2.
- Book: Delfs . Hans . Knebl . Helmut . Introduction to Cryptography: Principles and Applications . 2015 . Springer Verlag . Berlin . 226 . 3rd.
- Book: Prime Suspects: The Anatomy of Integers and Permutations. Andrew. Granville. Jennifer. Granville. Princeton University Press. 2019. 9780691188737. Constructing integers with the probabilistic model. 207–208. https://books.google.com/books?id=uPaKDwAAQBAJ&pg=PA207.