Documentation

CslibFrontier.Crypto.Protocols.SigmaProtocol.EqualPlaintexts

Equal plaintexts under one ElGamal key #

Example 20.2 of [BS23] (pp. 825–826), in additive notation: for a public key u and two multiplicative-ElGamal ciphertexts (v₀, e₀) and (v₁, e₁), the Chaum–Pedersen protocol on the triple (u, v₀ - v₁, e₀ - e₁) proves the relation (20.2): there is a β with β • g = v₀ - v₁ and β • u = e₀ - e₁ ([BS23], p. 826). When g generates the group, this says that both ciphertexts encrypt the same message (exists_equalPlaintextsRelation_iff). Neither the message nor the two encryption exponents are needed.

The protocol is SigmaProtocol.comap of chaumPedersen along the statement map equalPlaintextsTriple, with the identity on witnesses, so completeness, special soundness and special HVZK are those of chaumPedersen. Special soundness and special HVZK here are the library's SigmaProtocol.SpecialSoundness and SigmaProtocol.SpecialHVZK: an extractor that returns a witness from two accepting transcripts, and a simulator whose transcript law equals the honest one at each fixed challenge. The efficiency of the extractor and simulator, which [BS23], Definitions 19.4 and 19.5, also ask for, is a separate property (EfficientSpecialSoundness, EfficientSpecialHVZK) that is not proved here.

Main definitions #

Main results #

References #

def Cslib.Crypto.Protocols.SigmaProtocol.equalPlaintextsRelation {q : ℕ} {G : Type} [AddCommGroup G] [Module (ZMod q) G] (g : G) (β : ZMod q) :
G × (G × G) × G × G → Prop

The relation of [BS23], Example 20.2, equation (20.2) (p. 826), in additive notation: a witness for a public key u and ciphertexts (v₀, e₀) and (v₁, e₁) is β with β • g = v₀ - v₁ and β • u = e₀ - e₁.

The statement map of [BS23], Example 20.2 (p. 826): a public key u and ciphertexts (v₀, e₀) and (v₁, e₁) go to the triple (u, v₀ - v₁, e₀ - e₁).

The language #

theorem Cslib.Crypto.Protocols.SigmaProtocol.equalPlaintextsRelation_sub {q : ℕ} {G : Type} [AddCommGroup G] [Module (ZMod q) G] (g u m : G) (β₀ β₁ : ZMod q) :
equalPlaintextsRelation g (β₀ - β₁) (u, (β₀ • g, β₀ • u + m), β₁ • g, β₁ • u + m)

Two encryptions (β₀ • g, β₀ • u + m) and (β₁ • g, β₁ • u + m) of one message under one key satisfy (20.2) with β = β₀ - β₁ ([BS23], Example 20.2, p. 826).

theorem Cslib.Crypto.Protocols.SigmaProtocol.exists_equalPlaintextsRelation_iff {q : ℕ} {G : Type} [AddCommGroup G] [Module (ZMod q) G] {g : G} (hg : Function.Surjective fun (β : ZMod q) => β • g) (u : G) (ct₀ ct₁ : G × G) :
(∃ (β : ZMod q), equalPlaintextsRelation g β (u, ct₀, ct₁)) ↔ ∃ (m : G) (β₀ : ZMod q) (β₁ : ZMod q), ct₀ = (β₀ • g, β₀ • u + m) ∧ ct₁ = (β₁ • g, β₁ • u + m)

When g generates the group, a statement has a witness of (20.2) iff the two ciphertexts encrypt one message under the key u ([BS23], Example 20.2, p. 826). The generator hypothesis is used only from left to right.

theorem Cslib.Crypto.Protocols.SigmaProtocol.equalPlaintextsRelation_reencrypt {q : ℕ} {G : Type} [AddCommGroup G] [Module (ZMod q) G] (g u : G) (ct : G × G) (β : ZMod q) :
equalPlaintextsRelation g (-β) (u, ct, ct.1 + β • g, ct.2 + β • u)

Re-encryption ([BS23], Example 20.2, p. 826): for any pair (v, e) and exponent β, the pair (v, e) and its re-encryption (v + β • g, e + β • u) satisfy (20.2), with witness -β. Both are encryptions of one message under u when (v, e) is an encryption (β₀ • g, β₀ • u + m), or, for every pair, when g generates the group (exists_equalPlaintextsRelation_iff). Without either, the relation can hold for a pair that is no encryption: with g = u = 0, a pair whose first component is nonzero. The book writes β for both this exponent and the witness of (20.2); they differ by a sign.

The protocol #

noncomputable def Cslib.Crypto.Protocols.SigmaProtocol.equalPlaintexts {q : ℕ} {G : Type} [AddCommGroup G] [Module (ZMod q) G] [NeZero q] {C : Type} [DecidableEq G] (ι : C ↪ ZMod q) (g : G) :
SigmaProtocol (ZMod q) (G × (G × G) × G × G) (G × G) C (ZMod q)

The protocol of [BS23], Example 20.2 (p. 826): the Chaum–Pedersen protocol on the triple (u, v₀ - v₁, e₀ - e₁).

@[simp]
theorem Cslib.Crypto.Protocols.SigmaProtocol.equalPlaintexts_accepts_iff {q : ℕ} {G : Type} [AddCommGroup G] [Module (ZMod q) G] [NeZero q] {C : Type} [DecidableEq G] {ι : C ↪ ZMod q} {g u : G} {ct₀ ct₁ t : G × G} {c : C} {z : ZMod q} :
(equalPlaintexts ι g).Accepts (u, ct₀, ct₁) t c z ↔ z • g = t.1 + ι c • (ct₀.1 - ct₁.1) ∧ z • u = t.2 + ι c • (ct₀.2 - ct₁.2)

The verification equations z • g = t₁ + c • (v₀ - v₁) and z • u = t₂ + c • (e₀ - e₁).

Honest conversations are accepting.

Special soundness as SigmaProtocol.SpecialSoundness: from two accepting conversations with a common commitment and distinct challenges, the Chaum–Pedersen extractor, run on the triple, returns a witness of (20.2). The extractor's efficiency is a separate property, not proved here.

Special honest-verifier zero knowledge as SigmaProtocol.SpecialHVZK, with the Chaum–Pedersen simulator run on the triple: its conversations are accepting, and for a witness-statement pair its transcript law at each fixed challenge equals the honest prover's. The simulator's efficiency is a separate property, not proved here.

theorem Cslib.Crypto.Protocols.SigmaProtocol.equalPlaintexts_sound {q : ℕ} {G : Type} [AddCommGroup G] [Module (ZMod q) G] [NeZero q] {C : Type} [DecidableEq G] {ι : C ↪ ZMod q} {g : G} [Fact (Nat.Prime q)] [Fintype C] [Nonempty C] (hg : Function.Surjective fun (β : ZMod q) => β • g) (langOut : Set Unit := Set.univ) :
Interactive.Verifier.Sound Interactive.World.plain (equalPlaintexts ι g).toInteractiveVerifier {(u, ct₀, ct₁) : G × (G × G) × G × G | ∃ (m : G) (β₀ : ZMod q) (β₁ : ZMod q), ct₀ = (β₀ • g, β₀ • u + m) ∧ ct₁ = (β₁ • g, β₁ • u + m)} langOut (1 / ↑(Fintype.card C))

Soundness with error 1 / |C| against arbitrary provers ([BS23], Theorem 20.1, eq. (20.1), p. 824, applied to Example 20.2, p. 826): when q is prime and g generates the group, on a public key and two ciphertexts that do not encrypt one message, every prover makes the verifier accept with output in langOut with probability at most 1 / |C|.