blumb_blumb_shub.Rd
The Blum Blum Shub (B.B.S.) pseudorandom number generator was proposed in 1986 by Lenore Blum, Manuel Blum, and Michael Shub. It is based on the security of the quadratic residuosity problem, making it a cryptographically secure generator. The B.B.S. generator relies on the product of two large prime numbers, \(p\) and \(q\), and generates pseudorandom bits by repeatedly squaring a seed value modulo \(n = p \times q\).
blumb_blumb_shub(seed, p, q, n)
Initial seed for the generator. This should be an integer such that \(gcd(seed, p \times q) = 1\).
A large prime number such that \(p \mod 4 = 3\).
A large prime number such that \(q \mod 4 = 3\).
Number of pseudorandom numbers (or bits) to generate.
A numeric vector of pseudorandom values generated by the Blum Blum Shub algorithm.
The generator operates as follows: 1. Select two large prime numbers, \(p\) and \(q\), such that both \(p \mod 4 = 3\) and \(q \mod 4 = 3\). 2. Set \(n = p \times q\). 3. Choose a seed \(s\) such that \(gcd(s, n) = 1\). 4. Generate the sequence using \(x_{i+1} = (x_i)^2 \mod n\), where the initial \(x_0 = s^2 \mod n\). 5. Output the least significant bit (or several bits) of each \(x_i\) as the pseudorandom output.
Lenore Blum, Manuel Blum, and Michael Shub, "A Simple Unpredictable Pseudo-Random Number Generator", SIAM Journal on Computing, 1986.
if (FALSE) {
# Example usage of the blumb_blumb_shub function
random_numbers <- blumb_blumb_shub(6, 103, 563, 1000)
plot(random_numbers)
}