Documentation

Complexity.Crypto.Computational.PedersenCommitment

Pedersen commitments over a prime-order group family #

Over a PrimeOrderGroupFamily, Pedersen's commitment scheme ([Ped92], Section 3, Theorem 3.1; [BS23], Section 8.12, Definition 8.8, Section 10.6.1, Fact 10.3 and Theorem 10.4, and Exercise 20.5) uses a group description d and a public commitment key h = α • g : F.Carrier d generated by a secret exponent α : ZMod (F.order d). To commit to a message m : ZMod (F.order d) with randomness r : ZMod (F.order d), the committer computes

pedersenCommit d h m r = m • g + r • h.

On encoded group elements and natural-number exponents, encodePedersenCommit computes F.encode d (F.pedersenCommit d h m r) in polynomial time from (d, encode h, m, r) using F.encode d (F.generator d), F.smul, and F.add.

We instantiate the general public-parameter CommitmentScheme (pedersenScheme) with canonical binary message words (ValidPedersenMessage), commitment-and-opening pair law (pedersenCommitPairLaw), and verification algorithm pedersenVerify (V(m, c, o)), and establish:

  1. Algebraic and homomorphic laws (pedersenCommit_zero, pedersenCommit_add, pedersenCommit_neg, pedersenCommit_sub, pedersenCommit_smul) and polynomial-time encoded evaluation (encodePedersenCommit, encodePedersenCommit_encode, computableInPolyTime_encodePedersenCommit).
  2. Unconditional hiding (pedersenCommitLaw_eq_uniform_of_ne_zero, pedersenCommitLaw_eq_of_ne_zero, pedersenHidingForKey_eq_of_ne_zero, advantage_pedersenHidingGame_le, negligible_advantage_pedersenHidingGame, pedersenScheme_statisticalHiding): for every non-identity commitment key h ≠ 0, a uniform blinding exponent r ← PMF.uniformOfFintype (ZMod (F.order d)) makes pedersenCommit d h m r uniformly distributed on F.Carrier d and independent of m. Consequently, at any fixed d and h ≠ 0, the chosen-message hiding distributions for bit = false and bit = true in F.pedersenScheme.hidingForKey ⟨d, h⟩ are identical against every (even computationally unbounded) two-stage adversary Encryption.WordAdversary. When the key exponent α ← PMF.uniformOfFintype (ZMod (F.order d)) is drawn uniformly from all of ZMod (F.order d) (matching discreteLogGame and [BS23], Exercise 20.5), the degenerate key α = 0 occurs with probability 1 / F.order d, bounding any unbounded adversary's hiding advantage in F.pedersenScheme.hidingGame (F.pedersenKeyDist setup) by 1 / m whenever supported groups have order at least m.
  3. Computational binding under the discrete-logarithm assumption (pedersenVerify, pedersenExtractNat, pedersenToDLAdversary, succProbability_pedersenBindingGame_le_discreteLogGame, isPPTOn_pedersenToDLAdversary, DiscreteLog.pedersenBinding, DiscreteLog.pedersenScheme_binding): any verified double opening (c, (m₀, o₀), (m₁, o₁)) with m₀ ≠ m₁ and pedersenVerify d h mᵢ c oᵢ = true for i ∈ {0, 1} under h = α • g has (ofBits m₀ : ZMod q) ≠ (ofBits m₁ : ZMod q), forces (ofBits o₀ : ZMod q) ≠ (ofBits o₁ : ZMod q), and yields α = (o₁ - o₀)⁻¹ * (m₀ - m₁) modulo q ([Ped92], Section 3, Theorem 3.1; [BS23], Section 10.6.1, Fact 10.3 and Theorem 10.4), computed in polynomial time via Fermat's little theorem (pedersenExtractNat). This gives an exact zero-loss reduction from F.pedersenScheme.bindingGame to discreteLogGame.

Main definitions #

Main results #

References #

Algebraic and encoded Pedersen commitments #

Algebraic Pedersen commitment ([Ped92], Section 3; [BS23], Section 10.6.1 and Exercise 20.5): commit to message m : ZMod (F.order d) with randomness r : ZMod (F.order d) under commitment key h : F.Carrier d as m • g + r • h.

