Documentation

CatCryptCore.Examples.OT

Naor-Pinkas Oblivious Transfer (OT) #

This file formalizes the Naor-Pinkas (2001) DDH-based 1-out-of-2 OT protocol and proves both sender security (information-theoretic) and receiver security (DDH-based).

Protocol #

The receiver holds a choice bit σ ∈ {0,1}. The sender holds messages m₀, m₁ ∈ G.

  1. Receiver: Sample a, b, c from Exp. Send (g^a, g^b, z₀, z₁) where z_σ = g^{ab} (DDH triple) and z_{1-σ} = g^c (random).

  2. Sender: For each i ∈ {0,1}, sample (sᵢ, rᵢ), compute wᵢ = g^{a·sᵢ + rᵢ} and eᵢ = g^{dᵢ·sᵢ + b·rᵢ} · mᵢ where dᵢ is the exponent of zᵢ.

  3. Receiver: Decrypt m_σ using s_σ, r_σ (the DDH position is decryptable).

Security #

Sender security: When d ≠ ab (non-DDH position), the map (s, r) ↦ (as + r, ds + br) is a bijection on Exp × Exp, so (wᵢ, eᵢ) is uniformly distributed and the message is information-theoretically hidden (otEnc_message_independent). The honest receiver samples c uniformly, so c = ab occurs with probability 1 / |Exp|; ot_sender_secure bounds the real/ideal advantage by that probability.

Receiver security: The receiver's public values (g^a, g^b, z₀, z₁) contain a DDH triple at the choice position. Distinguishing σ=0 from σ=1 reduces to DDH.

References #

CyclicGroupRing: Exponent Ring Structure #

The sender security proof requires the matrix map (s,r) ↦ (as+r, ds+br) to be a bijection when d ≠ ab. This needs ring structure on exponents (addition, multiplication, distributivity) beyond what CyclicGroup provides.

Extension of CyclicGroup with ring structure on exponents.

The key new operations are expAdd (addition in Z_q) and the distributivity law expMul a (expAdd b c) = expAdd (expMul a b) (expMul a c). The crucial expMul_bij ensures multiplication by a nonzero element is bijective.

Instances

    Additive right cancellation: a + c = b + c → a = b

    Additive left cancellation: c + a = c + b → a = b

    Protocol Definitions #

    Sender encryption for one position.

    Given exponents (a, b, d) corresponding to (x = g^a, y = g^b, z = g^d), encrypt message m by sampling (s, r) and computing:

    • w = g^{as + r} (mask for receiver)
    • e = g^{ds + br} · m (encrypted message)

    When d = ab (DDH position), the receiver who knows s can compute g^{ds+br} and decrypt. When d ≠ ab, the pair (w, e) is uniform — m is hidden.

    Equations
    • One or more equations did not get rendered due to their size.
    Instances For
      @[reducible, inline]

      OT transcript: public keys + two ciphertexts

      Equations
      Instances For
        noncomputable def CatCrypt.Examples.OT.ot_real {G : Type} [CGR : CyclicGroupRing G] (m0 m1 : G) (sigma : Bool) :

        Real OT game: both messages are encrypted normally (no adversary substitution).

        Equations
        • One or more equations did not get rendered due to their size.
        Instances For
          noncomputable def CatCrypt.Examples.OT.ot_ideal {G : Type} [CGR : CyclicGroupRing G] (m0 m1 : G) (sigma : Bool) :

          Ideal OT game: the non-chosen message is replaced by the identity.

          Equations
          • One or more equations did not get rendered due to their size.
          Instances For

            The Naor-Pinkas encryption step otEnc does not read or write the heap.

            theorem CatCrypt.Examples.OT.ot_real_isPure {G : Type} [CGR : CyclicGroupRing G] (m0 m1 : G) (sigma : Bool) :
            (ot_real m0 m1 sigma).IsPure

            The real OT game ot_real does not read or write the heap.

            theorem CatCrypt.Examples.OT.ot_ideal_isPure {G : Type} [CGR : CyclicGroupRing G] (m0 m1 : G) (sigma : Bool) :
            (ot_ideal m0 m1 sigma).IsPure

            The ideal OT game ot_ideal does not read or write the heap.

            Matrix Bijection #

            The key algebraic fact for sender security: the linear map M(s, r) = (as + r, ds + br) on Exp × Exp is a bijection when d - ab ≠ 0.

            Sender Security #

            The key theorem: when d ≠ ab, the encryption otEnc a b d m produces a distribution independent of m. This is because the matrix map (s,r) ↦ (as+r, ds+br) is a bijection, so (w, e) is uniformly distributed.

            Translation equivalence on exponents: s ↦ s + c.

            Equations
            • One or more equations did not get rendered due to their size.
            Instances For

              Key lemma: otEnc a b d m0 = otEnc a b d m1 when d - ab ≠ 0.

              The proof uses a translation coupling. When d - ab ≠ 0, we can find a constant shift δ such that coupling s₀ ↔ s₀ + δ and r₀ ↔ r₀ - aδ preserves the first output component g^{as+r} and exactly compensates the message change in the second component g^{ds+br} · m.

              theorem CatCrypt.Examples.OT.advantageA_sample_bind_le_of_eq_off {α β : Type} [Fintype α] [Nonempty α] (f g : α → Core.SPComp β) (A : β → Core.SPComp Bool) (x₀ : α) (h : ∀ (x : α), x ≠ x₀ → f x = g x) :

              Sampling a uniform x and continuing with f x or with g x gives an advantage of at most 1 / |α| against every distinguisher, when f and g agree at every point except x₀.

              Sender security of Naor–Pinkas OT, statistical form.

              For every distinguisher A and every choice bit sigma, the real transcript (both messages encrypted) and the ideal transcript (the unchosen message replaced by the identity) are at advantage at most 1 / |Exp|. The two games coincide on every receiver sample with c ≠ a·b (otEnc_message_independent); the term 1 / |Exp| is the probability of the event c = a·b, on which the unchosen position is a DDH triple and its message is decryptable.

              Receiver Security #

              The receiver's public values (g^a, g^b, z₀, z₁) encode the choice bit σ: position σ has a DDH triple (g^a, g^b, g^{ab}), the other has a random g^c.

              Distinguishing σ=0 from σ=1 reduces to DDH via a standard hybrid argument.

              noncomputable def CatCrypt.Examples.OT.receiverView {G : Type} [CGR : CyclicGroupRing G] (sigma : Bool) :
              Core.SPComp (G × G × G × G)

              Receiver's view: what the sender sees (the public commitment).

              Equations
              • One or more equations did not get rendered due to their size.
              Instances For

                DDH reduction for receiver security.

                Equations
                • One or more equations did not get rendered due to their size.
                Instances For

                  Bridge lemma: monad pure equals SPComp.pure for simp matching.

                  The reduction with real DDH matches the receiver's view.

                  Receiver security: the advantage of distinguishing σ=0 from σ=1 is bounded by the sum of two DDH advantages.