Documentation

CslibFrontier.Crypto.Protocols.UC.WordInterface

Binary word presentation of typed UC interfaces #

Library infrastructure toward #6043 and #8377 (no cited result): typed UC machines and environments communicate over indexed query-reply specifications E : ι → Type (partySpec, netSpec, protocolSpec, execSpec), whereas WordOracleComp and IsOraclePPTOn execute on finite channel tags carrying List Bool payloads. This module supplies the lowering from typed ProbOracleComp programs to WordOracleComp programs over finitely many channels, together with the dual encoded oracle, canonical-request normalizer, and strict oracle PPT preservation certificates.

Modelling decisions and restrictions #

Main definitions #

Main results #

Library construction (no cited definition): a binary presentation of one typed port netSpec Q R packaging total decoders for its queries and replies. Because queryDecoder.decode [] must inhabit Q, any total party port WordPort (Fin n × In) (Option Out) intrinsically requires n ≥ 1 (not merely the WordPort.party constructor), whereas an empty corruption set C = ∅ at positive n is distinct and covered.

structure Cslib.Crypto.Protocols.UC.WordInterface {ι : Type} (E : ι → Type) :

Library construction (no cited definition): a typed interface presented over finitely many word channels.

Library infrastructure: word presentation of the empty interface OracleSpec.empty.

Library infrastructure: word presentation of a single typed port netSpec Q R.

def Cslib.Crypto.Protocols.UC.WordInterface.sum {ι₁ ι₂ : Type} {E₁ : ι₁ → Type} {E₂ : ι₂ → Type} (left : WordInterface E₁) (right : WordInterface E₂) :

Library infrastructure: disjoint sum of two typed word interfaces.

@[reducible, inline]
abbrev Cslib.Crypto.Protocols.UC.WordInterface.protocol {n : ℕ} {In Out NetQ NetR : Type} (party : WordPort (Fin n × In) (Option Out)) (netPort : WordPort NetQ NetR) :
WordInterface (protocolSpec n In Out NetQ NetR)

Library construction (no cited definition): word interface for a UC protocol protocolSpec n In Out NetQ NetR.

@[reducible, inline]
abbrev Cslib.Crypto.Protocols.UC.WordInterface.exec {n : ℕ} {In Out AdvQ AdvR : Type} (party : WordPort (Fin n × In) (Option Out)) (adv : WordPort AdvQ AdvR) :
WordInterface (execSpec n In Out AdvQ AdvR)

Library construction (no cited definition): word interface for a UC execution environment execSpec n In Out AdvQ AdvR.

Library infrastructure (no cited result): view a WordInterface as a partial OracleCodec that accepts exactly canonical (I.channel q, I.request q) pairs.

noncomputable def Cslib.Crypto.Protocols.UC.WordInterface.encodeOracle {ι : Type} {E : ι → Type} {σ : Type} (I : WordInterface E) (oracle : (q : ι) → StateT σ PMF (E q)) :

Library infrastructure (no cited result): present a typed stateful oracle on I.Channel by routing through I.toOracleCodec.wordOracle at the I.requestNormalize-normalized request. Unlike calling I.toOracleCodec.wordOracle directly (which answers off-image requests with [] without querying oracle), encodeOracle normalizes every request to I.toOracleCodec.encodeQuery (I.decodeQuery cw.1 cw.2) via I.request_decodeQuery and calls oracle once (encodeOracle_apply); both agree on encoded requests (encodeOracle_eq_wordOracle).

theorem Cslib.Crypto.Protocols.UC.WordInterface.encodeOracle_apply {ι : Type} {E : ι → Type} {σ : Type} (I : WordInterface E) (oracle : (q : ι) → StateT σ PMF (E q)) (c : I.Channel) (w : List Bool) (s : σ) :
I.encodeOracle oracle (c, w) s = PMF.map (fun (x : E (I.decodeQuery c w) × σ) => ((I.reply (I.decodeQuery c w)) x.1, x.2)) (oracle (I.decodeQuery c w) s)

Library infrastructure (no cited result): stateful equation for I.encodeOracle oracle on any (c, w) and state s, obtained by normalizing (c, w) via I.request_decodeQuery and applying OracleCodec.wordOracle_encodeQuery.

@[simp]

Library infrastructure (no cited result): I.requestNormalize fixes every canonical request word I.request q on its channel I.channel q.

@[simp]

Library infrastructure (no cited result): I.requestNormalize is idempotent on every channel and word.

theorem Cslib.Crypto.Protocols.UC.WordInterface.encodeOracle_eq_wordOracle {ι : Type} {E : ι → Type} {σ : Type} (I : WordInterface E) (oracle : (q : ι) → StateT σ PMF (E q)) (q : ι) :

