Bach's algorithm is a probabilistic
polynomial time
In theoretical computer science, the time complexity is the computational complexity that describes the amount of computer time it takes to run an algorithm. Time complexity is commonly estimated by counting the number of elementary operations p ...
algorithm
In mathematics and computer science, an algorithm () is a finite sequence of Rigour#Mathematics, mathematically rigorous instructions, typically used to solve a class of specific Computational problem, problems or to perform a computation. Algo ...
for
generating random numbers along with their
factorization
In mathematics, factorization (or factorisation, see American and British English spelling differences#-ise, -ize (-isation, -ization), English spelling differences) or factoring consists of writing a number or another mathematical object as a p ...
s. 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.
The algorithm performs, in expectation,
primality tests
A primality test is an algorithm for determining whether an input number is prime number, prime. Among other fields of mathematics, it is used for cryptography. Unlike integer factorization, primality tests do not generally give prime factors, only ...
. A simpler but less-efficient algorithm (performing, in expectation, primality tests), is due to
Adam Kalai.
Bach's algorithm may be used as part of certain methods for
key generation
Key generation is the process of generating keys in cryptography. A key is used to encrypt and decrypt whatever data is being encrypted/decrypted.
A device or program used to generate keys is called a key generator or keygen.
Generation in crypt ...
in cryptography.
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
A prime number (or a prime) is a natural number greater than 1 that is not a Product (mathematics), product of two smaller natural numbers. A natural number greater than 1 that is not prime is called a composite number. For example, 5 is prime ...
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
In numerical analysis and computational statistics, rejection sampling is a basic technique used to generate observations from a distribution. It is also commonly called the acceptance-rejection method or "accept-reject algorithm" and is a type o ...
is then used to get a uniform distribution.
References
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 onlin
here
Cryptographic algorithms
Random number generation
{{algorithm-stub