Documentation

CslibFrontier.Crypto.Protocols.MPC.DDHOT

Three-Message DDH 1-out-of-2 Oblivious Transfer #

This module formalizes a three-message 1-out-of-2 oblivious transfer protocol from the Decision Diffie-Hellman (DDH) assumption over a finite additive group G that is a ZMod q-module, with a public element g, expressed as a two-party protocol ddhOTProtocol in Cslib.Crypto.Protocols.MPC computing otFunctionality G (compatible with batchOTSpec 1 G from CslibFrontier/Crypto/Protocols/MPC/BatchOT.lean). Groups are written additively, so the textbook g^a is a • g. The protocol is a variant of the DDH-based protocol of [BS23], Section 23.5.7, Figure 23.17; DDH-based oblivious transfer of this kind goes back to [NP01]. Its rounds are:

  1. Round 1 (.message 0 1 G): The sender (party 0) samples a : ZMod q and sends u = a • g to the receiver (party 1).
  2. Round 2 (.message 1 0 (G × G)): The receiver samples b : ZMod q, sets v = b • g, and sends (w₀, w₁) = if σ then (u - v, v) else (v, u - v) so that the chosen branch key w_σ = v has known discrete logarithm b, the unchosen branch key w_{1-σ} = u - v has unknown discrete logarithm, and w₀ + w₁ = u.
  3. Round 3 (.message 0 1 ((G × G) × (G × G))): The sender checks w₀ + w₁ = u. If the check holds, it encrypts each branch i ∈ {0, 1} with fresh randomization coins (rᵢ, sᵢ) : ZMod q × ZMod q via ddhOTEncryptBranch g u wᵢ mᵢ rᵢ sᵢ a (since the sender holds a with u = a • g, this equals ElGamal encryption under wᵢ with exponent rᵢ + a * sᵢ; if the check fails, the sender sends zeros). The receiver decrypts its chosen ciphertext (e_σ, c_σ) as c_σ - b • e_σ.

Differences from Figure 23.17 #

Main definitions #

Main results #

References #

1-out-of-2 Oblivious Transfer functionality and protocol syntax #

@[reducible, inline]

Per-party input types for 1-out-of-2 Oblivious Transfer over message type M: party 0 (sender) holds (m₀, m₁) : M × M and party 1 (receiver) holds σ : Bool.

@[reducible, inline]

Per-party output types for 1-out-of-2 Oblivious Transfer over message type M: party 0 (sender) receives Unit and party 1 (receiver) receives m_σ : M.

def Cslib.Crypto.Protocols.MPC.otOutputs {M : Type} (x : (i : Fin 2) → OTIn M i) (i : Fin 2) :
OTOut M i

Deterministic output tuple of otFunctionality M: () for the sender and m_σ for the receiver.

Ideal functionality for 1-out-of-2 Oblivious Transfer over M.

def Cslib.Crypto.Protocols.MPC.otInputToBatchOTQuery {M : Type} (x : (i : Fin 2) → OTIn M i) (s : Fin 2) :

Convert a single-transfer input tuple x : (i : Fin 2) → OTIn M i into a query to batchOTSpec 1 M from CslibFrontier/Crypto/Protocols/MPC/BatchOT.lean.

otOutputs agrees with the single-transfer specialization k = 1 of batchOTAnswer.

The sender's random coins in the DDH OT protocol over ZMod q: the Round 1 exponent a and two encryption coins (rᵢ, sᵢ) for each branch i ∈ {0, 1}.

  • exponent : ZMod q

    Round 1 exponent a for the sender's first message u = a • g.

  • coinR₀ : ZMod q

    Randomizer r₀ for branch 0 encryption.

  • coinS₀ : ZMod q

    Randomizer s₀ for branch 0 encryption.

  • coinR₁ : ZMod q

    Randomizer r₁ for branch 1 encryption.

  • coinS₁ : ZMod q

    Randomizer s₁ for branch 1 encryption.

theorem Cslib.Crypto.Protocols.MPC.DDHOTSenderCoins.ext {q : ℕ} {x y : DDHOTSenderCoins q} (exponent : x.exponent = y.exponent) (coinR₀ : x.coinR₀ = y.coinR₀) (coinS₀ : x.coinS₀ = y.coinS₀) (coinR₁ : x.coinR₁ = y.coinR₁) (coinS₁ : x.coinS₁ = y.coinS₁) :
x = y
@[reducible, inline]

