Documentation

CslibFrontier.Crypto.Protocols.SigmaProtocol.RelatedNonce

Schnorr signatures with related nonces #

In Schnorr's random-oracle signature scheme ([BS23], Section 19.2), signing two messages m₀ ≠ m₁ under nonces r and a * r + b with known a, b : ZMod q exposes the signing key via relatedNonceExtract whenever a * ι c₀ ≠ ι c₁ ([BS23], Exercise 19.1). Under a lazily sampled uniform random oracle, a two-query attacker recovers the secret key with probability at least 1 - 1 / |C| (one_sub_inv_card_le_succProbability_relatedNonceGame). This is a step toward Exercise 19.1, not the cited result: an attack is only meaningful for an efficient adversary, since an unbounded one can compute the key from the public key, and nothing here certifies relatedNonceAttacker as efficient. The word-level game for general (a, b) is open (#5293).

Differences from Boneh–Shoup. The book fixes a cyclic group with generator g, hashes to a challenge set C, and states that the adversary recovers the secret key with high probability. Here the ambient group is an additive ZMod q-module with an arbitrary base g and challenge embedding ι : C ↪ ZMod q (schnorrROMScheme), for honest responses the formula returns the key for any base g whenever a * ι c₀ ≠ ι c₁ (relatedNonceExtract_respond), and the explicit lower bound 1 - 1 / |C| assumes m₀ ≠ m₁ (needed because equal messages with a = 1, b = 0 repeat the random-oracle query and force a * ι c₀ = ι c₁). Only the exact-security typed ROM experiment is defined here; polynomial-time word extraction is separate in CslibFrontier.Crypto.Computational.SchnorrRelatedNonce, and the a = 0 leaked-nonce word game and PPT adversary are in CslibFrontier.Crypto.Computational.SchnorrLeakedNonce (general (a, b) word-level games remain open).

Main definitions #

Main results #

Step toward Exercise 19.1 #

References #

theorem Cslib.Crypto.Protocols.SigmaProtocol.schnorr_accepts_affine {q : ℕ} [NeZero q] {G C : Type} [AddCommGroup G] [Module (ZMod q) G] [DecidableEq G] {ι : C ↪ ZMod q} {g u t : G} {c : C} {z : ZMod q} (h : (schnorr ι g).Accepts u t c z) (a b : ZMod q) :
(schnorr (Function.Embedding.refl (ZMod q)) g).Accepts u (a • t + b • g) (a * ι c) (a * z + b)

An accepting Schnorr conversation with nonce r gives, for the full challenge space, an accepting conversation with nonce a * r + b: scale by a and shift by b.

def Cslib.Crypto.Protocols.SigmaProtocol.relatedNonceExtract {q : ℕ} (a b c₀ z₀ c₁ z₁ : ZMod q) :

The key computed from two Schnorr signatures whose nonces are r and a * r + b ([BS23], Exercise 19.1): from the challenges c₀, c₁ and the responses z₀, z₁. It is linearExtract at the conversation transformed by schnorr_accepts_affine.

theorem Cslib.Crypto.Protocols.SigmaProtocol.relatedNonceExtract_smul {q : ℕ} [NeZero q] {G C : Type} [AddCommGroup G] [Module (ZMod q) G] [DecidableEq G] {ι : C ↪ ZMod q} {g : G} [Fact (Nat.Prime q)] {u t₀ t₁ : G} {a b : ZMod q} {c₀ c₁ : C} {z₀ z₁ : ZMod q} (h₀ : (schnorr ι g).Accepts u t₀ c₀ z₀) (h₁ : (schnorr ι g).Accepts u t₁ c₁ z₁) (ht : t₁ = a • t₀ + b • g) (hc : a * ι c₀ ≠ ι c₁) :
relatedNonceExtract a b (ι c₀) z₀ (ι c₁) z₁ • g = u

