Documentation

CslibFrontier.Crypto.Protocols.MPC.MaskedOT

Oblivious transfer of masked values from an oblivious transfer of pads #

maskedOT mask unmask samplePads is a two-party protocol for the single 1-out-of-2 transfer otFunctionality M of values in M, in the hybrid model whose oracle is the single transfer otSpec G of values in a pad type G. The sender (party 0) samples a pair of pads r ← samplePads as its coins. The parties call the pad transfer once: the sender submits the two pads and the receiver (party 1) its choice bit, so the receiver obtains the pad of its choice. The sender then sends the pair (mask r.1 m.1, mask r.2 m.2) of its two values masked by the two pads, and the receiver outputs unmask of its pad and the component of its choice.

This is the sender-masking step that turns a transfer of pads into a transfer of values of another type, for instance a transfer of group elements into a transfer of words with mask r m = m ⊕ H r for a key-derivation function H. It is original library infrastructure in the style of CslibFrontier/Crypto/Protocols/MPC/BatchOT/Sequential.lean; no cited theorem is claimed.

What is proved #

All statements are concrete and per instance (fixed input pair and distinguisher), in the hybrid model with the ideal pad transfer otWorld G. The only hypothesis is that, under every pad r, unmask r recovers the receiver's output otOutputs x 1 from its mask; it is stated for the value of the instance, so a mask that inverts only on words of a bounded length, such as the xor with a key of fixed length, satisfies it on inputs of that length. samplePads is an arbitrary joint distribution of the two pads.

What is not proved #

Main definitions #

Main results #

The protocol #

@[reducible, inline]

Per-party coins of maskedOT with pads in G: the sender (party 0) holds its pair of pads and the receiver (party 1) has no coins.

@[reducible]

The schedule of maskedOT: one transfer of a pad in G, the sender in slot 0 and the receiver in slot 1, then one message from the sender to the receiver carrying the two masked values.

The query of party s to the pad transfer: the sender submits its two pads and the receiver its choice bit.

def Cslib.Crypto.Protocols.MPC.maskedOTMsg {G M : Type} (mask : G → M → M) (m : M × M) (r : G × G) :
M × M

The sender's message: its two values masked by its two pads, in the order of the values.

@[reducible, inline]

The local state of party i at the end of maskedOTSchedule G M: its input and coins, its answer from the pad transfer and the message it received.

def Cslib.Crypto.Protocols.MPC.maskedOTOutput {G M : Type} (unmask : G → M → M) (i : Fin 2) (st : MaskedOTFinal G M i) :
OTOut M i

The outputs of maskedOT: () for the sender; the receiver applies unmask of its pad to the component of the sender's message selected by its choice bit, true selecting the second.

def Cslib.Crypto.Protocols.MPC.maskedOT {G M : Type} (mask unmask : G → M → M) (samplePads : ProbComp (G × G)) :

Oblivious transfer of masked values, in the hybrid model whose oracle is the single transfer otSpec G of a pad. The sender's coins are a pair of pads r ← samplePads. The parties call the pad transfer on the two pads and the receiver's choice bit, the sender sends maskedOTMsg mask m r, and the receiver outputs unmask of its pad and the component of its choice (maskedOTOutput).

Views and the execution law #

The sender's view in a run with input m and pads r: it receives () from the pad transfer and no message.

The receiver's view with choice bit σ when it obtains the pad r from the pad transfer and receives the message c.

def Cslib.Crypto.Protocols.MPC.maskedOTViews {G M : Type} (mask : G → M → M) (x : (i : Fin 2) → OTIn M i) (r : G × G) (i : Fin 2) :

The views of both parties in the run of maskedOT on the inputs x with pads r: the receiver obtains the pad selected by its choice bit and the message maskedOTMsg mask (x 0) r.