Per-party random coin types parameterized by sender coin type C₀ and receiver coin type C₁.

@[reducible, inline]

Per-party random coin types for ddhOTProtocol.

Sample the sender's five exponents uniformly from ZMod q.

@[reducible, inline]

Three-message point-to-point schedule for the DDH OT protocol: sender to receiver (G), receiver to sender (G × G), and sender to receiver ((G × G) × (G × G)).

def Cslib.Crypto.Protocols.MPC.ddhOTReceiverMsg {G : Type} [AddCommGroup G] {q : ℕ} [Module (ZMod q) G] (g : G) (σ : Bool) (b : ZMod q) (u : G) :
G × G

Round 2 receiver message: given u : G, choice bit σ : Bool, and coin b : ZMod q, outputs (w₀, w₁) with w_σ = b • g and w_{1-σ} = u - b • g.

theorem Cslib.Crypto.Protocols.MPC.ddhOTReceiverMsg_add {G : Type} [AddCommGroup G] {q : ℕ} [Module (ZMod q) G] (g : G) (σ : Bool) (b : ZMod q) (u : G) :
(ddhOTReceiverMsg g σ b u).1 + (ddhOTReceiverMsg g σ b u).2 = u

Honest Round 2 receiver messages always satisfy the sender's check w.1 + w.2 = u.

def Cslib.Crypto.Protocols.MPC.ddhOTEncryptBranch {G : Type} [AddCommGroup G] {q : ℕ} [Module (ZMod q) G] (g u w m : G) (r s a : ZMod q) :
G × G

Encrypt a single branch message m : G under (g, u, w) using coins (r, s) and sender exponent a. When u = a • g, this equals ElGamal encryption ((r + a * s) • g, (r + a * s) • w + m) under key w.

theorem Cslib.Crypto.Protocols.MPC.ddhOTReceiverOutput_encryptBranch {G : Type} [AddCommGroup G] {q : ℕ} [Module (ZMod q) G] (g m : G) (a b r s : ZMod q) :
have u := a • g; have w := b • g; have ct := ddhOTEncryptBranch g u w m r s a; ct.2 - b • ct.1 = m

Decrypting an honestly encrypted branch with w = b • g and u = a • g recovers m.

def Cslib.Crypto.Protocols.MPC.ddhOTSenderReplyUnchecked {G : Type} [AddCommGroup G] {q : ℕ} [Module (ZMod q) G] (g : G) (m : G × G) (c : DDHOTSenderCoins q) (w : G × G) :
(G × G) × G × G

Round 3 sender reply in the unchecked variant: omits the w.1 + w.2 = u verification.

def Cslib.Crypto.Protocols.MPC.ddhOTReceiverOutput {G : Type} [AddCommGroup G] {q : ℕ} [Module (ZMod q) G] (σ : Bool) (b : ZMod q) (reply : (G × G) × G × G) :
G

Receiver output decryption: selects ciphertext σ and unmasks by subtracting b • e_σ.

@[reducible, inline]
abbrev Cslib.Crypto.Protocols.MPC.DDHOTFinalWith (G C₀ C₁ : Type) (i : Fin 2) :

Final local state type at the end of ddhOTSchedule G, parameterized by coin types C₀, C₁.

def Cslib.Crypto.Protocols.MPC.ddhOTOutputWith {G : Type} [AddCommGroup G] {q : ℕ} [Module (ZMod q) G] {C₀ C₁ : Type} (proj₁ : C₁ → ZMod q) (i : Fin 2) (st : DDHOTFinalWith G C₀ C₁ i) :
OTOut G i

Output extraction at the end of ddhOTSchedule G under receiver coin projection proj₁.

Unchecked three-message DDH OT protocol: ddhOTProtocol without the sender's w₀ + w₁ = u check. [BS23], Section 23.5.7.3, Remark 23.6 describes the malicious-receiver attack that the check is meant to stop; ddhOTUncheckedRealGame runs that attack against this protocol.

def Cslib.Crypto.Protocols.MPC.ddhOTSenderReplyOf {G : Type} {q : ℕ} (proto : Protocol 2 noOracleSpec (ddhOTSchedule G) (OTIn G) (DDHOTCoins q) (OTOut G)) (m : G × G) (c : DDHOTSenderCoins q) (w : G × G) :
(G × G) × G × G

