Documentation

CslibFrontier.Crypto.Protocols.MPC.BatchOT.Sequential

Batched oblivious transfer from sequential single transfers #

batchOTFunctionality k M transfers k values of a type M in one invocation. This module realizes it from k sequential invocations of the single 1-out-of-2 transfer otFunctionality M, and bounds the semi-honest advantage against the protocol obtained by substituting a protocol for the single transfer.

seqBatchOT k M runs in the hybrid model whose oracle is the single transfer (otSpec M, with the ideal world otWorld M). It has k oracle rounds and no messages: in round j the sender submits the pair (x j false, x j true) of its two values for transfer j and the receiver submits its j-th choice bit; the receiver outputs the k answers and the sender outputs (). In the hybrid model every party's view is determined by its input and output, so seqBatchOT k M is perfectly private for every coalition, with the simulator seqBatchOTSim that replays the outputs as the oracle answers (perfectSemiHonestPrivate_seqBatchOT).

Substituting a protocol Sub for the single transfer (Protocol.compose) gives a protocol for batchOTFunctionality k M in the model of Sub. semiHonestAdvantage_seqBatchOT_compose_le bounds its semi-honest advantage, for the composed simulator composeSim, by Composition.replacementBound: the sum over the k transfers of the expected semi-honest advantage of that transfer's distinguisher Composition.roundDistinguisher against Sub, where the expectation is over the real executions of the earlier transfers. When every test has advantage at most ε against Sub, the bound is k * ε (semiHonestAdvantage_seqBatchOT_compose_le_mul).

Scope #

These are concrete, per-instance statements in the style of CslibFrontier/Crypto/Protocols/MPC/Composition/Hybrid.lean, and original library infrastructure; no cited theorem is claimed. In particular:

Main definitions #

Main results #

The single transfer as an oracle #

@[reducible]

One 1-out-of-2 oblivious transfer of a value in M as a two-party oracle: slot 0 (sender) submits a pair of values and receives Unit; slot 1 (receiver) submits a choice bit and receives the chosen value. Its query and answer parts are the input and output types OTIn M and OTOut M of otFunctionality M, so that a protocol for otFunctionality M can be substituted for this oracle by Protocol.compose as it stands; batchOTSpec 1 M is the same transfer with the values and the bit indexed by Fin 1.

The ideal memoryless world of otSpec M: the functionality otFunctionality M.

Sequential transfer rounds #

@[reducible]

The schedule of k sequential single transfers between the two parties, the sender in slot 0 and the receiver in slot 1 of every transfer.

def Cslib.Crypto.Protocols.MPC.seqOTSteps {M : Type} {Out : Fin 2 → Type} (k : ℕ) {State : Fin 2 → Type} :
(Fin k → (s : Fin 2) → State s → OTIn M s) → ((s : Fin 2) → State s → (Fin k → OTOut M s) → Out s) → Steps State Out (seqBatchOTSchedule k M)

k sequential single transfers from the states State: in round j party s submits query j s of its initial state, and at the end party s outputs output s of its initial state and of its k answers, in the order of the rounds.

def Cslib.Crypto.Protocols.MPC.seqOTReceived {M : Type} (k : ℕ) (i : Fin 2) :
(Fin k → OTOut M i) → (seqBatchOTSchedule k M).Received i

The transcript that party i receives along seqBatchOTSchedule k M when its answer in round j is ans j.

theorem Cslib.Crypto.Protocols.MPC.evalWith_seqOTSteps {M : Type} {Out : Fin 2 → Type} (k : ℕ) {State : Fin 2 → Type} (query : Fin k → (s : Fin 2) → State s → OTIn M s) (output : (s : Fin 2) → State s → (Fin k → OTOut M s) → Out s) (st : (i : Fin 2) → State i) :
(seqOTSteps k query output).evalWith (otWorld M) st = PMF.pure fun (i : Fin 2) => seqOTReceived k i fun (j : Fin k) => otOutputs (fun (s : Fin 2) => query j s (st s)) i

In the ideal world otWorld M the rounds of seqOTSteps are deterministic: party i receives in round j its part of otOutputs on the queries of round j.