theorem Cslib.Crypto.Protocols.MPC.evalWith_maskedOT {G M : Type} (mask unmask : G → M → M) (samplePads : ProbComp (G × G)) (x : (i : Fin 2) → OTIn M i) (hmask : ∀ (r : G), unmask r (mask r (otOutputs x 1)) = otOutputs x 1) :
(maskedOT mask unmask samplePads).evalWith (otWorld G) x = samplePads.eval.bind fun (r : G × G) => PMF.pure (maskedOTViews mask x r, otOutputs x)

Execution law of maskedOT. When unmask r recovers the receiver's output otOutputs x 1 from its mask under every pad r, the execution with the ideal pad transfer draws the sender's pads r ← samplePads and returns the views maskedOTViews mask x r and the outputs otOutputs x: the receiver outputs the value of its choice.

A corrupted sender #

Simulator for a corrupted sender ({0}): samples the pads and returns the sender's input and pads, with no information from the pad transfer.

theorem Cslib.Crypto.Protocols.MPC.idealJoint_maskedOT_sender {G M : Type} (mask unmask : G → M → M) (samplePads : ProbComp (G × G)) (x : (i : Fin 2) → OTIn M i) (hmask : ∀ (r : G), unmask r (mask r (otOutputs x 1)) = otOutputs x 1) :
(idealJoint (otFunctionality M) {0} (maskedOTSenderSim samplePads) x).eval = (maskedOT mask unmask samplePads).realJoint (otWorld G) {0} x

Perfect privacy against a corrupted sender: the ideal joint distribution with maskedOTSenderSim equals the real joint distribution with the ideal pad transfer.

theorem Cslib.Crypto.Protocols.MPC.semiHonestAdvantage_maskedOT_sender {G M : Type} (mask unmask : G → M → M) (samplePads : ProbComp (G × G)) (x : (i : Fin 2) → OTIn M i) (hmask : ∀ (r : G), unmask r (mask r (otOutputs x 1)) = otOutputs x 1) (D : ((i : ↥{0}) → PartyView (OTIn M) (MaskedOTCoins G) (maskedOTSchedule G M) ↑i) × ((i : Fin 2) → OTOut M i) → ProbComp Bool) :
semiHonestAdvantage (maskedOT mask unmask samplePads) (otWorld G) (otFunctionality M) {0} (maskedOTSenderSim samplePads) x D = 0

A corrupted sender has advantage zero against every distinguisher.

A corrupted receiver #

def Cslib.Crypto.Protocols.MPC.maskedOTSimMsg {M : Type} (σ : Bool) (c u : M) :
M × M

The message with the value c in the component selected by the choice bit σ and u in the other component; true selects the second component.

def Cslib.Crypto.Protocols.MPC.maskedOTReceiverSim {G M : Type} (mask : G → M → M) (samplePads : ProbComp (G × G)) (pad : ProbComp M) :

Simulator for a corrupted receiver ({1}) with choice bit σ and output y: samples the pads and a value u ← pad, and returns the view in which the receiver obtains the pad r of its choice and the message with mask r y in the chosen component and u in the other.

def Cslib.Crypto.Protocols.MPC.maskedOTPadTest {G M : Type} (mask : G → M → M) (x : (i : Fin 2) → OTIn M i) (D : ((i : ↥{1}) → PartyView (OTIn M) (MaskedOTCoins G) (maskedOTSchedule G M) ↑i) × ((i : Fin 2) → OTOut M i) → ProbComp Bool) (r : G) (u : M) :

The reduction from a corrupted receiver's distinguisher to a test of the masked unchosen value. Given the receiver's pad r and a candidate u for the masked unchosen value, the test assembles the receiver's view on the inputs x, with mask r of the receiver's output in the chosen component of the message and u in the other, and runs D on it and the outputs.

