Collision resistance from RSA #
[BS23], §10.6.2, defines a hash function from an RSA modulus n, a prime encryption
exponent e and a random unit y modulo n (p. 415): H_rsa(a, b) = a ^ e * y ^ b for a unit
a modulo n and 0 ≤ b < e. Theorem 10.7 (pp. 416–417) says that H_rsa is collision
resistant under the RSA assumption, with the bound (10.3) CRadv[A, H_rsa] ≤ RSAadv[B, ℓ, e]. The
proof turns a collision (a, b) ≠ (a', b') into (a / a') ^ e = y ^ (b' - b); then b ≠ b', so
b' - b is coprime to the prime e, and Shamir's trick (Theorem 10.6) gives an e-th root of
y. That is a win in the RSA game with a uniform unit preimage, and Theorem 10.5 bounds it by
the RSA advantage.
Here rsaHash is an instance of Cslib.Crypto.collisionGameFor, as
Cslib.Crypto.PrimeOrderGroupFamily.groupHash in
CslibFrontier/Crypto/Computational/DiscreteLog/GroupHash.lean is for the discrete-logarithm hash
H_dl. The key is an RSAHashKey, drawn by rsaHashSetup. A message is a word, and
validRSAHashInput accepts the words that encode a pair (a, b) with a < N coprime to N and
b < e.
Main definitions #
Cslib.Crypto.RSAHashKey,Cslib.Crypto.encRSAHashKey: the key(N, e, y)and its encoding.Cslib.Crypto.rsaHashSetup: draws an RSA key from a generator and a uniform unity.Cslib.Crypto.rsaHash,Cslib.Crypto.validRSAHashInput: the hashH_rsaon words and its domain.Cslib.Crypto.rsaHashRoot: thee-th root ofythat Shamir's trick computes from a collision.Cslib.Crypto.rsaHashToRSA: the adversaryB'of the proof of Theorem 10.7, an inverter for the RSA game with a uniform unit preimage.
Main results #
Cslib.Crypto.rsaEval_rsaHashRoot: forecoprime tob.dist b',rsaHashRootturns pairs(a, b),(a', b')with equal hashes into ane-th root ofy.Cslib.Crypto.isPPT_rsaHashToRSA,Cslib.Crypto.computableInPolyTime_rsaHash,Cslib.Crypto.computableInPolyTime_validRSAHashInput: the reduction is PPT, and the hash and its domain are computable in polynomial time.Cslib.Crypto.succProbability_collisionGameFor_rsaHash_le_rsaUnitInversionGame: the success probability of a collision finder is at most that ofrsaHashToRSAin the RSA game with a uniform unit preimage, at every security parameter whereeis prime on the support.Cslib.Crypto.succProbability_collisionGameFor_rsaHash_le_rsaInversionGame: the bound (10.3).Cslib.Crypto.RSAUnitOneWay.collisionResistantForOn_rsaHash,Cslib.Crypto.RSAOneWay.collisionResistantForOn_rsaHash: Theorem 10.7, from either RSA assumption.
Implementation notes #
The statements differ from the book's in four ways.
- The bound is
≤, where the proof showsCRadv[A, H_rsa] = uRSAadv[B', ℓ, e].rsaHashToRSAdoes not test the pair it receives, so it also wins on some pairs that the collision game rejects:encPair encNat encNat (1, 0) ++ [false]is not a valid word, but it decodes to(1, 0). The bound (10.3) needs only≤. - The domain
ℤₙ* × I_eis a set of words.validRSAHashInputrequires the word to be the encoding of the pair it decodes to, so that distinct valid words are distinct pairs. - Digests are natural numbers below
N, not units moduloN. - The book fixes a prime
e. Here keys come from any law onRSADesc(RSAGen), and the bounds assume thateis prime for every key in its support, eventually in the security parameter.rsaEval_rsaHashRootneeds only thateis coprime tob.dist b', as a primeegreater than bothbandb', withb ≠ b', is. Coprimality with(p - 1) * (q - 1)is not enough: forN = 15ande = 9, the pairs(1, 0)and(2, 3)collide aty = 2,9is not coprime to their distance3, and the pair gives no ninth root of2. There is no condition on the length parameterℓ.
The book's proof applies Theorem 10.6 with f = b' - b, which may be negative. rsaHashRoot
orders the pair instead: it takes f = b' - b and w = a * a'⁻¹ when b < b', and
f = b - b' and w = a' * a⁻¹ otherwise, so Cslib.Crypto.commonRoot keeps natural exponents.
The use of H_rsa as a compression function in the Merkle–Damgård construction (p. 416) is not
formalized; Exercises 10.25–10.26 (§10.11, p. 431) are in
CslibFrontier/Crypto/Computational/RSAUnitInversion/Converse.lean. The accumulator of §10.9
is in GUOAccumulator.lean, and its security under strong RSA in
CslibFrontier/Crypto/Computational/GUOAccumulator/Security.lean.
References #
- D. Boneh, V. Shoup, A Graduate Course in Applied Cryptography, Version 0.6,
§10.6.2, the definition of
H_rsa, p. 415; Theorem 10.7, pp. 416–417, with (10.3) on p. 417.
The key of the RSA hash ([BS23], §10.6.2, p. 415): an RSA public key (N, e) and a
base y.
- publicKey : RSAPublicKey
The public key
(N, e). - base : ℕ
The base
y, a unit moduloNin the experiment.
The tuple of the fields of encRSAHashKey.
The encoding of an RSA hash key: the public key, framed, and the base in binary.
Messages of the RSA hash are read as pairs of binary numbers.
The key law of the RSA hash ([BS23], §10.6.2, p. 415): draw desc ← gen n and a
uniform unit y modulo N, and return the public key with base y.
The RSA hash H_rsa(a, b) = a ^ e * y ^ b ([BS23], §10.6.2, p. 415), on the pair
(a, b) that the word m decodes to, as a natural number below N (for 0 < N).
The domain ℤₙ* × I_e of the RSA hash ([BS23], §10.6.2, p. 415) on words: m is
the encoding of the pair (a, b) it decodes to, a < N is coprime to N, and b < e.
The e-th root of y modulo N from a collision (a, b), (a', b') of the RSA hash, as in
the proof of [BS23], Theorem 10.7 (p. 417): Shamir's trick (commonRoot) with
f = b' - b and w = a * a'⁻¹ mod N when b < b', and with f = b - b' and
w = a' * a⁻¹ mod N otherwise.
The output of rsaHashRoot is below a positive modulus.
The root from a collision ([BS23], proof of Theorem 10.7, p. 417). For e
coprime to b.dist b' (b' - b if b ≤ b', else b - b'), units y, a and a' modulo N
with y < N and a ^ e * y ^ b ≡ a' ^ e * y ^ b' [MOD N], rsaHashRoot returns an e-th root
of y. As in the book, a prime e greater than both b and b', with b ≠ b', is coprime to
b.dist b'; b = b' is allowed and forces e = 1.
The adversary B' of the proof of [BS23], Theorem 10.7 (p. 417): on a public key
(N, e) and a challenge y, run the collision finder on the key (N, e, y), decode its two words
to pairs and return rsaHashRoot of them. It does not check that the pair is a collision.
rsaHashRoot is computable in polynomial time whenever its seven inputs are.
rsaHashToRSA A is a PPT RSAInverter whenever the collision finder A is PPT on
(1ⁿ, k).
The RSA hash is computable in polynomial time from the key and the word.
The domain test of the RSA hash is computable in polynomial time.
The reduction of Theorem 10.7 ([BS23], p. 417): at every security parameter n
where e is prime for every key in the support of gen n, the success probability of a collision
finder A against the RSA hash is at most that of rsaHashToRSA A in the RSA game with a uniform
unit preimage. The book proves equality, CRadv[A, H_rsa] = uRSAadv[B', ℓ, e]; rsaHashToRSA
does not test its pair, so it can also win when the pair is not a collision.
The bound (10.3) ([BS23], Theorem 10.7, p. 417): at every security parameter
n where e is prime for every key in the support of gen n, the success probability of a
collision finder A against the RSA hash is at most that of the elementary wrapper
unitRSAToRSA (rsaHashToRSA A) in rsaInversionGame.
Theorem 10.7 from the unit-preimage RSA assumption ([BS23], §10.6.2,
pp. 416–417): if RSAUnitOneWay gen holds and, for all sufficiently large n, e is prime for
every key in the support of gen n, then the RSA hash is collision resistant on
validRSAHashInput under rsaHashSetup gen.
Theorem 10.7 ([BS23], §10.6.2, pp. 416–417): if RSAOneWay gen holds and, for
all sufficiently large n, e is prime for every key in the support of gen n, then the RSA
hash is collision resistant on validRSAHashInput under rsaHashSetup gen.