theorem Cslib.Crypto.Protocols.MPC.outputAt_seqOTSteps {M : Type} {Out : Fin 2 → Type} (k : ℕ) {State : Fin 2 → Type} (query : Fin k → (s : Fin 2) → State s → OTIn M s) (output : (s : Fin 2) → State s → (Fin k → OTOut M s) → Out s) (i : Fin 2) (st : State i) (ans : Fin k → OTOut M i) :
(seqOTSteps k query output).outputAt i st (seqOTReceived k i ans) = output i st ans

The output of party i after seqOTSteps, on the transcript in which its answers are ans, is output i of its state and ans.

The batched transfer protocol #

def Cslib.Crypto.Protocols.MPC.batchOTQueryAt {k : ℕ} {M : Type} (j : Fin k) (s : Fin 2) :
(batchOTSpec k M).Query () s → OTIn M s

The query of party s in transfer j of the batched transfer: the sender submits the pair (x j false, x j true) of its two values for transfer j, and the receiver its j-th choice bit. As in otOutputs, the choice bit true selects the second value of the pair.

def Cslib.Crypto.Protocols.MPC.batchOTAnswerOfRounds {k : ℕ} {M : Type} (s : Fin 2) :
(Fin k → OTOut M s) → (batchOTSpec k M).Answer () s

The answer of batchOTSpec k M to party s assembled from its answers in the k single transfers.

The answers to party s in the k single transfers, read off its answer from batchOTSpec k M; the inverse of batchOTAnswerOfRounds.

theorem Cslib.Crypto.Protocols.MPC.otOutputs_batchOTQueryAt {k : ℕ} {M : Type} (x : (s : Fin 2) → (batchOTSpec k M).Query () s) (i : Fin 2) :
(fun (j : Fin k) => otOutputs (fun (s : Fin 2) => batchOTQueryAt j s (x s)) i) = batchOTRoundAnswers i (batchOTAnswer x i)

The answers of the k single transfers on the queries batchOTQueryAt are the parts of the batched answer batchOTAnswer.

Batched oblivious transfer from k sequential single transfers, in the hybrid model whose oracle is the single transfer otSpec M. In round j the sender submits its two values for transfer j and the receiver its j-th choice bit (batchOTQueryAt); the receiver outputs its k answers and the sender outputs (). The protocol uses no coins and sends no messages.

The simulators of seqBatchOT k M: each corrupted party's view consists of its input, the empty coins and, as its answer in transfer j, the j-th part of its output.

theorem Cslib.Crypto.Protocols.MPC.evalWith_seqBatchOT (k : ℕ) (M : Type) (x : (i : Fin 2) → (batchOTSpec k M).Query () i) :
(seqBatchOT k M).evalWith (otWorld M) x = PMF.pure (fun (i : Fin 2) => { input := x i, coins := (), received := seqOTReceived k i (batchOTRoundAnswers i (batchOTAnswer x i)) }, batchOTAnswer x)

The execution of seqBatchOT k M is deterministic and correct. In the ideal world of the single transfer, on the inputs x every party outputs its part of batchOTAnswer x, and its view consists of its input and, as its answer in transfer j, the j-th part of its output.

seqBatchOT k M is perfectly semi-honest private in the single-transfer hybrid model: for every coalition, the simulator seqBatchOTSim k M on the coalition's inputs and outputs of batchOTFunctionality k M has the joint distribution of the coalition's views and all outputs in the execution with the ideal single transfer otWorld M.

Substituting a protocol for the single transfer #