theorem Cslib.Crypto.Protocols.MPC.bind_eval_idealJoint_maskedOT_receiver {G M : Type} (mask : G → M → M) (samplePads : ProbComp (G × G)) (pad : ProbComp M) (x : (i : Fin 2) → OTIn M i) (D : ((i : ↥{1}) → PartyView (OTIn M) (MaskedOTCoins G) (maskedOTSchedule G M) ↑i) × ((i : Fin 2) → OTOut M i) → ProbComp Bool) :
((idealJoint (otFunctionality M) {1} (maskedOTReceiverSim mask samplePads pad) x).eval.bind fun (r : ((i : ↥{1}) → PartyView (OTIn M) (MaskedOTCoins G) (maskedOTSchedule G M) ↑i) × ((i : Fin 2) → OTOut M i)) => (D r).eval) = (do let r ← samplePads let u ← pad have σ : Bool := x 1 maskedOTPadTest mask x D (if σ = true then r.2 else r.1) u).eval

The ideal game of a corrupted receiver is the pad test on a sample of pad. The ideal joint distribution of otFunctionality M for the coalition {1} with the simulator maskedOTReceiverSim mask samplePads pad, followed by a test D, draws the pads r ← samplePads and u ← pad and runs maskedOTPadTest mask x D on the receiver's pad and u. No hypothesis is needed.

theorem Cslib.Crypto.Protocols.MPC.bind_realJoint_maskedOT_receiver {G M : Type} (mask unmask : G → M → M) (samplePads : ProbComp (G × G)) (x : (i : Fin 2) → OTIn M i) (hmask : ∀ (r : G), unmask r (mask r (otOutputs x 1)) = otOutputs x 1) (D : ((i : ↥{1}) → PartyView (OTIn M) (MaskedOTCoins G) (maskedOTSchedule G M) ↑i) × ((i : Fin 2) → OTOut M i) → ProbComp Bool) :
(((maskedOT mask unmask samplePads).realJoint (otWorld G) {1} x).bind fun (r : ((i : ↥{1}) → PartyView (OTIn M) (MaskedOTCoins G) (maskedOTSchedule G M) ↑i) × ((i : Fin 2) → OTOut M i)) => (D r).eval) = (do let r ← samplePads have σ : Bool := x 1 maskedOTPadTest mask x D (if σ = true then r.2 else r.1) (if σ = true then mask r.1 (x 0).1 else mask r.2 (x 0).2)).eval

The real game of a corrupted receiver is the pad test on the masked unchosen value. When unmask r recovers the receiver's output from its mask under every pad r, the real joint distribution of maskedOT with the ideal pad transfer for the coalition {1}, followed by a test D, draws the pads r ← samplePads and runs maskedOTPadTest mask x D on the receiver's pad and the sender's unchosen value masked by the other pad.

theorem Cslib.Crypto.Protocols.MPC.semiHonestAdvantage_maskedOT_receiver_eq {G M : Type} (mask unmask : G → M → M) (samplePads : ProbComp (G × G)) (pad : ProbComp M) (x : (i : Fin 2) → OTIn M i) (hmask : ∀ (r : G), unmask r (mask r (otOutputs x 1)) = otOutputs x 1) (D : ((i : ↥{1}) → PartyView (OTIn M) (MaskedOTCoins G) (maskedOTSchedule G M) ↑i) × ((i : Fin 2) → OTOut M i) → ProbComp Bool) :
semiHonestAdvantage (maskedOT mask unmask samplePads) (otWorld G) (otFunctionality M) {1} (maskedOTReceiverSim mask samplePads pad) x D = Game.advantage (do let r ← samplePads let u ← pad have σ : Bool := x 1 maskedOTPadTest mask x D (if σ = true then r.2 else r.1) u).eval (do let r ← samplePads have σ : Bool := x 1 maskedOTPadTest mask x D (if σ = true then r.2 else r.1) (if σ = true then mask r.1 (x 0).1 else mask r.2 (x 0).2)).eval