Instances For
    theorem Cslib.Crypto.PrimeOrderGroupFamily.pedersenCommit_add (F : PrimeOrderGroupFamily) (d : F.Desc) (h : F.Carrier d) (m₁ r₁ m₂ r₂ : ZMod (F.order d)) :
    F.pedersenCommit d h (m₁ + m₂) (r₁ + r₂) = F.pedersenCommit d h m₁ r₁ + F.pedersenCommit d h m₂ r₂

    Additive homomorphism of Pedersen commitments: committing to (m₁ + m₂, r₁ + r₂) equals the sum of the individual commitments.

    theorem Cslib.Crypto.PrimeOrderGroupFamily.pedersenCommit_sub (F : PrimeOrderGroupFamily) (d : F.Desc) (h : F.Carrier d) (m₁ r₁ m₂ r₂ : ZMod (F.order d)) :
    F.pedersenCommit d h (m₁ - m₂) (r₁ - r₂) = F.pedersenCommit d h m₁ r₁ - F.pedersenCommit d h m₂ r₂
    theorem Cslib.Crypto.PrimeOrderGroupFamily.pedersenCommit_smul (F : PrimeOrderGroupFamily) (d : F.Desc) (h : F.Carrier d) (c m r : ZMod (F.order d)) :
    F.pedersenCommit d h (c * m) (c * r) = c • F.pedersenCommit d h m r

    Scalar-multiplication homomorphism of Pedersen commitments.

    Under a commitment key h = α • g, pedersenCommit d (α • g) m r = (m + r * α) • g.

    theorem Cslib.Crypto.PrimeOrderGroupFamily.pedersenCommit_smul_generator_eq_iff (F : PrimeOrderGroupFamily) (d : F.Desc) (α m₀ r₀ m₁ r₁ : ZMod (F.order d)) :
    F.pedersenCommit d (α • F.generator d) m₀ r₀ = F.pedersenCommit d (α • F.generator d) m₁ r₁ ↔ m₀ + r₀ * α = m₁ + r₁ * α

    Two openings (m₀, r₀) and (m₁, r₁) produce the same commitment under h = α • g if and only if m₀ + r₀ * α = m₁ + r₁ * α in ZMod (F.order d).

    Pedersen commitment on encoded group elements: given (d, encode h, m, r), compute encode (m • g + r • h).

    Instances For
      @[simp]

      encodePedersenCommit computes F.encode d (F.pedersenCommit d h m r) on encoded group elements.

      Unconditional hiding and CommitmentScheme packaging #

      The distribution of F.pedersenCommit d h m r when r is drawn uniformly from ZMod (F.order d).

      Instances For

        Perfect hiding for any non-identity commitment key h ≠ 0 ([Ped92], Section 3, Theorem 3.1): for every message m : ZMod (F.order d), F.pedersenCommitLaw d h m equals the uniform distribution (PMF.uniformOfFintype (ZMod (F.order d))).map (· • F.generator d) on F.Carrier d.

        Perfect hiding ([Ped92], Section 3, Theorem 3.1): for any h ≠ 0 and any two messages m₀, m₁ : ZMod (F.order d), the commitment distributions F.pedersenCommitLaw d h m₀ and F.pedersenCommitLaw d h m₁ are identical.

        theorem Cslib.Crypto.PrimeOrderGroupFamily.uniform_pedersenCommit (F : PrimeOrderGroupFamily) {β : Type u_1} (d : F.Desc) {h : F.Carrier d} (hh : h ≠ 0) (m : ZMod (F.order d)) (f : F.Carrier d → PMF β) :
        ((Probability.PMF.uniformOfFintype (ZMod (F.order d))).bind fun (r : ZMod (F.order d)) => f (F.pedersenCommit d h m r)) = (Probability.PMF.uniformOfFintype (ZMod (F.order d))).bind fun (γ : ZMod (F.order d)) => f (γ • F.generator d)

        Bind form of pedersenCommitLaw_eq_uniform_of_ne_zero: for any h ≠ 0 and message m, sampling r ← PMF.uniformOfFintype (ZMod (F.order d)) and passing F.pedersenCommit d h m r to a continuation f has the same distribution as sampling γ ← PMF.uniformOfFintype (ZMod (F.order d)) and passing γ • F.generator d.

        A message word m : List Bool is a canonical Pedersen message for group description d if ofBits m < F.order d and m is the canonical binary representation (ofBits m).bits. Requiring canonical binary representation ensures that distinct message words in the message space represent distinct elements of ZMod (F.order d).

        Instances For

          The distribution of (F.encode d (F.pedersenCommit d h m r), r.val.bits) (encoded commitment string and canonical binary opening string) when r is drawn uniformly from ZMod (F.order d).

          Instances For
            @[simp]

            The commitment-string marginal of pedersenCommitPairLaw is (pedersenCommitLaw d h m).map (F.encode d).

            Pedersen commitment verification V(m, c, o) ([BS23], Section 8.12, p. 344, and Section 10.6.1, p. 414; [Ped92], Section 3): verify that m is a canonical message word for d (ofBits m < F.order d and (ofBits m).bits = m) and that recomputing the commitment from (ofBits m, ofBits o) under (d, h) yields c.

            Instances For

              Correctness of pedersenVerify: every (c, o) in the support of pedersenCommitPairLaw d h (ofBits m) for a canonical message word m is accepted by pedersenVerify d h m c o.

              @[reducible, inline]

              A Pedersen commitment key over F: a group description d : F.Desc together with a public group element h : F.Carrier d.

              Instances For

                Draw d ← setup n and a uniform key exponent α ← PMF.uniformOfFintype (ZMod (F.order d)), returning the Pedersen key ⟨d, α • g⟩ ([BS23], Exercise 20.5, pp. 843–844).

                Instances For

                  Pedersen's commitment scheme as an instance of the general public-parameter CommitmentScheme ([BS23], Section 8.12, Definition 8.8, p. 344, and Section 10.6.1, p. 414; [Ped92], Section 3).

                  Instances For
                    theorem Cslib.Crypto.PrimeOrderGroupFamily.pedersenHidingForKey_eq_of_ne_zero (F : PrimeOrderGroupFamily) (d : F.Desc) {h : F.Carrier d} (hh : h ≠ 0) (adversary : Encryption.WordAdversary) (b₁ b₂ : Bool) (n : ℕ) :
                    F.pedersenScheme.hidingForKey ⟨d, h⟩ adversary b₁ n = F.pedersenScheme.hidingForKey ⟨d, h⟩ adversary b₂ n

                    For any non-identity commitment key h ≠ 0, F.pedersenScheme.hidingForKey ⟨d, h⟩ produces the exact same output distribution for any two hidden bits b₁ and b₂, against every (even computationally unbounded) Encryption.WordAdversary.

                    @[simp]

                    At any non-identity commitment key h ≠ 0, the hiding advantage of any (computationally unbounded) adversary between bit = false and bit = true is 0.

                    theorem Cslib.Crypto.PrimeOrderGroupFamily.pedersenHidingGame_apply_true_le (F : PrimeOrderGroupFamily) (setup : ℕ → PMF F.Desc) (adversary : Encryption.WordAdversary) (b₁ b₂ : Bool) (n m : ℕ) (hm : ∀ d ∈ (setup n).support, m ≤ F.order d) :
                    (F.pedersenScheme.hidingGame (F.pedersenKeyDist setup) adversary b₁ n) true ≤ (F.pedersenScheme.hidingGame (F.pedersenKeyDist setup) adversary b₂ n) true + (↑m)⁻¹

                    When every supported group at parameter n has order at least m, changing the hidden bit from b₁ to b₂ changes acceptance probability in F.pedersenScheme.hidingGame (F.pedersenKeyDist setup) by at most 1 / m (arising solely from the 1 / F.order d probability of sampling the degenerate key α = 0).

                    theorem Cslib.Crypto.PrimeOrderGroupFamily.advantage_pedersenHidingGame_le (F : PrimeOrderGroupFamily) (setup : ℕ → PMF F.Desc) (adversary : Encryption.WordAdversary) (n m : ℕ) (hm0 : 0 < m) (hm : ∀ d ∈ (setup n).support, m ≤ F.order d) :
                    (F.pedersenScheme.hidingGame (F.pedersenKeyDist setup) adversary false n).advantage (F.pedersenScheme.hidingGame (F.pedersenKeyDist setup) adversary true n) ≤ 1 / ↑m

                    Unconditional hiding bound for Pedersen commitments: when every supported group at parameter n has order at least m > 0, any (even computationally unbounded) Encryption.WordAdversary has distinguishing advantage at most 1 / m in F.pedersenScheme.hidingGame (F.pedersenKeyDist setup).

                    theorem Cslib.Crypto.PrimeOrderGroupFamily.negligible_advantage_pedersenHidingGame (F : PrimeOrderGroupFamily) (setup : ℕ → PMF F.Desc) (adversary : Encryption.WordAdversary) {m : ℕ → ℕ} (hm0 : ∀ (n : ℕ), 0 < m n) (hm : ∀ (n : ℕ), ∀ d ∈ (setup n).support, m n ≤ F.order d) (hinv : Negligible fun (n : ℕ) => 1 / ↑(m n)) :
                    Negligible fun (n : ℕ) => (F.pedersenScheme.hidingGame (F.pedersenKeyDist setup) adversary false n).advantage (F.pedersenScheme.hidingGame (F.pedersenKeyDist setup) adversary true n)

                    Asymptotic unconditional hiding of Pedersen commitments ([Ped92], Section 3, Theorem 3.1; [BS23], Section 8.12, Definition 8.8, and Exercise 20.5): when every supported group at parameter n has order at least m n > 0 and 1 / m n is negligible, every (even computationally unbounded) Encryption.WordAdversary has negligible advantage in F.pedersenScheme.hidingGame (F.pedersenKeyDist setup).

                    theorem Cslib.Crypto.PrimeOrderGroupFamily.pedersenScheme_statisticalHiding (F : PrimeOrderGroupFamily) (setup : ℕ → PMF F.Desc) {m : ℕ → ℕ} (hm0 : ∀ (n : ℕ), 0 < m n) (hm : ∀ (n : ℕ), ∀ d ∈ (setup n).support, m n ≤ F.order d) (hinv : Negligible fun (n : ℕ) => 1 / ↑(m n)) :

                    Statistical hiding (CommitmentScheme.StatisticalHiding) of pedersenScheme ([Ped92], Section 3, Theorem 3.1; [BS23], Section 8.12, Definition 8.8, and Exercise 20.5).

                    Computational binding under the discrete-logarithm assumption #

                    Extract the discrete logarithm (r₁ - r₀)⁻¹ * (m₀ - m₁) mod q from a Pedersen commitment collision ((m₀, r₀), (m₁, r₁)) ([Ped92], Section 3, Theorem 3.1; [BS23], Section 10.6.1, Fact 10.3, p. 415), computing the modular inverse via Fermat's little theorem as a (q - 2)-th power.

                    Instances For
                      theorem Cslib.Crypto.PrimeOrderGroupFamily.pedersenExtractNat_cast {q : ℕ} [Fact (Nat.Prime q)] {m₀ r₀ m₁ r₁ : ℕ} (hr : ↑r₁ ≠ ↑r₀) :
                      ↑(pedersenExtractNat q m₀ r₀ m₁ r₁) = (↑r₁ - ↑r₀)⁻¹ * (↑m₀ - ↑m₁)

                      Fermat's little theorem gives the modular inverse in pedersenExtractNat whenever (r₁ : ZMod q) ≠ (r₀ : ZMod q).

                      Any valid Pedersen binding collision (c, (m₀, o₀), (m₁, o₁)) under h = α • g recovers α via pedersenExtractNat ([Ped92], Section 3, Theorem 3.1; [BS23], Section 10.6.1, Fact 10.3).

                      Turn a pedersenScheme binding adversary into a discrete-logarithm adversary by passing the encoded Pedersen key encPair F.encDesc encBits input and extracting pedersenExtractNat in binary from the two candidate openings ([BS23], Section 10.6.1, Theorem 10.4, pp. 414–415).

                      Instances For

                        Exact binding-to-discrete-logarithm reduction ([BS23], Section 10.6.1, Theorem 10.4, pp. 414–415; [Ped92], Section 3, Theorem 3.1): for every security parameter n, the success probability of adversary in F.pedersenScheme.bindingGame (F.pedersenKeyDist setup) is at most the discrete-logarithm success probability of pedersenToDLAdversary adversary.

                        Computational binding of Pedersen commitments under the discrete-logarithm assumption ([Ped92], Section 3, Theorem 3.1; [BS23], Section 8.12, Definition 8.8, and Section 10.6.1, Theorem 10.4): if F.DiscreteLog setup holds, every uniform strict PPT adversary succeeds in F.pedersenScheme.bindingGame (F.pedersenKeyDist setup) with negligible probability.

                        Computational binding (CommitmentScheme.Binding) of pedersenScheme under the discrete-logarithm assumption ([Ped92], Section 3, Theorem 3.1; [BS23], Section 8.12, Definition 8.8, and Section 10.6.1, Theorem 10.4).