theorem Cslib.Crypto.Protocols.MPC.semiHonestAdvantage_seqBatchOT_compose_le {spec₂ : MultiOracleSpec} {sc₂ : Schedule 2 spec₂} {Coins₂ : Fin 2 → Type} (k : ℕ) (M : Type) (W₂ : MultiOracleWorld spec₂) (Sub : Protocol 2 spec₂ sc₂ (OTIn M) Coins₂ (OTOut M)) (S₂ : (J : Finset (Fin 2)) → CoalitionSimulator sc₂ (OTIn M) Coins₂ (OTOut M) J) (I : Finset (Fin 2)) (x : (i : Fin 2) → (batchOTSpec k M).Query () i) (D : ((i : ↥I) → PartyView ((batchOTSpec k M).Query ()) (Schedule.ComposedCoins (fun (x : (otSpec M).Op) => Coins₂) (fun (x : Fin ((batchOTSpec k M).arity ())) => Unit) (seqBatchOTSchedule k M)) (Schedule.compose (fun (x : (otSpec M).Op) => sc₂) (seqBatchOTSchedule k M)) ↑i) × ((i : Fin 2) → (batchOTSpec k M).Answer () i) → ProbComp Bool) :
↑(semiHonestAdvantage ((seqBatchOT k M).compose fun (x : (otSpec M).Op) => Sub) W₂ (batchOTFunctionality k M) I (composeSim (seqBatchOT k M) (seqBatchOTSim k M I) fun (x : (otSpec M).Op) => S₂) x D) ≤ Composition.replacementBound (otWorld M) W₂ (fun (x : (otSpec M).Op) => Sub) (fun (x : (otSpec M).Op) => S₂) I (seqBatchOT k M).steps (fun (i : Fin 2) => (x i, ())) fun (res : ((i : ↥I) → Schedule.SubCoins (fun (x : (otSpec M).Op) => Coins₂) (seqBatchOTSchedule k M) ↑i × (Schedule.compose (fun (x : (otSpec M).Op) => sc₂) (seqBatchOTSchedule k M)).Received ↑i) × ((i : Fin 2) → (batchOTSpec k M).Answer () i)) => D (fun (i : ↥I) => { input := x ↑i, coins := ((), (res.1 i).1), received := (res.1 i).2 }, res.2)

The batched transfer over a substituted single transfer. For every protocol Sub for the single transfer in a world W₂ and simulators S₂ of Sub, the semi-honest advantage of D against (seqBatchOT k M).compose fun _ => Sub, for batchOTFunctionality k M with the composed simulator, is at most Composition.replacementBound: the sum over the k transfers of the expected semi-honest advantage of that transfer's distinguisher Composition.roundDistinguisher against Sub, for otFunctionality M with the simulator S₂, on that transfer's queries. The expectation is over the real executions of Sub in the earlier transfers.

Nothing is assumed about Sub, S₂ or D, and no efficiency of the round distinguishers is claimed.

@[simp]

k sequential transfers have k oracle rounds.

theorem Cslib.Crypto.Protocols.MPC.semiHonestAdvantage_seqBatchOT_compose_le_sum_roundGame {spec₂ : MultiOracleSpec} {sc₂ : Schedule 2 spec₂} {Coins₂ : Fin 2 → Type} (k : ℕ) (M : Type) (W₂ : MultiOracleWorld spec₂) (Sub : Protocol 2 spec₂ sc₂ (OTIn M) Coins₂ (OTOut M)) (S₂ : (J : Finset (Fin 2)) → CoalitionSimulator sc₂ (OTIn M) Coins₂ (OTOut M) J) (I : Finset (Fin 2)) (x : (i : Fin 2) → (batchOTSpec k M).Query () i) (D : ((i : ↥I) → PartyView ((batchOTSpec k M).Query ()) (Schedule.ComposedCoins (fun (x : (otSpec M).Op) => Coins₂) (fun (x : Fin ((batchOTSpec k M).arity ())) => Unit) (seqBatchOTSchedule k M)) (Schedule.compose (fun (x : (otSpec M).Op) => sc₂) (seqBatchOTSchedule k M)) ↑i) × ((i : Fin 2) → (batchOTSpec k M).Answer () i) → ProbComp Bool) :
semiHonestAdvantage ((seqBatchOT k M).compose fun (x : (otSpec M).Op) => Sub) W₂ (batchOTFunctionality k M) I (composeSim (seqBatchOT k M) (seqBatchOTSim k M I) fun (x : (otSpec M).Op) => S₂) x D ≤ ∑ j ∈ Finset.range k, Game.advantage ((composeRoundEnv (seqBatchOT k M) (otWorld M) W₂ (fun (x : (otSpec M).Op) => Sub) (fun (x : (otSpec M).Op) => S₂) I x D j).bind (Composition.roundGame fun (op : (otSpec M).Op) (J : Finset (Fin ((otSpec M).arity op))) (q : (s : Fin ((otSpec M).arity op)) → (otSpec M).Query op s) => (idealJoint (otWorld M op) J (S₂ J) q).eval)) ((composeRoundEnv (seqBatchOT k M) (otWorld M) W₂ (fun (x : (otSpec M).Op) => Sub) (fun (x : (otSpec M).Op) => S₂) I x D j).bind (Composition.roundGame fun (x : (otSpec M).Op) (J : Finset (Fin ((otSpec M).arity x))) (q : (s : Fin ((otSpec M).arity x)) → (otSpec M).Query x s) => Sub.realJoint W₂ J q))