The honest sender's Round 3 reply in a protocol proto along ddhOTSchedule G, on input m and coins c, when the receiver's Round 2 message is w. The sender's local state is built as in Steps.run; a malicious receiver may choose w freely.

def Cslib.Crypto.Protocols.MPC.ddhOTAttackMsg {G : Type} [AddCommGroup G] {q : ℕ} [Module (ZMod q) G] (g : G) (b₀ b₁ : ZMod q) :
G × G

Malicious Round 2 message (b₀ • g, b₁ • g) with known discrete logs (b₀, b₁).

def Cslib.Crypto.Protocols.MPC.ddhOTAttackBothMessages {G : Type} [AddCommGroup G] {q : ℕ} [Module (ZMod q) G] (b₀ b₁ : ZMod q) (reply : (G × G) × G × G) :
G × G

Simultaneous decryption of both branches from the unchecked sender reply using (b₀, b₁).

theorem Cslib.Crypto.Protocols.MPC.ddhOTAttackBothMessages_eq {G : Type} [AddCommGroup G] {q : ℕ} [Module (ZMod q) G] (g : G) (m : G × G) (c₀ : DDHOTSenderCoins q) (b₀ b₁ : ZMod q) :

Simultaneous recovery on the unchecked variant: when the sender omits w₀ + w₁ = u, a malicious receiver sending ddhOTAttackMsg g b₀ b₁ recovers both (m.1, m.2) from ddhOTSenderReplyUnchecked.

def Cslib.Crypto.Protocols.MPC.ddhOTSenderReply {G : Type} [AddCommGroup G] [DecidableEq G] {q : ℕ} [Module (ZMod q) G] (g : G) (m : G × G) (c : DDHOTSenderCoins q) (w : G × G) :
(G × G) × G × G

Round 3 sender reply in the checked protocol: verifies w.1 + w.2 = c.exponent • g before encrypting (m.1, m.2).

theorem Cslib.Crypto.Protocols.MPC.ddhOTSenderReply_eq_unchecked_of_add {G : Type} [AddCommGroup G] [DecidableEq G] {q : ℕ} [Module (ZMod q) G] (g : G) (m : G × G) (c : DDHOTSenderCoins q) (w : G × G) (hw : w.1 + w.2 = c.exponent • g) :

When the receiver's Round 2 message satisfies w.1 + w.2 = c.exponent • g, the checked sender reply ddhOTSenderReply coincides with ddhOTSenderReplyUnchecked.

theorem Cslib.Crypto.Protocols.MPC.ddhOTSenderReply_eq_zero_of_add_ne {G : Type} [AddCommGroup G] [DecidableEq G] {q : ℕ} [Module (ZMod q) G] (g : G) (m : G × G) (c : DDHOTSenderCoins q) (w : G × G) (hw : w.1 + w.2 ≠ c.exponent • g) :
ddhOTSenderReply g m c w = ((0, 0), 0, 0)

When the receiver's Round 2 message violates w.1 + w.2 = c.exponent • g, the checked sender reply ddhOTSenderReply aborts to ((0, 0), (0, 0)).

noncomputable def Cslib.Crypto.Protocols.MPC.ddhOTProtocolWith {G : Type} [AddCommGroup G] [DecidableEq G] (g : G) (q : ℕ) [Module (ZMod q) G] {C₀ C₁ : Type} (sample₀ : ProbComp C₀) (sample₁ : ProbComp C₁) (proj₀ : C₀ → DDHOTSenderCoins q) (proj₁ : C₁ → ZMod q) :

Three-message DDH 1-out-of-2 Oblivious Transfer protocol with given coin samplers and projections: a variant of [BS23], Section 23.5.7, Figure 23.17, with the check w₀ + w₁ = u from Remark 23.6. Party 0 samples raw₀ ← sample₀ (retained unreduced in PartyView.coins) and derives proj₀ raw₀ : DDHOTSenderCoins q; party 1 samples raw₁ ← sample₁ (retained unreduced in PartyView.coins) and derives b := proj₁ raw₁. Unlike in Figure 23.17, the sender knows the discrete logarithm a of its first message u = a • g and encrypts each branch with its own coins (rᵢ, sᵢ); the module docstring lists the differences.