The advantage against a corrupted receiver is the pad-hiding advantage. When unmask r recovers the receiver's output from its mask under every pad r, the semi-honest advantage of D against maskedOT with the ideal pad transfer, for the coalition {1} with the simulator maskedOTReceiverSim mask samplePads pad, equals the advantage of the test maskedOTPadTest mask x D between two experiments that both draw the pads r ← samplePads and give the test the receiver's pad: in the first the candidate is a sample of pad, and in the second it is the sender's unchosen value masked by the other pad. Nothing is assumed about mask, samplePads or pad beyond that recovery, and the right-hand side is not bounded here.

Substituting a protocol for the pad transfer #

theorem Cslib.Crypto.Protocols.MPC.semiHonestAdvantage_maskedOT_compose_le_add {G M : Type} {spec₂ : MultiOracleSpec} {sc₂ : Schedule 2 spec₂} {Coins₂ : Fin 2 → Type} (mask unmask : G → M → M) (samplePads : ProbComp (G × G)) (W₂ : MultiOracleWorld spec₂) (Sub : Protocol 2 spec₂ sc₂ (OTIn G) Coins₂ (OTOut G)) (S₁ : (J : Finset (Fin 2)) → CoalitionSimulator (maskedOTSchedule G M) (OTIn M) (MaskedOTCoins G) (OTOut M) J) (S₂ : (J : Finset (Fin 2)) → CoalitionSimulator sc₂ (OTIn G) Coins₂ (OTOut G) J) (I : Finset (Fin 2)) (ε₁ ε₂ : ENNReal) (x : (i : Fin 2) → OTIn M i) (h₁ : ∀ (D' : ((i : ↥I) → PartyView (OTIn M) (MaskedOTCoins G) (maskedOTSchedule G M) ↑i) × ((i : Fin 2) → OTOut M i) → ProbComp Bool), ↑(semiHonestAdvantage (maskedOT mask unmask samplePads) (otWorld G) (otFunctionality M) I (S₁ I) x D') ≤ ε₁) (h₂ : ∀ (q : (i : Fin 2) → OTIn G i) (D' : ((i : ↥I) → PartyView (OTIn G) Coins₂ sc₂ ↑i) × ((i : Fin 2) → OTOut G i) → ProbComp Bool), ↑(semiHonestAdvantage Sub W₂ (otFunctionality G) I (S₂ I) q D') ≤ ε₂) (D : ((i : ↥I) → PartyView (OTIn M) (Schedule.ComposedCoins (fun (x : (otSpec G).Op) => Coins₂) (MaskedOTCoins G) (maskedOTSchedule G M)) (Schedule.compose (fun (x : (otSpec G).Op) => sc₂) (maskedOTSchedule G M)) ↑i) × ((i : Fin 2) → OTOut M i) → ProbComp Bool) :
↑(semiHonestAdvantage ((maskedOT mask unmask samplePads).compose fun (x : (otSpec G).Op) => Sub) W₂ (otFunctionality M) I (composeSim (maskedOT mask unmask samplePads) (S₁ I) fun (x : (otSpec G).Op) => S₂) x D) ≤ ε₁ + ε₂

The masked transfer over a substituted pad transfer, with uniform bounds. Let Sub be a protocol for the pad transfer otFunctionality G in a world W₂, with simulators S₂, and let S₁ be simulators of maskedOT. If, for the coalition I, every test has semi-honest advantage at most ε₁ against maskedOT with the ideal pad transfer on the inputs x, and at most ε₂ against Sub on every pair of inputs, then every test has advantage at most ε₁ + ε₂ against (maskedOT mask unmask samplePads).compose fun _ => Sub, for otFunctionality M with the composed simulator.

Both hypotheses range over all tests, so they hold with small bounds only for statistically secure components: for I = {0} the first holds with ε₁ = 0 (semiHonestAdvantage_maskedOT_sender), and for I = {1} it is a bound on the pad-hiding advantage (semiHonestAdvantage_maskedOT_receiver_eq). For a computationally secure Sub the bound to use is semiHonestAdvantage_compose_le_replacementBound, with its explicit distinguishers.