The batched transfer over a substituted single transfer, with one environment per transfer. For every protocol Sub for the single transfer in a world W₂ and simulators S₂ of Sub, the semi-honest advantage of D against (seqBatchOT k M).compose fun _ => Sub, for batchOTFunctionality k M with the composed simulator, is at most the sum over the transfers j < k of the advantage of the environment composeRoundEnv of hop j between the ideal game of transfer j, for otFunctionality M with the simulator S₂, and its real game with Sub. The environment runs the transfers before j with Sub itself and its guessing stage simulates the transfers after j with S₂, so each summand is the absolute difference of two acceptance probabilities of one environment; in semiHonestAdvantage_seqBatchOT_compose_le the absolute value is inside the expectation over the earlier transfers.

Nothing is assumed about Sub, S₂ or D, and no efficiency of the environments is claimed.

noncomputable def Cslib.Crypto.Protocols.MPC.composeSeqBatchOTRoundEnv {spec₂ : MultiOracleSpec} {sc₂ : Schedule 2 spec₂} {Coins₂ : Fin 2 → Type} {m : ℕ} (k : ℕ) (M : Type) {sc₁ : Schedule m (batchOTSpec k M)} {In Coins₁ Out : Fin m → Type} (P : Protocol m (batchOTSpec k M) sc₁ In Coins₁ Out) (W₂ : MultiOracleWorld spec₂) (Sub : Protocol 2 spec₂ sc₂ (OTIn M) Coins₂ (OTOut M)) (S₂ : (J : Finset (Fin 2)) → CoalitionSimulator sc₂ (OTIn M) Coins₂ (OTOut M) J) (I : Finset (Fin m)) (x : (i : Fin m) → In i) (D : ((i : ↥I) → PartyView In (Schedule.ComposedCoins (fun (x : (batchOTSpec k M).Op) => Schedule.ComposedCoins (fun (x : (otSpec M).Op) => Coins₂) (fun (x : Fin ((batchOTSpec k M).arity x)) => Unit) (seqBatchOTSchedule k M)) Coins₁ sc₁) (Schedule.compose (fun (x : (batchOTSpec k M).Op) => Schedule.compose (fun (x : (otSpec M).Op) => sc₂) (seqBatchOTSchedule k M)) sc₁) ↑i) × ((i : Fin m) → Out i) → ProbComp Bool) (i j : ℕ) :
PMF (Bool ⊕ Composition.RoundChallenge (fun (x : (otSpec M).Op) => sc₂) fun (x : (otSpec M).Op) => Coins₂)

The environment of transfer j of call i, for an outer protocol P that calls the batched transfer batchOTSpec k M, with every call run by seqBatchOT k M over a protocol Sub for the single transfer. It samples the coins of P, runs P up to its call i with the earlier calls run by seqBatchOT k M over Sub (composeRoundEnv of P), then runs the transfers before j of call i with Sub and stops at transfer j (composeRoundEnv of seqBatchOT k M on the challenged call). The guessing stage simulates the later transfers with S₂ and the later calls with seqBatchOTSim k M and S₂, and runs D.

