# Cryptography/Blum-Goldwasser

The Blum-Goldwasser (BG) cryptosystem is an asymmetric key encryption algorithm proposed by Manuel Blum and Shafi Goldwasser in 1984. Blum-Goldwasser is a probabilistic, semantically secure cryptosystem with a constant-size ciphertext expansion. The encryption algorithm implements an XOR-based stream cipher using the Blum Blum Shub (BBS) pseudo-random number generator to generate the keystream. Decryption is accomplished by manipulating the final state of the BBS generator using the private key, in order to find the initial seed and reconstruct the keystream.

The BG cryptosystem is semantically secure based on the assumed intractability of integer factorization; specifically, factoring a composite value ${\displaystyle N=pq}$ where ${\displaystyle p,q}$ are large primes. BG has multiple advantages over earlier probabilistic encryption schemes such as the Goldwasser-Micali cryptosystem. First, its semantic security reduces solely to integer factorization, without requiring any additional assumptions (e.g., hardness of the quadratic residuosity problem or the RSA problem). Secondly, BG is efficient in terms of storage, inducing a constant-size ciphertext expansion regardless of message length. BG is also relatively efficient in terms of computation, and fares well even in comparison with cryptosystems such as RSA (depending on message length and exponent choices). However, BG is highly vulnerable to adaptive chosen ciphertext attacks (see below).

Because encryption is performed using a probabilistic algorithm, a given plaintext may produce very different ciphertexts each time it is encrypted. This has significant advantages, as it prevents an adversary from recognizing intercepted messages by comparing them to a dictionary of known ciphertexts.

## Scheme definition

Note that the following description is a draft, and may contain errors!

Blum-Goldwasser consists of three algorithms: a probabilistic key generation algorithm which produces a public and a private key, a probabilistic encryption algorithm, and a deterministic decryption algorithm.

### Key generation

To allow for decryption, the modulus used in Blum-Goldwasser encryption should be a Blum integer. This value is generated in the same manner as an RSA modulus, except that the prime factors ${\displaystyle (p,q)}$  must be congruent to 3 mod 4. (See RSA, key generation for details.)

1. Alice generates two large prime numbers ${\displaystyle p\,}$  and ${\displaystyle q\,}$  such that ${\displaystyle p\neq q}$ , randomly and independently of each other, where ${\displaystyle (p,q)\equiv 3}$  mod ${\displaystyle 4}$ .[1]
2. Alice computes ${\displaystyle N=pq}$ .

The public key is ${\displaystyle N}$ . The private key is the factorization ${\displaystyle (p,q)}$ . [1]

1. Alice keeps the private key secret.
1. Alice gives ${\displaystyle N}$  to Bob.

### Message encryption

Suppose Bob wishes to send a message m to Alice:

1. Bob first encodes ${\displaystyle m}$  as a string of ${\displaystyle L}$  bits ${\displaystyle (m_{0},\dots ,m_{L-1})}$ .
2. Bob selects a random element ${\displaystyle r}$ , where ${\displaystyle 1 , and computes ${\displaystyle x_{0}=r^{2}~mod~N}$ .
3. Bob uses the BBS pseudo-random number generator to generate ${\displaystyle L}$  random bits ${\displaystyle {\vec {b}}=(b_{0},\dots ,b_{L-1})}$  (the keystream), as follows:
1. For ${\displaystyle i=0}$  to ${\displaystyle L}$ :
2. Set ${\displaystyle b_{i}}$  equal to the least-significant bit of ${\displaystyle x_{i}}$ .
3. Increment ${\displaystyle i}$ .
4. Compute ${\displaystyle x_{i}=(x_{i-1})^{2}~mod~N}$ .
4. Bob computes the ciphertext bits using the bits from the BBS as a stream cipher keystream, XORing the plaintext bits with the keystream:
1. For ${\displaystyle i=0}$  to ${\displaystyle L-1}$ :
2. ${\displaystyle {\vec {c}}={\vec {m}}\oplus {\vec {b}}}$
1. Bob sends a message to Alice -- the enciphered bits and the final ${\displaystyle x_{L}}$  value ${\displaystyle (c_{0},\dots ,c_{L-1}),x_{L}}$ .

(The value ${\displaystyle x_{L}}$  is equal to ${\displaystyle x_{L}=x_{0}^{2^{L}}~mod~N}$ . )

To improve performance, the BBS generator can securely output up to ${\displaystyle O(loglogN)}$  of the least-significant bits of ${\displaystyle x_{i}}$  during each round. See Blum Blum Shub for details.

### Message decryption

Alice receives ${\displaystyle (c_{0},\dots ,c_{L-1}),y}$ . She can recover ${\displaystyle m}$  using the following procedure:

1. Using the prime factorization ${\displaystyle (p,q)}$ , Alice computes ${\displaystyle r_{p}=y^{((p+1)/4)^{L}}~mod~p}$  and ${\displaystyle r_{q}=y^{((q+1)/4)^{L}}~mod~q}$ .
2. Compute the initial seed ${\displaystyle x_{0}=(q(q^{-1}~{mod}~p)r_{p}+p(p^{-1}~{mod}~q)r_{q})~{mod}~N}$
3. From ${\displaystyle x_{0}}$ , recompute the bit-vector ${\displaystyle {\vec {b}}}$  using the BBS generator, as in the encryption algorithm.
4. Compute the plaintext by XORing the keystream with the ciphertext: ${\displaystyle {\vec {m}}={\vec {c}}\oplus {\vec {b}}}$ .

Alice recovers the plaintext ${\displaystyle m=(m_{0},\dots ,m_{L-1})}$ .

## Security and efficiency

The Blum-Goldwasser scheme is semantically-secure based on the hardness of predicting the keystream bits given only the final BBS state ${\displaystyle y}$  and the public key ${\displaystyle N}$ . However, ciphertexts of the form ${\displaystyle {\vec {c}},y}$  are vulnerable to an adaptive chosen ciphertext attack in which the adversary requests the decryption ${\displaystyle m^{\prime }}$  of a chosen ciphertext ${\displaystyle {\vec {a}},y}$ . The decryption ${\displaystyle m}$  of the original ciphertext can be computed as ${\displaystyle {\vec {a}}\oplus m^{\prime }\oplus {\vec {c}}}$ .

Depending on plaintext size, BG may be more or less computationally expensive than RSA. Because most RSA deployments use a fixed encryption exponent optimized to minimize encryption time, RSA encryption will typically outperform BG for all but the shortest messages. However, as the RSA decryption exponent is randomly distributed, modular exponentiation may require a comparable number of squarings/multiplications to BG decryption for a ciphertext of the same length. BG has the advantage of scaling more efficiently to longer ciphertexts, where RSA requires multiple separate encryptions. In these cases, BG may be significantly more efficient.

## References

1. a b RFC 4086 section "6.2.2. The Blum Blum Shub Sequence Generator"
1. M. Blum, S. Goldwasser, "An Efficient Probabilistic Public Key Encryption Scheme which Hides All Partial Information", Proceedings of Advances in Cryptology - CRYPTO '84, pp. 289–299, Springer Verlag, 1985.
2. Menezes, Alfred; van Oorschot, Paul C.; and Vanstone, Scott A. Handbook of Applied Cryptography. CRC Press, October 1996. ISBN 0-8493-8523-7