Related nonces reveal a witness ([BS23], Exercise 19.1): from two accepting conversations for u whose commitments satisfy t₁ = a • t₀ + b • g, with a * ι c₀ ≠ ι c₁.

theorem Cslib.Crypto.Protocols.SigmaProtocol.relatedNonceExtract_respond {q : ℕ} [NeZero q] {G C : Type} [AddCommGroup G] [Module (ZMod q) G] [DecidableEq G] {ι : C ↪ ZMod q} {g : G} [Fact (Nat.Prime q)] (α : ZMod q) (u : G) (r a b : ZMod q) {c₀ c₁ : C} (hc : a * ι c₀ ≠ ι c₁) :
relatedNonceExtract a b (ι c₀) ((schnorr ι g).respond α u r c₀) (ι c₁) ((schnorr ι g).respond α u (a * r + b) c₁) = α

Related nonces reveal the signing key ([BS23], Exercise 19.1): from the honest responses with nonces r and a * r + b, with a * ι c₀ ≠ ι c₁. No hypothesis on g.

def Cslib.Crypto.Protocols.SigmaProtocol.relatedNonceAttacker {q : ℕ} {G C M : Type} (ι : C ↪ ZMod q) (a b : ZMod q) (m₀ : M) (σ₀ : G × ZMod q) (m₁ : M) (σ₁ : G × ZMod q) :
OracleComp (fun (x : M × G) => C) (ZMod q)

The adversary of [BS23], Exercise 19.1 in the random-oracle model: recompute the two challenges with two hash queries and return relatedNonceExtract.

theorem Cslib.Crypto.Protocols.SigmaProtocol.relatedNonceAttacker_isQueryBounded {q : ℕ} {G C M : Type} (ι : C ↪ ZMod q) (a b : ZMod q) (m₀ : M) (σ₀ : G × ZMod q) (m₁ : M) (σ₁ : G × ZMod q) :
(relatedNonceAttacker ι a b m₀ σ₀ m₁ σ₁).IsQueryBounded 2

The adversary of [BS23], Exercise 19.1 makes at most two hash queries.

noncomputable def Cslib.Crypto.Protocols.SigmaProtocol.relatedNonceGame {q : ℕ} [Fact (Nat.Prime q)] {G C M : Type} [AddCommGroup G] [Module (ZMod q) G] [DecidableEq G] [DecidableEq M] [Fintype C] [Nonempty C] (ι : C ↪ ZMod q) (g : G) (a b : ZMod q) (m₀ m₁ : M) :

The experiment of [BS23], Exercise 19.1: the Schnorr signer signs m₀ with a uniform nonce r and m₁ with the nonce a * r + b, under one lazily sampled random oracle; the adversary sees both signatures and wins when it returns the signing key.

theorem Cslib.Crypto.Protocols.SigmaProtocol.one_sub_inv_card_le_succProbability_relatedNonceGame {q : ℕ} [Fact (Nat.Prime q)] {G C M : Type} [AddCommGroup G] [Module (ZMod q) G] [DecidableEq G] [DecidableEq M] [Fintype C] [Nonempty C] (ι : C ↪ ZMod q) (g : G) (a b : ZMod q) {m₀ m₁ : M} (hm : m₀ ≠ m₁) :
1 - (↑(Fintype.card C))⁻¹ ≤ (relatedNonceGame ι g a b m₀ m₁).succProbability

Typed related-nonce key recovery, a step toward [BS23], Exercise 19.1, not the cited result: for two different messages signed with affine-related nonces r and a * r + b, relatedNonceAttacker recovers the signing key with probability at least 1 - 1 / |C|. An attack has content only for an efficient adversary; nothing here certifies relatedNonceAttacker as efficient, and the polynomial-time word extraction PrimeOrderGroupFamily.computableInPolyTime_schnorrRelatedNonceExtractWord is not yet joined to this game for general (a, b) (#5293). For a = 0 the certified attack is PrimeOrderGroupFamily.one_sub_inv_two_pow_le_succProbability_schnorrLeakedNonceWordGame.