theorem Cslib.Crypto.Protocols.MPC.semiHonestAdvantage_compose_seqBatchOT_compose_le_sum_roundGame {spec₂ : MultiOracleSpec} {sc₂ : Schedule 2 spec₂} {Coins₂ : Fin 2 → Type} {m : ℕ} (k : ℕ) (M : Type) {sc₁ : Schedule m (batchOTSpec k M)} {In Coins₁ Out : Fin m → Type} (P : Protocol m (batchOTSpec k M) sc₁ In Coins₁ Out) (W₂ : MultiOracleWorld spec₂) (Sub : Protocol 2 spec₂ sc₂ (OTIn M) Coins₂ (OTOut M)) (S₂ : (J : Finset (Fin 2)) → CoalitionSimulator sc₂ (OTIn M) Coins₂ (OTOut M) J) (f : Functionality m In Out) (S₁ : (I : Finset (Fin m)) → CoalitionSimulator sc₁ In Coins₁ Out I) (I : Finset (Fin m)) (x : (i : Fin m) → In i) (D : ((i : ↥I) → PartyView In (Schedule.ComposedCoins (fun (x : (batchOTSpec k M).Op) => Schedule.ComposedCoins (fun (x : (otSpec M).Op) => Coins₂) (fun (x : Fin ((batchOTSpec k M).arity x)) => Unit) (seqBatchOTSchedule k M)) Coins₁ sc₁) (Schedule.compose (fun (x : (batchOTSpec k M).Op) => Schedule.compose (fun (x : (otSpec M).Op) => sc₂) (seqBatchOTSchedule k M)) sc₁) ↑i) × ((i : Fin m) → Out i) → ProbComp Bool) :
semiHonestAdvantage (P.compose fun (x : (batchOTSpec k M).Op) => (seqBatchOT k M).compose fun (x : (otSpec M).Op) => Sub) W₂ f I (composeSim P (S₁ I) fun (x : (batchOTSpec k M).Op) (J : Finset (Fin ((batchOTSpec k M).arity x))) => composeSim (seqBatchOT k M) (seqBatchOTSim k M J) fun (x : (otSpec M).Op) => S₂) x D ≤ semiHonestAdvantage P (batchOTWorld k M) f I (S₁ I) x (composeDistinguisher P (fun (x : (batchOTSpec k M).Op) (J : Finset (Fin ((batchOTSpec k M).arity x))) => composeSim (seqBatchOT k M) (seqBatchOTSim k M J) fun (x : (otSpec M).Op) => S₂) I x D) + ∑ i ∈ Finset.range sc₁.oracleRounds, ∑ j ∈ Finset.range k, Game.advantage ((composeSeqBatchOTRoundEnv k M P W₂ Sub S₂ I x D i j).bind (Composition.roundGame fun (op : (otSpec M).Op) (J : Finset (Fin ((otSpec M).arity op))) (q : (s : Fin ((otSpec M).arity op)) → (otSpec M).Query op s) => (idealJoint (otWorld M op) J (S₂ J) q).eval)) ((composeSeqBatchOTRoundEnv k M P W₂ Sub S₂ I x D i j).bind (Composition.roundGame fun (x : (otSpec M).Op) (J : Finset (Fin ((otSpec M).arity x))) (q : (s : Fin ((otSpec M).arity x)) → (otSpec M).Query x s) => Sub.realJoint W₂ J q))

An outer protocol over the batched transfer run by sequential single transfers, with one environment per transfer. Let P be any protocol that calls the batched transfer batchOTSpec k M, such as Yao's protocol, with every call run by seqBatchOT k M over a protocol Sub for the single transfer in a world W₂. The semi-honest advantage of D against the composed protocol, with the simulator composed from S₁, seqBatchOTSim k M and simulators S₂ of Sub, is at most the advantage of composeDistinguisher against P with the ideal batched transfer, plus the sum over the calls i of P and the transfers j < k of the advantage of the environment composeSeqBatchOTRoundEnv of transfer j of call i between the ideal game of that transfer, for otFunctionality M with S₂, and its real game with Sub. Every summand is the absolute difference of two acceptance probabilities of one environment, which samples the coins of P and runs the earlier calls and transfers itself.

Nothing is assumed about P, Sub, the simulators or D, and no efficiency of the environments is claimed.