Library infrastructure (no cited result): on every canonical query request (I.channel q, I.request q), the total channel-encoded oracle agrees with I.toOracleCodec.wordOracle. Off-image requests differ: encodeOracle normalizes the request via I.requestNormalize before delegating to I.toOracleCodec.wordOracle and therefore still calls oracle on I.decodeQuery, whereas OracleCodec.wordOracle directly returns [].

theorem Cslib.Crypto.Protocols.UC.WordInterface.encodeOracle_sum {ι₁ ι₂ : Type} {E₁ : ι₁ → Type} {E₂ : ι₂ → Type} {σ : Type} (I₁ : WordInterface E₁) (I₂ : WordInterface E₂) (o₁ : (q : ι₁) → StateT σ PMF (E₁ q)) (o₂ : (q : ι₂) → StateT σ PMF (E₂ q)) :
(I₁.sum I₂).encodeOracle (OracleComp.sumHandler o₁ o₂) = fun (cw : (I₁.sum I₂).Channel × List Bool) => Sum.elim (fun (c₁ : I₁.Channel) => I₁.encodeOracle o₁ (c₁, cw.2)) (fun (c₂ : I₂.Channel) => I₂.encodeOracle o₂ (c₂, cw.2)) cw.1

Library infrastructure (no cited result): the encoded oracle of a sum interface routes left and right channel requests to the respective component encoded oracles.

Library infrastructure: lower a single typed query to its channel request with reply truncation to limit bits and decoding.

theorem Cslib.Crypto.Protocols.UC.WordInterface.runWith_lowerQuery {ι : Type} {E : ι → Type} {σ : Type} (I : WordInterface E) {limit : ℕ} (oracle : (q : ι) → StateT σ PMF (E q)) (hfit : ∀ (q : ι) (s : σ), ∀ x ∈ (oracle q s).support, ((I.reply q) x.1).length ≤ limit) (q : ι) (s : σ) :
ProbOracleComp.runWith (I.encodeOracle oracle) (I.lowerQuery limit q) s = oracle q s

Library infrastructure: running a single lowered query against I.encodeOracle oracle agrees with running oracle when every supported reply fits in limit bits.

def Cslib.Crypto.Protocols.UC.WordPort.sum {Q₁ R₁ Q₂ R₂ : Type} (p₁ : WordPort Q₁ R₁) (p₂ : WordPort Q₂ R₂) :
WordPort (Q₁ ⊕ Q₂) (R₁ ⊕ R₂)

Library construction (no cited definition): disjoint sum of two typed word ports, e.g. for RoutedNetQ / RoutedNetR.

def Cslib.Crypto.Protocols.UC.WordPort.party {n : ℕ} [NeZero n] {In Out : Type} (input : WordPort In Out) :
WordPort (Fin n × In) (Option Out)

Library construction (no cited definition): party-port word presentation for n ≥ 1 ([NeZero n]) parties, encoding party indices in unary and decoding arbitrary words modulo n.

Library infrastructure (no cited result): WordPort.party input exposes the decoded party index Fin n in polynomial time.

Library construction (no cited definition): lower a typed program ProbOracleComp E α to a word program over I.Channel via ProbOracleComp.simulate (I.lowerQuery limit), keeping private samples private and truncating each word reply to limit bits before decoding.

theorem Cslib.ProbOracleComp.runWith_lowerWith {ι : Type} {E : ι → Type} {α : Type} (I : Crypto.Protocols.UC.WordInterface E) {limit : ℕ} {σ : Type} (oracle : (q : ι) → StateT σ PMF (E q)) (hfit : ∀ (q : ι) (s : σ), ∀ x ∈ (oracle q s).support, ((I.reply q) x.1).length ≤ limit) (program : ProbOracleComp E α) (s : σ) :
runWith (I.encodeOracle oracle) (lowerWith I limit program) s = runWith oracle program s

Library infrastructure (no cited result): a typed program lowered with reply bound limit has the joint law of the typed program against every typed stateful oracle whose encoded replies fit in limit bits.

theorem Cslib.Crypto.Protocols.UC.WordInterface.isOraclePPTOn_lowerWith_query {ι α : Type} {E : ι → Type} (I : WordInterface E) {input : α ↪ List Bool} {query : α → ι} {limit : α → ℕ} (hchannel : Turing.MultiTapeTM.ComputableInPolyTime (fun (a : α) => I.channel (query a)) input (Turing.MultiTapeTM.encFinite I.Channel)) (hrequest : Turing.MultiTapeTM.ComputableInPolyTime (fun (a : α) => I.request (query a)) input Turing.MultiTapeTM.encBits) (hlimit : Turing.MultiTapeTM.ComputableInPolyTime limit input Turing.MultiTapeTM.encUnary) :

Library infrastructure (no cited result): one lowered typed query, re-encoded, is uniform strict oracle PPT on I.Channel when its channel, request, and reply bound are computed in polynomial time. This consumes the replyNormalize and computable_replyNormalize interface certificates.

Library infrastructure (no cited result): a lowered, re-encoded decoded query I.decodeQuery (ch a) (word a) is uniform strict oracle PPT when its channel, request word, and reply bound are computable in polynomial time.

