Documentation

CslibFrontier.Crypto.Computational.StrongRSA

The strong RSA assumption #

[BS23], §10.9, p. 420, calls a pair (G, g) of a finite abelian group G and an element g ∈ G a group of unknown order when the size of G is hard to deduce from (G, g); a probabilistic algorithm GGen draws it. In the strong RSA game the adversary receives (G, g) and wins when it outputs (x, e) ∈ G × ℤ with x ^ e = g and e ≠ ±1. GGen satisfies the strong RSA assumption when no efficient adversary wins with non-negligible probability. The book remarks that this is a stronger assumption than standard RSA; no implication between StrongRSA and RSAOneWay or RSAUnitOneWay is formalized here. On p. 421 the book observes that the assumption is false when the order u of g, or a multiple of it, is known: for v > 1 coprime to u, the element x = g ^ (v⁻¹ mod u) satisfies x ^ v = g. Its example of GGen draws an RSA modulus n from RSAGen(ℓ, e) and a uniform g ∈ ℤₙ*.

Main definitions #

Main results #

Implementation notes #

The statements differ from the book's in three ways.

References #

The public parameters (G, g) of a group of unknown order ([BS23], §10.9, p. 420) for G = (ZMod N)ˣ: the modulus N and the base g.

  • modulus : ℕ

    The modulus N; the group is (ZMod N)ˣ.

  • base : ℕ

    The base g, a unit modulo N under rsaGUOSetup.

The encoding of the public parameters: N and g in binary, N framed (encGUOParams_apply).

theorem Cslib.Crypto.encGUOParams_modulus_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → GUOParams} :
@[reducible, inline]

The tuple of the fields of encGUOParams.

theorem Cslib.Crypto.encGUOParams_mk_inO {γ : Type} {encIn : γ ↪ List Bool} {x0 T0 S0 x1 T1 S1 : γ → ℕ} (h0 : Turing.MultiTapeTM.ComputableInO x0 encIn Turing.MultiTapeTM.encNat T0 S0) (h1 : Turing.MultiTapeTM.ComputableInO x1 encIn Turing.MultiTapeTM.encNat T1 S1) :
Turing.MultiTapeTM.ComputableInO (fun (x : γ) => { modulus := x0 x, base := x1 x }) encIn encGUOParams (fun (x : γ) => T0 x + T1 x) fun (x : γ) => S0 x + S1 x
theorem Cslib.Crypto.encGUOParams_base_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → GUOParams} :
theorem Cslib.Crypto.encGUOParams_mk_budget {γ : Type} {encIn : γ ↪ List Bool} {budget x0 x1 : γ → ℕ} (h0 : Turing.MultiTapeTM.ComputableInSpace x0 encIn Turing.MultiTapeTM.encNat budget) (h1 : Turing.MultiTapeTM.ComputableInSpace x1 encIn Turing.MultiTapeTM.encNat budget) :
Turing.MultiTapeTM.ComputableInSpace (fun (x : γ) => { modulus := x0 x, base := x1 x }) encIn encGUOParams budget
@[reducible, inline]

An adversary of the strong RSA game: given the security parameter and the public parameters (N, g), it outputs a pair (x, e). StrongRSAAdversary.IsPPT states its efficiency on encodings.

A strong RSA adversary is PPT when one uniform strict PPT machine reads the unary security parameter followed by encGUOParams, and writes (x, e) as a pair of binary numbers.

The winning condition of the strong RSA game ([BS23], §10.9, p. 420) in (ZMod N)ˣ: x ^ e and g agree modulo N, computed with powMod, and e ≠ 1. For 0 < N this is x ^ e ≡ g [MOD N] ∧ e ≠ 1 (isStrongRSASolution_eq_true_iff). For N = 0, powMod 0 x e = 1, so (x, e) wins exactly when g = 1 and e ≠ 1.

For 0 < N, (x, e) wins exactly when x ^ e ≡ g [MOD N] and e ≠ 1.

noncomputable def Cslib.Crypto.strongRSAGame (setup : ℕ → PMF GUOParams) (A : StrongRSAAdversary) (n : ℕ) :

The strong RSA game ([BS23], §10.9, p. 420): draw p ← setup n, run the adversary on (n, p), and accept its output (x, e) when isStrongRSASolution p (x, e).

The strong RSA assumption for the setup law setup ([BS23], §10.9, p. 420): every PPT adversary wins strongRSAGame with negligible probability. Two differences from the book. The group is (ZMod N)ˣ for public parameters (N, g) drawn from any law, which need not be efficiently samplable or give a unit g, in place of a group of unknown order from an efficient GGen; rsaGUOSetup gen is the book's GGen (p. 421). The adversary outputs natural numbers x and e ≠ 1 in place of x ∈ G and an integer e ≠ ±1. For a unit g, every output that wins here gives one that wins the book's game, so for a setup that gives a unit g the book's assumption implies this one.