theorem Cslib.Crypto.Protocols.MPC.replacementBound_seqOTSteps_le {spec₂ : MultiOracleSpec} {sc₂ : Schedule 2 spec₂} {Coins₂ : Fin 2 → Type} {M : Type} {Out : Fin 2 → Type} (W₂ : MultiOracleWorld spec₂) (Sub : Protocol 2 spec₂ sc₂ (OTIn M) Coins₂ (OTOut M)) (S₂ : (J : Finset (Fin 2)) → CoalitionSimulator sc₂ (OTIn M) Coins₂ (OTOut M) J) (I : Finset (Fin 2)) (ε : ENNReal) (hε : ∀ (q : (i : Fin 2) → OTIn M i) (D : ((i : ↥I) → PartyView (OTIn M) Coins₂ sc₂ ↑i) × ((i : Fin 2) → OTOut M i) → ProbComp Bool), ↑(semiHonestAdvantage Sub W₂ (otFunctionality M) I (S₂ I) q D) ≤ ε) (k : ℕ) {State : Fin 2 → Type} (query : Fin k → (s : Fin 2) → State s → OTIn M s) (output : (s : Fin 2) → State s → (Fin k → OTOut M s) → Out s) (st : (i : Fin 2) → State i) (D : ((i : ↥I) → Schedule.SubCoins (fun (x : (otSpec M).Op) => Coins₂) (seqBatchOTSchedule k M) ↑i × (Schedule.compose (fun (x : (otSpec M).Op) => sc₂) (seqBatchOTSchedule k M)).Received ↑i) × ((i : Fin 2) → Out i) → ProbComp Bool) :
Composition.replacementBound (otWorld M) W₂ (fun (x : (otSpec M).Op) => Sub) (fun (x : (otSpec M).Op) => S₂) I (seqOTSteps k query output) st D ≤ ↑k * ε

When every test has semi-honest advantage at most ε against Sub for the coalition I, the hybrid bound of k sequential transfers is at most k * ε.

theorem Cslib.Crypto.Protocols.MPC.semiHonestAdvantage_seqBatchOT_compose_le_mul {spec₂ : MultiOracleSpec} {sc₂ : Schedule 2 spec₂} {Coins₂ : Fin 2 → Type} (k : ℕ) (M : Type) (W₂ : MultiOracleWorld spec₂) (Sub : Protocol 2 spec₂ sc₂ (OTIn M) Coins₂ (OTOut M)) (S₂ : (J : Finset (Fin 2)) → CoalitionSimulator sc₂ (OTIn M) Coins₂ (OTOut M) J) (I : Finset (Fin 2)) (ε : ENNReal) (hε : ∀ (q : (i : Fin 2) → OTIn M i) (D : ((i : ↥I) → PartyView (OTIn M) Coins₂ sc₂ ↑i) × ((i : Fin 2) → OTOut M i) → ProbComp Bool), ↑(semiHonestAdvantage Sub W₂ (otFunctionality M) I (S₂ I) q D) ≤ ε) (x : (i : Fin 2) → (batchOTSpec k M).Query () i) (D : ((i : ↥I) → PartyView ((batchOTSpec k M).Query ()) (Schedule.ComposedCoins (fun (x : (otSpec M).Op) => Coins₂) (fun (x : Fin ((batchOTSpec k M).arity ())) => Unit) (seqBatchOTSchedule k M)) (Schedule.compose (fun (x : (otSpec M).Op) => sc₂) (seqBatchOTSchedule k M)) ↑i) × ((i : Fin 2) → (batchOTSpec k M).Answer () i) → ProbComp Bool) :
↑(semiHonestAdvantage ((seqBatchOT k M).compose fun (x : (otSpec M).Op) => Sub) W₂ (batchOTFunctionality k M) I (composeSim (seqBatchOT k M) (seqBatchOTSim k M I) fun (x : (otSpec M).Op) => S₂) x D) ≤ ↑k * ε

The batched transfer over a statistically secure single transfer. If every test has semi-honest advantage at most ε against Sub, for otFunctionality M with the simulator S₂ I of the coalition I, on every pair of inputs, then every test has advantage at most k * ε against (seqBatchOT k M).compose fun _ => Sub, for batchOTFunctionality k M with the composed simulator. The hypothesis ranges over all tests, so it holds with a small ε only for a statistically secure Sub.