@[reducible, inline]
noncomputable abbrev Cslib.Crypto.Protocols.MPC.ddhOTProtocol {G : Type} [AddCommGroup G] [DecidableEq G] (g : G) (q : ℕ) [NeZero q] [Module (ZMod q) G] :

Three-message DDH 1-out-of-2 Oblivious Transfer protocol with exact uniform coins: ddhOTProtocolWith specialized to sampleDDHOTSenderCoins q, ProbComp.uniform (ZMod q), and identity projections.

Party views and execution characterization #

def Cslib.Crypto.Protocols.MPC.ddhOTSenderViewWith {G C₀ C₁ : Type} (x₀ : G × G) (raw₀ : C₀) (w : G × G) :

The sender's PartyView from its input x₀, coin object raw₀, and received Round 2 message w.

@[reducible, inline]
abbrev Cslib.Crypto.Protocols.MPC.ddhOTSenderView {G : Type} {q : ℕ} (x₀ : G × G) (c₀ : DDHOTSenderCoins q) (w : G × G) :

The sender's PartyView for ZMod q coins.

def Cslib.Crypto.Protocols.MPC.ddhOTReceiverViewWith {G C₀ C₁ : Type} (σ : Bool) (raw₁ : C₁) (u : G) (reply : (G × G) × G × G) :

The receiver's PartyView from its input σ, coin object raw₁, Round 1 message u, and Round 3 reply reply.

@[reducible, inline]
abbrev Cslib.Crypto.Protocols.MPC.ddhOTReceiverView {G : Type} {q : ℕ} (σ : Bool) (b : ZMod q) (u : G) (reply : (G × G) × G × G) :

The receiver's PartyView for ZMod q coins.

def Cslib.Crypto.Protocols.MPC.ddhOTViewsWith {G : Type} [AddCommGroup G] {q : ℕ} [Module (ZMod q) G] {C₀ C₁ : Type} (g : G) (proj₀ : C₀ → DDHOTSenderCoins q) (proj₁ : C₁ → ZMod q) (x : (i : Fin 2) → OTIn G i) (raw₀ : C₀) (raw₁ : C₁) (i : Fin 2) :

The pair of party views produced by ddhOTProtocolWith on inputs x, sender coins raw₀, and receiver coin raw₁. Because ddhOTReceiverMsg always satisfies the sender's check w₀ + w₁ = u, the sender's reply equals ddhOTSenderReplyUnchecked.

@[reducible, inline]
abbrev Cslib.Crypto.Protocols.MPC.ddhOTViews {G : Type} [AddCommGroup G] {q : ℕ} [Module (ZMod q) G] (g : G) (x : (i : Fin 2) → OTIn G i) (c₀ : DDHOTSenderCoins q) (b : ZMod q) (i : Fin 2) :

The pair of party views for ZMod q coins.

Execution law and correctness #

theorem Cslib.Crypto.Protocols.MPC.evalWith_ddhOTProtocolWith {G : Type} [AddCommGroup G] [DecidableEq G] (g : G) (q : ℕ) [Module (ZMod q) G] {C₀ C₁ : Type} (sample₀ : ProbComp C₀) (sample₁ : ProbComp C₁) (proj₀ : C₀ → DDHOTSenderCoins q) (proj₁ : C₁ → ZMod q) (x : (i : Fin 2) → OTIn G i) :
(ddhOTProtocolWith g q sample₀ sample₁ proj₀ proj₁).evalWith noOracleWorld x = do let raw₀ ← sample₀.eval let raw₁ ← sample₁.eval pure (ddhOTViewsWith g proj₀ proj₁ x raw₀ raw₁, otOutputs x)

Execution law of ddhOTProtocolWith: for any party coin samplers sample₀, sample₁ and projections proj₀, proj₁, evalWith draws raw₀ ← sample₀ and raw₁ ← sample₁ and returns (ddhOTViewsWith g proj₀ proj₁ x raw₀ raw₁, otOutputs x).