noncomputable def Cslib.Crypto.rsaGUOSetup (gen : RSAGen) (n : ℕ) :

The group generator GGen of [BS23], §10.9, p. 421, for the RSA key generator gen: draw desc ← gen n and a uniform unit g modulo N = desc.modulus, and return (N, g) with g read in [0, N). The book draws n from RSAGen(ℓ, e); here gen is any law on RSADesc. Every base it draws is a unit (exists_of_mem_support_rsaGUOSetup).

theorem Cslib.Crypto.exists_of_mem_support_rsaGUOSetup {gen : RSAGen} {n : ℕ} {p : GUOParams} (hp : p ∈ (rsaGUOSetup gen n).support) :
∃ desc ∈ (gen n).support, p.modulus = desc.modulus ∧ p.base.Coprime p.modulus

Every (N, g) drawn by rsaGUOSetup gen n has the modulus N of a key in the support of gen n and a base g coprime to N.

The known-order observation #

The root g ^ (v⁻¹ mod u) modulo N of [BS23], §10.9, p. 421, with v⁻¹ mod u computed as BinaryGcd.modInv v u. When g ^ u ≡ 1 [MOD N] for some 0 < u and v is coprime to u, it is a v-th root of g (powMod_knownOrderRoot). The book does not name it; knownOrderRoot is this library's name.

theorem Cslib.Crypto.powMod_knownOrderRoot {N u v g : ℕ} (hu : 0 < u) (hg : g ^ u ≡ 1 [MOD N]) (hv : v.Coprime u) :

For 0 < u with g ^ u ≡ 1 [MOD N] and v coprime to u, knownOrderRoot N u v g is a v-th root of g modulo N ([BS23], §10.9, p. 421). There is no condition on N.

The adversary of [BS23], §10.9, p. 421, for exponents u and v computed from the security parameter and the public parameters: on (n, (N, g)) it outputs (knownOrderRoot N u v g, v) for u = u n (N, g) and v = v n (N, g). The book does not name it; knownOrderAdversary is this library's name.

theorem Cslib.Crypto.strongRSAGame_knownOrderAdversary (setup : ℕ → PMF GUOParams) (u v : ℕ → GUOParams → ℕ) (n : ℕ) (h : ∀ p ∈ (setup n).support, p.base ^ u n p ≡ 1 [MOD p.modulus] ∧ (v n p).Coprime (u n p) ∧ v n p ≠ 1) :

The known-order adversary wins strongRSAGame with probability 1 at a security parameter n where, for every (N, g) in the support of setup n, g ^ u ≡ 1 [MOD N], v is coprime to u and v ≠ 1 ([BS23], §10.9, p. 421).

The known-order adversary wins with probability 1, so StrongRSA setup does not hold, when polynomial-time functions u and v of the security parameter and (N, g) give, for every (N, g) in the support of every setup n, g ^ u ≡ 1 [MOD N] and an exponent v ≠ 1 coprime to u. This is the general form of the observation of [BS23], §10.9, p. 421, with the exponent v chosen by the caller; not_strongRSA_of_orderMultiple is the book's form, with hypotheses on u alone.

The adversary of [BS23], §10.9, p. 421, for a multiple u of the order of g computed from the security parameter and the public parameters: it takes v = u + 1, which is greater than 1 and coprime to u, and outputs (knownOrderRoot N u (u + 1) g, u + 1). The book does not name it; orderMultipleAdversary is this library's name.

The order-multiple adversary is PPT when u is computable in polynomial time from the unary security parameter and encGUOParams.

theorem Cslib.Crypto.strongRSAGame_orderMultipleAdversary (setup : ℕ → PMF GUOParams) (u : ℕ → GUOParams → ℕ) (n : ℕ) (h : ∀ p ∈ (setup n).support, 0 < u n p ∧ p.base ^ u n p ≡ 1 [MOD p.modulus]) :

The order-multiple adversary wins strongRSAGame with probability 1 at a security parameter n where, for every (N, g) in the support of setup n, 0 < u and g ^ u ≡ 1 [MOD N] ([BS23], §10.9, p. 421).

The strong RSA assumption does not hold when a multiple of the order is known ([BS23], §10.9, p. 421). If a polynomial-time function u of the security parameter and (N, g) gives, for every (N, g) in the support of every setup n, a positive multiple of the order of g modulo N (0 < u and g ^ u ≡ 1 [MOD N]), then orderMultipleAdversary u is PPT (isPPT_orderMultipleAdversary) and wins with probability 1 (strongRSAGame_orderMultipleAdversary), so StrongRSA setup is false.