Canonical-request normalizer #

Rewrite every external word query (c, w) of a word program to its canonical representative (c, I.requestNormalize c w), preserving private coin draws and returning oracle replies verbatim.

@[simp]

Request normalization preserves returned values.

@[simp]
theorem Cslib.Crypto.Protocols.UC.WordInterface.normalizeRequests_bind {ι α β : Type} {E : ι → Type} (I : WordInterface E) (program : Probability.WordOracleComp I.Channel α) (next : α → Probability.WordOracleComp I.Channel β) :
I.normalizeRequests (program >>= next) = do let a ← I.normalizeRequests program I.normalizeRequests (next a)

Request normalization distributes over bind.

@[simp]
theorem Cslib.Crypto.Protocols.UC.WordInterface.normalizeRequests_map {ι α β : Type} {E : ι → Type} (I : WordInterface E) (f : α → β) (program : Probability.WordOracleComp I.Channel α) :
I.normalizeRequests (f <$> program) = f <$> I.normalizeRequests program

Request normalization commutes with mapping.

@[simp]

Request normalization preserves private samples.

@[simp]

Request normalization rewrites a single query (c, w) to (c, I.requestNormalize c w).

Interacting with the total normalized oracle I.encodeOracle oracle produces the exact same joint output and oracle-state distribution as running I.normalizeRequests program against I.toOracleCodec.wordOracle oracle (which leaves oracle state unchanged on off-image requests), for every word program (including off-image queries).

theorem Cslib.Crypto.Protocols.UC.WordInterface.runWith_encodeOracle_eq_adapt_normalizeRequests {ι α σ : Type} {E : ι → Type} (I : WordInterface E) (oracle : (q : ι) → StateT σ PMF (E q)) (program : Probability.WordOracleComp I.Channel α) (s : σ) :

Interacting with I.encodeOracle oracle produces the same joint output and oracle-state law as running the typed adaptation I.toOracleCodec.adapt (I.normalizeRequests program) directly against oracle.

Every external query issued by I.normalizeRequests program is a canonical (I.channel q, I.request q) pair.

theorem Cslib.Crypto.Protocols.UC.WordInterface.normalizeRequests_eq_self {ι α : Type} {E : ι → Type} (I : WordInterface E) {program : Probability.WordOracleComp I.Channel α} (h : ProbOracleComp.QueriesSatisfy (fun (cw : I.Channel × List Bool) => ∃ (q : ι), cw = (I.channel q, I.request q)) program) :
I.normalizeRequests program = program

Any word program whose queries are already canonical is fixed identically by I.normalizeRequests.

@[simp]

Canonical-request normalization is idempotent.

theorem Cslib.Crypto.Protocols.UC.WordInterface.queriesSatisfy_lowerWith {ι α : Type} {E : ι → Type} (I : WordInterface E) (limit : ℕ) (program : ProbOracleComp E α) :
ProbOracleComp.QueriesSatisfy (fun (cw : I.Channel × List Bool) => ∃ (q : ι), cw = (I.channel q, I.request q)) (ProbOracleComp.lowerWith I limit program)

Every external query issued by a lowered typed program program.lowerWith I limit is canonical.

@[simp]

Lowered typed programs are already canonical and therefore fixed by I.normalizeRequests.

theorem Cslib.Crypto.Protocols.UC.WordInterface.runWith_encodeOracle_eq_wordOracle_of_queriesSatisfy {ι α σ : Type} {E : ι → Type} (I : WordInterface E) (oracle : (q : ι) → StateT σ PMF (E q)) {program : Probability.WordOracleComp I.Channel α} (h : ProbOracleComp.QueriesSatisfy (fun (cw : I.Channel × List Bool) => ∃ (q : ι), cw = (I.channel q, I.request q)) program) (s : σ) :

For any word program whose queries are all canonical, I.encodeOracle oracle and I.toOracleCodec.wordOracle oracle induce the same joint output and oracle-state law.

Canonical-request normalization preserves external query budgets.

theorem Cslib.Crypto.Protocols.UC.WordInterface.isOraclePPTOn_normalizeRequests {ι α β : Type} {E : ι → Type} (I : WordInterface E) {input : α ↪ List Bool} {output : β ↪ List Bool} {program : α → Probability.WordOracleComp I.Channel β} (hprogram : Probability.IsOraclePPTOn input output program) :
Probability.IsOraclePPTOn input output fun (a : α) => I.normalizeRequests (program a)

Canonical-request normalization preserves uniform strict oracle PPT for arbitrary word adversaries, with no extra reply-length assumption: a polynomial-time realizing machine running for T steps cannot inspect beyond the first T bits of any oracle reply (Turing.MultiTapePTM.runOracle_eq_simulate_take), so normalizing each request and taking T reply bits realizes I.normalizeRequests identically against every stateful external oracle.