theorem Cslib.Crypto.Protocols.MPC.ddhOTProtocolWith_output_of_mem_support {G : Type} [AddCommGroup G] [DecidableEq G] (g : G) (q : ℕ) [Module (ZMod q) G] {C₀ C₁ : Type} {sample₀ : ProbComp C₀} {sample₁ : ProbComp C₁} {proj₀ : C₀ → DDHOTSenderCoins q} {proj₁ : C₁ → ZMod q} (x : (i : Fin 2) → OTIn G i) {r : ((i : Fin 2) → PartyView (OTIn G) (DDHOTCoinsWith C₀ C₁) (ddhOTSchedule G) i) × ((i : Fin 2) → OTOut G i)} (hr : r ∈ ((ddhOTProtocolWith g q sample₀ sample₁ proj₀ proj₁).evalWith noOracleWorld x).support) :
r.2 = otOutputs x

Correctness: for any party coin samplers and exponent projections, in every execution of ddhOTProtocolWith, the sender outputs () and the receiver outputs if x 1 then (x 0).2 else (x 0).1.

Perfect privacy against a corrupted sender #

def Cslib.Crypto.Protocols.MPC.ddhOTSenderSimWithCoinsOf {G : Type} [AddCommGroup G] {q : ℕ} [Module (ZMod q) G] {C₀ C₁ : Type} (g : G) (proj₀ : C₀ → DDHOTSenderCoins q) (raw₀ : C₀) (b : ZMod q) (xI : (i : ↥{0}) → OTIn G ↑i) (i : ↥{0}) :
PartyView (OTIn G) (DDHOTCoinsWith C₀ C₁) (ddhOTSchedule G) ↑i

The simulated view of a corrupted sender ({0}) on sender coin object raw₀ (projected via proj₀) and receiver exponent b : ZMod q: the sender's input and unreduced coin raw₀, and the Round 2 message (b • g, (proj₀ raw₀).exponent • g - b • g).

@[reducible, inline]
abbrev Cslib.Crypto.Protocols.MPC.ddhOTSenderSimWithCoins {G : Type} [AddCommGroup G] {q : ℕ} [Module (ZMod q) G] (g : G) (c₀ : DDHOTSenderCoins q) (b : ZMod q) (xI : (i : ↥{0}) → OTIn G ↑i) (i : ↥{0}) :

The simulated view of a corrupted sender ({0}) for ZMod q coins.

Simulator for a corrupted sender ({0}): samples fresh sender coins c₀ and a uniform b : ZMod q, and returns ddhOTSenderSimWithCoins, whose Round 2 message is (b • g, c₀.exponent • g - b • g).

theorem Cslib.Crypto.Protocols.MPC.idealJoint_ddhOT_sender_with {G : Type} [AddCommGroup G] (g : G) (q : ℕ) [NeZero q] [Module (ZMod q) G] {C₀ C₁ : Type} (sample₀ : ProbComp C₀) (proj₀ : C₀ → DDHOTSenderCoins q) (x : (i : Fin 2) → OTIn G i) :
(do let raw₀ ← sample₀.eval let b ← Probability.PMF.uniformOfFintype (ZMod q) pure (ddhOTSenderSimWithCoinsOf g proj₀ raw₀ b ({0}.restrict x), otOutputs x)) = do let raw₀ ← sample₀.eval let b ← Probability.PMF.uniformOfFintype (ZMod q) pure (singletonView (ddhOTSenderViewWith (x 0) raw₀ (ddhOTReceiverMsg g (x 1) b ((proj₀ raw₀).exponent • g))), otOutputs x)

Perfect sender simulation under any sender coin sampler when the honest receiver's exponent is uniform on ZMod q: for every sample₀ and proj₀, drawing raw₀ ← sample₀ and b ← uniform (ZMod q) gives ddhOTSenderSimWithCoinsOf the exact same distribution as the corrupted sender's real view paired with otOutputs x.

Real joint distribution for a corrupted sender ({0}).

Perfect privacy against a corrupted sender: the ideal joint distribution with ddhOTSenderSim equals the real joint distribution.

theorem Cslib.Crypto.Protocols.MPC.semiHonestAdvantage_ddhOT_sender {G : Type} [AddCommGroup G] [DecidableEq G] (g : G) (q : ℕ) [NeZero q] [Module (ZMod q) G] (x : (i : Fin 2) → OTIn G i) (D : ((i : ↥{0}) → PartyView (OTIn G) (DDHOTCoins q) (ddhOTSchedule G) ↑i) × ((i : Fin 2) → OTOut G i) → ProbComp Bool) :