theorem Cslib.Crypto.Protocols.MPC.semiHonestAdvantage_compose_seqBatchOT_maskedOT_le_sum_roundGame {G M : Type} {spec₂ : MultiOracleSpec} {sc₂ : Schedule 2 spec₂} {Coins₂ : Fin 2 → Type} {m : ℕ} (k : ℕ) {sc₁ : Schedule m (batchOTSpec k M)} {In Coins₁ Out : Fin m → Type} (P : Protocol m (batchOTSpec k M) sc₁ In Coins₁ Out) (mask unmask : G → M → M) (samplePads : ProbComp (G × G)) (W₂ : MultiOracleWorld spec₂) (Sub : Protocol 2 spec₂ sc₂ (OTIn G) Coins₂ (OTOut G)) (Sm : (J : Finset (Fin 2)) → CoalitionSimulator (maskedOTSchedule G M) (OTIn M) (MaskedOTCoins G) (OTOut M) J) (S₂ : (J : Finset (Fin 2)) → CoalitionSimulator sc₂ (OTIn G) Coins₂ (OTOut G) 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) => Schedule.ComposedCoins (fun (x : (otSpec G).Op) => Coins₂) (MaskedOTCoins G) (maskedOTSchedule G M)) (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) => Schedule.compose (fun (x : (otSpec G).Op) => sc₂) (maskedOTSchedule G M)) (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) => (maskedOT mask unmask samplePads).compose fun (x : (otSpec G).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) (J : Finset (Fin ((otSpec M).arity x))) => composeSim (maskedOT mask unmask samplePads) (Sm J) fun (x : (otSpec G).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) (J : Finset (Fin ((otSpec M).arity x))) => composeSim (maskedOT mask unmask samplePads) (Sm J) fun (x : (otSpec G).Op) => S₂) I x D) + ∑ i ∈ Finset.range sc₁.oracleRounds, ∑ j ∈ Finset.range k, (Game.advantage ((composeSeqBatchOTRoundEnv k M P W₂ ((maskedOT mask unmask samplePads).compose fun (x : (otSpec G).Op) => Sub) (fun (J : Finset (Fin 2)) => composeSim (maskedOT mask unmask samplePads) (Sm J) fun (x : (otSpec G).Op) => S₂) I x D i j).bind (Sum.elim PMF.pure fun (c : Composition.RoundChallenge (fun (x : (otSpec M).Op) => Schedule.compose (fun (x : (otSpec G).Op) => sc₂) (maskedOTSchedule G M)) fun (x : (otSpec M).Op) => Schedule.ComposedCoins (fun (x : (otSpec G).Op) => Coins₂) (MaskedOTCoins G) (maskedOTSchedule G M)) => (idealJoint (otFunctionality M) c.coalition (Sm c.coalition) c.query).eval.bind fun (r : ((i : ↥c.coalition) → PartyView (OTIn M) (MaskedOTCoins G) (maskedOTSchedule G M) ↑i) × ((i : Fin 2) → OTOut M i)) => (composeDistinguisher (maskedOT mask unmask samplePads) (fun (x : (otSpec G).Op) => S₂) c.coalition c.query c.guess r).eval)) ((composeSeqBatchOTRoundEnv k M P W₂ ((maskedOT mask unmask samplePads).compose fun (x : (otSpec G).Op) => Sub) (fun (J : Finset (Fin 2)) => composeSim (maskedOT mask unmask samplePads) (Sm J) fun (x : (otSpec G).Op) => S₂) I x D i j).bind (Sum.elim PMF.pure fun (c : Composition.RoundChallenge (fun (x : (otSpec M).Op) => Schedule.compose (fun (x : (otSpec G).Op) => sc₂) (maskedOTSchedule G M)) fun (x : (otSpec M).Op) => Schedule.ComposedCoins (fun (x : (otSpec G).Op) => Coins₂) (MaskedOTCoins G) (maskedOTSchedule G M)) => ((maskedOT mask unmask samplePads).realJoint (otWorld G) c.coalition c.query).bind fun (r : ((i : ↥c.coalition) → PartyView (OTIn M) (MaskedOTCoins G) (maskedOTSchedule G M) ↑i) × ((i : Fin 2) → OTOut M i)) => (composeDistinguisher (maskedOT mask unmask samplePads) (fun (x : (otSpec G).Op) => S₂) c.coalition c.query c.guess r).eval)) + Game.advantage ((composeSeqBatchOTRoundEnv k M P W₂ ((maskedOT mask unmask samplePads).compose fun (x : (otSpec G).Op) => Sub) (fun (J : Finset (Fin 2)) => composeSim (maskedOT mask unmask samplePads) (Sm J) fun (x : (otSpec G).Op) => S₂) I x D i j).bind (Sum.elim PMF.pure fun (c : Composition.RoundChallenge (fun (x : (otSpec M).Op) => Schedule.compose (fun (x : (otSpec G).Op) => sc₂) (maskedOTSchedule G M)) fun (x : (otSpec M).Op) => Schedule.ComposedCoins (fun (x : (otSpec G).Op) => Coins₂) (MaskedOTCoins G) (maskedOTSchedule G M)) => (composeRoundEnv (maskedOT mask unmask samplePads) (otWorld G) W₂ (fun (x : (otSpec G).Op) => Sub) (fun (x : (otSpec G).Op) => S₂) c.coalition c.query c.guess 0).bind (Composition.roundGame fun (op : (otSpec G).Op) (J : Finset (Fin ((otSpec G).arity op))) (q : (s : Fin ((otSpec G).arity op)) → (otSpec G).Query op s) => (idealJoint (otWorld G op) J (S₂ J) q).eval))) ((composeSeqBatchOTRoundEnv k M P W₂ ((maskedOT mask unmask samplePads).compose fun (x : (otSpec G).Op) => Sub) (fun (J : Finset (Fin 2)) => composeSim (maskedOT mask unmask samplePads) (Sm J) fun (x : (otSpec G).Op) => S₂) I x D i j).bind (Sum.elim PMF.pure fun (c : Composition.RoundChallenge (fun (x : (otSpec M).Op) => Schedule.compose (fun (x : (otSpec G).Op) => sc₂) (maskedOTSchedule G M)) fun (x : (otSpec M).Op) => Schedule.ComposedCoins (fun (x : (otSpec G).Op) => Coins₂) (MaskedOTCoins G) (maskedOTSchedule G M)) => (composeRoundEnv (maskedOT mask unmask samplePads) (otWorld G) W₂ (fun (x : (otSpec G).Op) => Sub) (fun (x : (otSpec G).Op) => S₂) c.coalition c.query c.guess 0).bind (Composition.roundGame fun (x : (otSpec G).Op) (J : Finset (Fin ((otSpec G).arity x))) (q : (s : Fin ((otSpec G).arity x)) → (otSpec G).Query x s) => Sub.realJoint W₂ J q))))

An outer protocol over sequential masked transfers over a substituted pad transfer, with one environment per term. 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 maskedOT, and the pad transfer of maskedOT run by a protocol Sub in a world W₂. The semi-honest advantage of D against the composed protocol, with the composed simulator, is at most the advantage of composeDistinguisher against P with the ideal batched transfer, plus, for every call i of P and every transfer j < k, two advantages of the environment composeSeqBatchOTRoundEnv of that transfer followed by one further stage:

  • between the ideal and the real game of maskedOT with the ideal pad transfer, against composeDistinguisher (for a corrupted receiver this is where the pads have to hide the value that was not chosen);
  • between the ideal game of the pad transfer, with the simulator S₂, and its real game with Sub (composeRoundEnv of maskedOT).

Every term is the absolute difference of two acceptance probabilities of one environment, which samples the coins of P and the pads and runs the earlier calls and transfers itself. Nothing is assumed about P, Sub, mask, the simulators or D; no term is bounded here and no efficiency of the environments is claimed.