A corrupted sender has advantage zero against every distinguisher.

Computational privacy against a corrupted receiver under DDH #

def Cslib.Crypto.Protocols.MPC.ddhOTReductionWithCoinsOf {G : Type} [AddCommGroup G] {q : ℕ} [Module (ZMod q) G] {C₀ C₁ : Type} (g : G) (proj₁ : C₁ → ZMod q) (x : (i : Fin 2) → OTIn G i) (D : ((i : ↥{1}) → PartyView (OTIn G) (DDHOTCoinsWith C₀ C₁) (ddhOTSchedule G) ↑i) × ((i : Fin 2) → OTOut G i) → ProbComp Bool) (raw₁ : C₁) (r s : ZMod q) (u u' w_ddh : G) :

The DDH reduction for receiver privacy on a fixed receiver coin object raw₁ (projected via proj₁) and chosen-branch coins (r, s): embeds (u, u', w_ddh) into the unchosen branch, encrypts the chosen branch with b := proj₁ raw₁, records raw₁ unreduced in the receiver's PartyView.coins, and runs D.

@[reducible, inline]
abbrev Cslib.Crypto.Protocols.MPC.ddhOTReductionWithCoins {G : Type} [AddCommGroup G] {q : ℕ} [Module (ZMod q) G] (g : G) (x : (i : Fin 2) → OTIn G i) (D : ((i : ↥{1}) → PartyView (OTIn G) (DDHOTCoins q) (ddhOTSchedule G) ↑i) × ((i : Fin 2) → OTOut G i) → ProbComp Bool) (b r s : ZMod q) (u u' w_ddh : G) :

The DDH reduction for receiver privacy on fixed ZMod q coins.

noncomputable def Cslib.Crypto.Protocols.MPC.ddhOTReductionOf {G : Type} [AddCommGroup G] (g : G) (q : ℕ) [NeZero q] [Module (ZMod q) G] {C₀ C₁ : Type} (sample₁ : ProbComp C₁) (proj₁ : C₁ → ZMod q) (x : (i : Fin 2) → OTIn G i) (D : ((i : ↥{1}) → PartyView (OTIn G) (DDHOTCoinsWith C₀ C₁) (ddhOTSchedule G) ↑i) × ((i : Fin 2) → OTOut G i) → ProbComp Bool) (u u' w_ddh : G) :

DDH reduction for receiver privacy under receiver coin sampler sample₁ and projection proj₁: draws raw₁ ← sample₁ and uniform r, s : ZMod q, then runs ddhOTReductionWithCoinsOf.

@[reducible, inline]
noncomputable abbrev Cslib.Crypto.Protocols.MPC.ddhOTReduction {G : Type} [AddCommGroup G] (g : G) (q : ℕ) [NeZero q] [Module (ZMod q) G] (x : (i : Fin 2) → OTIn G i) (D : ((i : ↥{1}) → PartyView (OTIn G) (DDHOTCoins q) (ddhOTSchedule G) ↑i) × ((i : Fin 2) → OTOut G i) → ProbComp Bool) (u u' w_ddh : G) :

DDH reduction for receiver privacy with uniform ZMod q coins.

theorem Cslib.Crypto.Protocols.MPC.real_receiver_eq_ddhRealExperiment_of {G : Type} [AddCommGroup G] (g : G) (q : ℕ) [NeZero q] [Module (ZMod q) G] {C₀ C₁ : Type} (sample₁ : ProbComp C₁) (proj₁ : C₁ → ZMod q) (x : (i : Fin 2) → OTIn G i) (D : ((i : ↥{1}) → PartyView (OTIn G) (DDHOTCoinsWith C₀ C₁) (ddhOTSchedule G) ↑i) × ((i : Fin 2) → OTOut G i) → ProbComp Bool) :
(do let c₀ ← (sampleDDHOTSenderCoins q).eval let raw₁ ← sample₁.eval (D (singletonView (ddhOTReceiverViewWith (x 1) raw₁ (c₀.exponent • g) (ddhOTSenderReplyUnchecked g (x 0) c₀ (ddhOTReceiverMsg g (x 1) (proj₁ raw₁) (c₀.exponent • g)))), otOutputs x)).eval) = ProbComp.eval (ddhRealExperiment q g (ddhOTReductionOf g q sample₁ proj₁ x D))

For any receiver coin sampler sample₁ and projection proj₁, when the honest sender's five exponents are drawn uniformly via sampleDDHOTSenderCoins q, the corrupted receiver's real view distribution equals ddhRealExperiment q g run on ddhOTReductionOf.

theorem Cslib.Crypto.Protocols.MPC.real_receiver_eq_ddhRealExperiment {G : Type} [AddCommGroup G] [DecidableEq G] (g : G) (q : ℕ) [NeZero q] [Module (ZMod q) G] (x : (i : Fin 2) → OTIn G i) (D : ((i : ↥{1}) → PartyView (OTIn G) (DDHOTCoins q) (ddhOTSchedule G) ↑i) × ((i : Fin 2) → OTOut G i) → ProbComp Bool) :
(((ddhOTProtocol g q).realJoint noOracleWorld {1} x).bind fun (r : ((i : ↥{1}) → PartyView (OTIn G) (DDHOTCoins q) (ddhOTSchedule G) ↑i) × ((i : Fin 2) → OTOut G i)) => (D r).eval) = ProbComp.eval (ddhRealExperiment q g (ddhOTReduction g q x D))

The real execution for a corrupted receiver is the real DDH world Cslib.Crypto.ddhRealExperiment q g run on ddhOTReduction.

def Cslib.Crypto.Protocols.MPC.ddhOTReceiverSimWithCoinsOf {G : Type} [AddCommGroup G] {q : ℕ} [Module (ZMod q) G] {C₀ C₁ : Type} (g : G) (proj₁ : C₁ → ZMod q) (a : ZMod q) (raw₁ : C₁) (r s k c : ZMod q) (xI : (i : ↥{1}) → OTIn G ↑i) (yI : (i : ↥{1}) → OTOut G ↑i) (i : ↥{1}) :
PartyView (OTIn G) (DDHOTCoinsWith C₀ C₁) (ddhOTSchedule G) ↑i

The simulated view of a corrupted receiver ({1}) on receiver coin object raw₁ (projected via proj₁) and exponents a, r, s, k, c: given choice bit σ and ideal output m_σ, records raw₁ unreduced in PartyView.coins, sets u = a • g, encrypts the chosen branch as (e_σ, (proj₁ raw₁) • e_σ + m_σ) with e_σ = r • g + s • u, and sets the unchosen branch to (k • g, c • g).

@[reducible, inline]
abbrev Cslib.Crypto.Protocols.MPC.ddhOTReceiverSimWithCoins {G : Type} [AddCommGroup G] {q : ℕ} [Module (ZMod q) G] (g : G) (a b r s k c : ZMod q) (xI : (i : ↥{1}) → OTIn G ↑i) (yI : (i : ↥{1}) → OTOut G ↑i) (i : ↥{1}) :

The simulated view of a corrupted receiver ({1}) for ZMod q coins.

noncomputable def Cslib.Crypto.Protocols.MPC.ddhOTReceiverSimOf {G : Type} [AddCommGroup G] (g : G) (q : ℕ) [NeZero q] [Module (ZMod q) G] {C₀ C₁ : Type} (sample₁ : ProbComp C₁) (proj₁ : C₁ → ZMod q) :

Simulator for a corrupted receiver ({1}) under receiver coin sampler sample₁ and projection proj₁: draws raw₁ ← sample₁ and uniform a, r, s, k, c : ZMod q, and returns ddhOTReceiverSimWithCoinsOf.

@[reducible, inline]
noncomputable abbrev Cslib.Crypto.Protocols.MPC.ddhOTReceiverSim {G : Type} [AddCommGroup G] (g : G) (q : ℕ) [NeZero q] [Module (ZMod q) G] :

Simulator for a corrupted receiver ({1}) with uniform ZMod q coins.

theorem Cslib.Crypto.Protocols.MPC.ideal_receiver_eq_ddhRandomExperiment_of {G : Type} [AddCommGroup G] (g : G) (q : ℕ) [NeZero q] [Module (ZMod q) G] (hgen : ∀ (y : G), ∃ (k : ZMod q), k • g = y) {C₀ C₁ : Type} (sample₁ : ProbComp C₁) (proj₁ : C₁ → ZMod q) (x : (i : Fin 2) → OTIn G i) (D : ((i : ↥{1}) → PartyView (OTIn G) (DDHOTCoinsWith C₀ C₁) (ddhOTSchedule G) ↑i) × ((i : Fin 2) → OTOut G i) → ProbComp Bool) :
(idealJoint (otFunctionality G) {1} (ddhOTReceiverSimOf g q sample₁ proj₁) x >>= D).eval = ProbComp.eval (ddhRandomExperiment q g (ddhOTReductionOf g q sample₁ proj₁ x D))

For any receiver coin sampler sample₁ and projection proj₁, when g generates G, the ideal execution for a corrupted receiver with ddhOTReceiverSimOf equals ddhRandomExperiment q g run on ddhOTReductionOf.

theorem Cslib.Crypto.Protocols.MPC.ideal_receiver_eq_ddhRandomExperiment {G : Type} [AddCommGroup G] (g : G) (q : ℕ) [NeZero q] [Module (ZMod q) G] (hgen : ∀ (y : G), ∃ (k : ZMod q), k • g = y) (x : (i : Fin 2) → OTIn G i) (D : ((i : ↥{1}) → PartyView (OTIn G) (DDHOTCoins q) (ddhOTSchedule G) ↑i) × ((i : Fin 2) → OTOut G i) → ProbComp Bool) :

When g generates G, the ideal execution for a corrupted receiver is the random DDH world Cslib.Crypto.ddhRandomExperiment q g run on ddhOTReduction.

theorem Cslib.Crypto.Protocols.MPC.semiHonestAdvantage_ddhOT_receiver_eq {G : Type} [AddCommGroup G] [DecidableEq G] (g : G) (q : ℕ) [NeZero q] [Module (ZMod q) G] (hgen : ∀ (y : G), ∃ (k : ZMod q), k • g = y) (x : (i : Fin 2) → OTIn G i) (D : ((i : ↥{1}) → PartyView (OTIn G) (DDHOTCoins q) (ddhOTSchedule G) ↑i) × ((i : Fin 2) → OTOut G i) → ProbComp Bool) :

Privacy against a corrupted receiver, as a per-instance equality: for a fixed group, input and distinguisher, the distinguisher's advantage between the ideal joint distribution with ddhOTReceiverSim and the real one equals the fixed-group DDH advantage of ddhOTReduction, when g generates G. This is not a computational privacy theorem: there is no security parameter, and ddhOTReduction has no efficiency certificate. Cslib.Crypto.PrimeOrderGroupFamily.advantage_ddhOTReceiverGame_le in CslibFrontier/Crypto/Protocols/MPC/DDHOT/Family.lean is the family form, with a certified reduction.

Malicious-receiver attack on the unchecked variant #

noncomputable def Cslib.Crypto.Protocols.MPC.ddhOTUncheckedRealGame {G : Type} [AddCommGroup G] [DecidableEq G] [Fintype G] (g : G) (q : ℕ) [NeZero q] [Module (ZMod q) G] (b₀ b₁ : ZMod q) :

Real game for a malicious receiver against ddhOTUncheckedProtocol. The sender holds uniform messages (m₀, m₁) ← G × G and coins drawn by the protocol's own sampler. The receiver sends ddhOTAttackMsg g b₀ b₁ in Round 2, gets the sender's Round 3 reply ddhOTSenderReplyOf (ddhOTUncheckedProtocol g q), and wins if it recovers both messages.

Ideal game for a malicious receiver against oblivious transfer. The simulator S first outputs a query bit τ together with a guessing function, which may share the simulator's randomness. For uniform messages (m₀, m₁) ← G × G the ideal functionality gives it if τ then m₁ else m₀, and the simulator wins if its guess equals (m₀, m₁).

In ddhOTUncheckedRealGame, the malicious receiver recovers both messages with probability 1.

In ddhOTUncheckedIdealGame, every simulator S outputs both messages with probability at most (Fintype.card G : ℝ)⁻¹: the message it does not query is uniform and independent of its view.

Malicious-receiver separation for ddhOTUncheckedProtocol: for every simulator S, the distinguishing advantage between ddhOTUncheckedRealGame and ddhOTUncheckedIdealGame S is at least 1 - (Fintype.card G : ℝ)⁻¹.