Definitions for Key recycling in authentication
DefinitionQAlgorithms_Papers_Independent_Intake100_P41The objects the formalized statements of Key recycling in authentication (arXiv:1202.1229) are stated in. Each was checked against the paper by a blind read-back and a moderator.
Tag: PDF p.4, Definition 2: the m-bit tag alphabet, including the empty word.uniformAverage: PDF p.4: expectation under the uniform distribution on a finite seed set. Theorems require that the seed set be nonempty.uniformProbability: PDF p.4: probability of an event under a uniform finite seed.authConditionedSeedAverage: PDF p.8: uniform conditioning for the standard simulator. An impossible conditioning event falls back to the original uniform law; its real branch has zero probability. This also makes the simulator total at epsilon >= 1.IsASU2: PDF p.4, Definition 1: pair bound only, without marginal uniformity.IsAXU2: PDF p.4, Definition 2: the source's XOR universality convention.paddedTag: PDF pp.4,10--11: an actual tag with an independent OTP.CausalTest: PDF pp.7--9: all causal, terminating binary tests of an interactive system. There is no computational restriction or finite-alphabet restriction. Every finite observation prefix can be tested; private randomized tests are mixtures of these after their private randomness is fixed.testValue: PDF pp.7--9: deterministic execution of a causal test against a resource.AuthInput: PDF pp.7,10--16: the externally chosen input actions. For an asynchronous resource timeout is an inert action, conveying no synchronized event.AuthOutput: PDF pp.10--16: observations at all three interfaces. An empty deliveries list means no response; a list entrynoneis a rejection. Keys are emitted only on release, with Alice's and Bob's releases distinguished.silent: PDF pp.7,16: a step with no output is observably different from rejection.AuthState: PDF pp.10--16: send and submission orders have separate counters. The first submitted pair is retained for the standard simulator's rejection conditioning.authInitialState: PDF pp.7,10--16: initial protocol state; no message has yet been supplied.authMachineStep: PDF pp.10--16, Figures 7--11: explicit input/output scheduling. Submission i checks pad i even if send i has not occurred. Bob releases after n verifications or final timeout; Alice only at final timeout. Timeout emits one rejection per missing delivery and closes both interfaces. With recycling disabled it does nothing, so withholding an asynchronous message never creates a rejection. Excess calls to an already-used port are inert.padAt: PDF pp.13--14: the input reserve contains one hash key and exactly n pads. Out-of-range lookup returns the zero word; authMachineStep never uses that branch.paddedStep: PDF pp.10--16: real padded protocol, or authentic ideal channel with the fixed Figure 8 simulator. In the ideal execution tags are independent uniform pad-seed entries, and only an exact previously sent pair can be delivered. The simulator never uses the ideal hash key to choose its tags or decisions. The key is nevertheless visible to a test at the specified release steps.HonestInput: PDF p.8, Definition 4(i): honest users can choose messages and the final synchronization event, but have no malicious-channel submission interface.honestStep: PDF pp.8,11,14: attach the honest forwarding filter and hide Eve's tag port. The ideal version is the authentic channel's allow-delivery filter: its internal simulated tag is hidden and exactly forwarded, so no simulator output is exposed.PaddedConstructionSecure: PDF p.8, Definition 4, instantiated on the explicit padded executions. First clause: honest filtered distance zero. Second: the same fixed simulator works for every causal test, including tests that learn Bob's released key and then choose Alice's later inputs. A uniform seed in K × (Fin n → Tag m) is one uniform hash key and n mutually independent fresh pads, also independent of the test. Both clauses compare full executions, not just forgery probabilities.standardStep: PDF pp.7--9,17--18: standard authentication has one unpadded tag and exports no key. The ideal decision is exact pair equality, with impersonation rejected.standardIdealValue: PDF p.8: the one fixed standard-authentication simulator. At the first send it samples its own uniform hash key. If a submission was already rejected, it instead samples uniformly among keys rejecting that pair. Empty conditioning sets use the explicit harmless fallback in authConditionedSeedAverage. All other steps use exact-match delivery, and never leak the simulator's key.StandardConstructionSecure: PDF p.8, Definition 4, and pp.17--18, Lemma 9: full resource security for the actual unpadded execution and the fixed rejection-conditioned simulator. Honest filtered executions agree exactly; every adversarial causal test is bounded.RoundView: PDF pp.16--17: complete public transcript of one attempted substitution.AdaptiveAttack: PDF pp.16--17: a chosen-message attacker uses only public earlier rounds, including feedback, and the current intercepted pair. It has no secret-key argument. An existential attack is chosen before the uniform execution seed.attackTrace: PDF pp.16--17: execute n sequential chosen-message rounds with the same hash key and independent pads; append all messages, tags and verification bits.corrupts: PDF p.16: success means accepting a changed message in at least one round.posteriorKey: PDF pp.16--17: posterior law of the retained hash index, under a uniform joint key/pad seed. At any actually observed z its denominator is positive. Unobserved fibers have Lean's total value zero and contribute no entropy.conditionalKeyEntropy: PDF pp.16--17: classical conditional Shannon entropy in bits. Averaging fiber entropy over the original finite seed avoids requiring a finite message alphabet or a Fintype on all possible transcript values. The entropy is of K, not of the OTP seed P. The zero-mass convention is 0 log 0 = 0.leakageBound: PDF pp.16--17, Theorem 8: the second term is zero at n = |T|, as given by its zero-probability branch in the proof. It is not a logarithm of a sum.prematureReleaseView: PDF pp.3,10: the allowed subsequent application reveals k before Bob verifies the pending pair. The attacker gets the revealed key and intercepted pair, but not the OTP. This is a concrete known-key context for premature reuse.
import Mathlib
import Definitions.Def_QAlgorithms_Papers_Independent_Bridge50_P44
/-!
Portmann, arXiv:1202.1229v3. Concrete finite-randomness executions of the
classical authentication resources. Tests have unrestricted computation and
choose each input after seeing all preceding outputs. Fixing a test's private
coins gives such a deterministic causal test, so the universal bounds include
randomized environments by averaging. Prefix tests include stopping, suppressing
messages, and ignoring interfaces. The ideal executions include one fixed
simulator, defined before tests, rather than a security assumption in a record.
All new definitions are local to this paper. QKD reserve composition is deferred.
Compilation is pending the separate mechanical stage.
-/
noncomputable section
open scoped BigOperators
namespace QAlgorithms.Papers.Independent.Intake100.P41
open QAlgorithms.Papers.Independent.Bridge50.P44 (xorWord verifyTag)
attribute [local instance] Classical.propDecidable Classical.decEq
/-- PDF p.4, Definition 2: the m-bit tag alphabet, including the empty word. -/
abbrev Tag (m : ℕ) := Fin m → Bool
/-- PDF p.4: expectation under the uniform distribution on a finite seed set.
Theorems require that the seed set be nonempty. -/
def uniformAverage {S : Type*} [Fintype S] (f : S → ℝ) : ℝ :=
(∑ s, f s) / (Fintype.card S : ℝ)
/-- PDF p.4: probability of an event under a uniform finite seed. -/
def uniformProbability {S : Type*} [Fintype S] (p : S → Prop) : ℝ :=
((Finset.univ.filter p).card : ℝ) / (Fintype.card S : ℝ)
/-- PDF p.8: uniform conditioning for the standard simulator. An impossible
conditioning event falls back to the original uniform law; its real branch has
zero probability. This also makes the simulator total at epsilon >= 1. -/
def authConditionedSeedAverage {S : Type*} [Fintype S] (p : S → Prop) (f : S → ℝ) : ℝ :=
if (Finset.univ.filter p).Nonempty then
(∑ s ∈ Finset.univ.filter p, f s) / ((Finset.univ.filter p).card : ℝ)
else uniformAverage f
/-- PDF p.4, Definition 1: pair bound only, without marginal uniformity. -/
def IsASU2 {K X T : Type*} [Fintype K] [Fintype T]
(h : K → X → T) (epsilon : ℝ) : Prop :=
∀ x y, x ≠ y → ∀ a b,
uniformProbability (fun k => h k x = a ∧ h k y = b) ≤
epsilon / (Fintype.card T : ℝ)
/-- PDF p.4, Definition 2: the source's XOR universality convention. -/
def IsAXU2 {K X : Type*} [Fintype K] {m : ℕ}
(h : K → X → Tag m) (epsilon : ℝ) : Prop :=
∀ x y, x ≠ y → ∀ c,
uniformProbability (fun k => xorWord (h k x) (h k y) = c) ≤ epsilon
/-- PDF pp.4,10--11: an actual tag with an independent OTP. -/
def paddedTag {K X : Type*} {m : ℕ} (h : K → X → Tag m)
(k : K) (pad : Tag m) (x : X) : Tag m :=
xorWord (h k x) pad
/-- PDF pp.7--9: all causal, terminating binary tests of an interactive system.
There is no computational restriction or finite-alphabet restriction. Every
finite observation prefix can be tested; private randomized tests are mixtures
of these after their private randomness is fixed. -/
inductive CausalTest (I O : Type*) where
| stop : Bool → CausalTest I O
| step : I → (O → CausalTest I O) → CausalTest I O
/-- PDF pp.7--9: deterministic execution of a causal test against a resource. -/
def testValue {S I O : Type*} (step : S → I → S × O) (s : S) :
CausalTest I O → ℝ
| .stop b => if b then 1 else 0
| .step a next =>
let result := step s a
testValue step result.1 (next result.2)
/-- PDF pp.7,10--16: the externally chosen input actions. For an asynchronous
resource timeout is an inert action, conveying no synchronized event. -/
inductive AuthInput (X T : Type*) where
| send : X → AuthInput X T
| submit : X × T → AuthInput X T
| timeout : AuthInput X T
/-- PDF pp.10--16: observations at all three interfaces. An empty deliveries
list means no response; a list entry `none` is a rejection. Keys are emitted
only on release, with Alice's and Bob's releases distinguished. -/
structure AuthOutput (K X T : Type*) where
tag : Option (X × T)
deliveries : List (Option X)
aliceKey : Option K
bobKey : Option K
/-- PDF pp.7,16: a step with no output is observably different from rejection. -/
def silent {K X T : Type*} : AuthOutput K X T :=
⟨none, [], none, none⟩
/-- PDF pp.10--16: send and submission orders have separate counters. The first
submitted pair is retained for the standard simulator's rejection conditioning. -/
structure AuthState (X T : Type*) where
sent : List (X × T)
received : ℕ
firstSubmitted : Option (X × T)
closed : Bool
/-- PDF pp.7,10--16: initial protocol state; no message has yet been supplied. -/
def authInitialState {X T : Type*} : AuthState X T :=
⟨[], 0, none, false⟩
/-- PDF pp.10--16, Figures 7--11: explicit input/output scheduling. Submission i
checks pad i even if send i has not occurred. Bob releases after n verifications
or final timeout; Alice only at final timeout. Timeout emits one rejection per
missing delivery and closes both interfaces. With recycling disabled it does
nothing, so withholding an asynchronous message never creates a rejection.
Excess calls to an already-used port are inert. -/
def authMachineStep {K X T : Type*} (n : ℕ) (recycle : Bool) (k : K)
(makeTag : ℕ → X → T)
(valid : AuthState X T → ℕ → X × T → Bool)
(s : AuthState X T) (input : AuthInput X T) :
AuthState X T × AuthOutput K X T :=
if s.closed then (s, silent) else
match input with
| .send x =>
if s.sent.length < n then
let pair := (x, makeTag s.sent.length x)
({s with sent := s.sent ++ [pair]}, {(silent : AuthOutput K X T) with tag := some pair})
else (s, silent)
| .submit pair =>
if s.received < n then
let y := if valid s s.received pair then some pair.1 else none
let released := if recycle = true ∧ s.received + 1 = n then some k else none
({ s with
received := s.received + 1
firstSubmitted := if s.received = 0 then some pair else s.firstSubmitted },
{ (silent : AuthOutput K X T) with
deliveries := [y]
bobKey := released })
else (s, silent)
| .timeout =>
if recycle then
({ s with
closed := true
received := n },
{ (silent : AuthOutput K X T) with
deliveries := List.replicate (n - s.received) none
aliceKey := some k
bobKey := if s.received < n then some k else none })
else (s, silent)
/-- PDF pp.13--14: the input reserve contains one hash key and exactly n pads.
Out-of-range lookup returns the zero word; authMachineStep never uses that branch. -/
def padAt {m n : ℕ} (pads : Fin n → Tag m) (i : ℕ) : Tag m :=
if hi : i < n then pads ⟨i, hi⟩ else fun _ => false
/-- PDF pp.10--16: real padded protocol, or authentic ideal channel with the
fixed Figure 8 simulator. In the ideal execution tags are independent uniform
pad-seed entries, and only an exact previously sent pair can be delivered.
The simulator never uses the ideal hash key to choose its tags or decisions.
The key is nevertheless visible to a test at the specified release steps. -/
def paddedStep {K X : Type*} {m n : ℕ} (ideal recycle : Bool)
(h : K → X → Tag m) (k : K) (pads : Fin n → Tag m) :=
authMachineStep n recycle k
(fun i x => if ideal then padAt pads i else paddedTag h k (padAt pads i) x)
(fun s i pair => if ideal then decide (s.sent[i]? = some pair)
else decide (pair.2 = paddedTag h k (padAt pads i) pair.1))
/-- PDF p.8, Definition 4(i): honest users can choose messages and the final
synchronization event, but have no malicious-channel submission interface. -/
inductive HonestInput (X : Type*) where
| send : X → HonestInput X
| timeout : HonestInput X
/-- PDF pp.8,11,14: attach the honest forwarding filter and hide Eve's tag port.
The ideal version is the authentic channel's allow-delivery filter: its internal
simulated tag is hidden and exactly forwarded, so no simulator output is exposed. -/
def honestStep {K X T : Type*}
(step : AuthState X T → AuthInput X T → AuthState X T × AuthOutput K X T)
(s : AuthState X T) (input : HonestInput X) :
AuthState X T × AuthOutput K X T :=
match input with
| .timeout => step s .timeout
| .send x =>
let first := step s (.send x)
match first.2.tag with
| none => first
| some pair =>
let second := step first.1 (.submit pair)
(second.1, {second.2 with tag := none})
/-- PDF p.8, Definition 4, instantiated on the explicit padded executions.
First clause: honest filtered distance zero. Second: the same fixed simulator
works for every causal test, including tests that learn Bob's released key and
then choose Alice's later inputs. A uniform seed in K × (Fin n → Tag m) is one
uniform hash key and n mutually independent fresh pads, also independent of the
test. Both clauses compare full executions, not just forgery probabilities. -/
def PaddedConstructionSecure {K X : Type*} [Fintype K] {m n : ℕ}
(h : K → X → Tag m) (recycle : Bool) (epsilon : ℝ) : Prop :=
(∀ d : CausalTest (HonestInput X) (AuthOutput K X (Tag m)),
uniformAverage (fun seed : K × (Fin n → Tag m) =>
testValue (honestStep (paddedStep false recycle h seed.1 seed.2)) authInitialState d) =
uniformAverage (fun seed : K × (Fin n → Tag m) =>
testValue (honestStep (paddedStep true recycle h seed.1 seed.2)) authInitialState d)) ∧
∀ d : CausalTest (AuthInput X (Tag m)) (AuthOutput K X (Tag m)),
|uniformAverage (fun seed : K × (Fin n → Tag m) =>
testValue (paddedStep false recycle h seed.1 seed.2) authInitialState d) -
uniformAverage (fun seed : K × (Fin n → Tag m) =>
testValue (paddedStep true recycle h seed.1 seed.2) authInitialState d)| ≤ epsilon
/-- PDF pp.7--9,17--18: standard authentication has one unpadded tag and exports
no key. The ideal decision is exact pair equality, with impersonation rejected. -/
def standardStep {K X T : Type*} (ideal : Bool) (h : K → X → T) (k : K) :=
authMachineStep 1 false k (fun _ x => h k x)
(fun s i pair => if ideal then decide (s.sent[i]? = some pair)
else decide (verifyTag h k pair = some pair.1))
/-- PDF p.8: the one fixed standard-authentication simulator. At the first send
it samples its own uniform hash key. If a submission was already rejected, it
instead samples uniformly among keys rejecting that pair. Empty conditioning
sets use the explicit harmless fallback in authConditionedSeedAverage. All other steps
use exact-match delivery, and never leak the simulator's key. -/
def standardIdealValue {K X T : Type*} [Fintype K] [Nonempty K]
(h : K → X → T) (s : AuthState X T) :
CausalTest (AuthInput X T) (AuthOutput K X T) → ℝ
| .stop b => if b then 1 else 0
| .step input next =>
match input with
| .send x =>
if s.closed = false ∧ s.sent.length < 1 then
authConditionedSeedAverage
(fun k => match s.firstSubmitted with
| none => True
| some pair => h k pair.1 ≠ pair.2)
(fun k =>
let result := standardStep true h k s (.send x)
standardIdealValue h result.1 (next result.2))
else
let result := standardStep true h (Classical.choice inferInstance) s input
standardIdealValue h result.1 (next result.2)
| _ =>
let result := standardStep true h (Classical.choice inferInstance) s input
standardIdealValue h result.1 (next result.2)
/-- PDF p.8, Definition 4, and pp.17--18, Lemma 9: full resource security for the
actual unpadded execution and the fixed rejection-conditioned simulator. Honest
filtered executions agree exactly; every adversarial causal test is bounded. -/
def StandardConstructionSecure {K X T : Type*} [Fintype K] [Nonempty K]
(h : K → X → T) (epsilon : ℝ) : Prop :=
(∀ d : CausalTest (HonestInput X) (AuthOutput K X T),
uniformAverage (fun k : K => testValue (honestStep (standardStep false h k)) authInitialState d) =
uniformAverage (fun k : K => testValue (honestStep (standardStep true h k)) authInitialState d)) ∧
∀ d : CausalTest (AuthInput X T) (AuthOutput K X T),
|uniformAverage (fun k : K => testValue (standardStep false h k) authInitialState d) -
standardIdealValue h authInitialState d| ≤ epsilon
/-- PDF pp.16--17: complete public transcript of one attempted substitution. -/
structure RoundView (X T : Type*) where
message : X
tag : T
submitted : X × T
accepted : Bool
/-- PDF pp.16--17: a chosen-message attacker uses only public earlier rounds,
including feedback, and the current intercepted pair. It has no secret-key
argument. An existential attack is chosen before the uniform execution seed. -/
structure AdaptiveAttack (X T : Type*) where
message : List (RoundView X T) → X
substitute : List (RoundView X T) → X × T → X × T
/-- PDF pp.16--17: execute n sequential chosen-message rounds with the same
hash key and independent pads; append all messages, tags and verification bits. -/
def attackTrace {K X : Type*} {m n : ℕ} (h : K → X → Tag m)
(a : AdaptiveAttack X (Tag m)) (k : K) (pads : Fin n → Tag m) :
List (RoundView X (Tag m)) :=
(List.finRange n).foldl (fun history i =>
let x := a.message history
let t := paddedTag h k (pads i) x
let pair := a.substitute history (x, t)
history ++ [⟨x, t, pair, decide (pair.2 = paddedTag h k (pads i) pair.1)⟩]) []
/-- PDF p.16: success means accepting a changed message in at least one round. -/
def corrupts {X T : Type*} (z : List (RoundView X T)) : Prop :=
∃ r ∈ z, r.accepted = true ∧ r.submitted.1 ≠ r.message
/-- PDF pp.16--17: posterior law of the retained hash index, under a uniform
joint key/pad seed. At any actually observed z its denominator is positive.
Unobserved fibers have Lean's total value zero and contribute no entropy. -/
def posteriorKey {K P Z : Type*} [Fintype K] [Fintype P]
(observe : K × P → Z) (z : Z) (k : K) : ℝ :=
uniformProbability (fun seed : K × P => seed.1 = k ∧ observe seed = z) /
uniformProbability (fun seed : K × P => observe seed = z)
/-- PDF pp.16--17: classical conditional Shannon entropy in bits. Averaging
fiber entropy over the original finite seed avoids requiring a finite message
alphabet or a Fintype on all possible transcript values. The entropy is of K,
not of the OTP seed P. The zero-mass convention is 0 log 0 = 0. -/
def conditionalKeyEntropy {K P Z : Type*} [Fintype K] [Fintype P]
(observe : K × P → Z) : ℝ :=
uniformAverage (fun seed : K × P =>
-∑ k : K, posteriorKey observe (observe seed) k *
Real.logb 2 (posteriorKey observe (observe seed) k))
/-- PDF pp.16--17, Theorem 8: the second term is zero at n = |T|, as given by
its zero-probability branch in the proof. It is not a logarithm of a sum. -/
def leakageBound (K : Type*) [Fintype K] (m n : ℕ) : ℝ :=
Real.logb 2 ((Fintype.card K : ℝ) / (Fintype.card (Tag m) : ℝ)) +
if n = Fintype.card (Tag m) then 0 else
(1 - (n : ℝ) / (Fintype.card (Tag m) : ℝ)) *
Real.logb 2 ((Fintype.card (Tag m) : ℝ) - (n : ℝ))
/-- PDF pp.3,10: the allowed subsequent application reveals k before Bob
verifies the pending pair. The attacker gets the revealed key and intercepted
pair, but not the OTP. This is a concrete known-key context for premature reuse. -/
def prematureReleaseView {K X : Type*} {m : ℕ} (h : K → X → Tag m)
(a : K → X × Tag m → X × Tag m) (k : K) (pad : Tag m) (x : X) :
K × RoundView X (Tag m) :=
let t := paddedTag h k pad x
let leakedKey := k
let pair := a leakedKey (x, t)
(leakedKey, ⟨x, t, pair, decide (pair.2 = paddedTag h k pad pair.1)⟩)
/-! Definition sanity checks only; no source theorem is proved here. -/
example (r : ℝ) : uniformAverage (fun _ : Unit => r) = r := by
simp [uniformAverage]
example : uniformProbability (fun _ : Unit => True) = 1 := by
simp [uniformProbability]
example (f : Unit → ℝ) : authConditionedSeedAverage (fun _ : Unit => False) f =
uniformAverage f := by
simp [authConditionedSeedAverage]
example : IsASU2 (fun (_ : Unit) (_ : Bool) => ()) 1 := by
intro x y hxy a b
have ha : () = a := Subsingleton.elim _ _
have hb : () = b := Subsingleton.elim _ _
simp [uniformProbability, ha, hb]
example : IsAXU2 (fun (_ : Unit) (_ : Bool) (_ : Fin 0) => false) 1 := by
intro x y hxy c
have hc : xorWord (fun _ : Fin 0 => false) (fun _ => false) = c :=
Subsingleton.elim _ _
simp [uniformProbability, hc]
example : paddedTag (fun (_ : Unit) (_ : Unit) (_ : Fin 1) => true)
() (fun _ => false) () = (fun _ => true) := rfl
example {K X T : Type*} : (silent : AuthOutput K X T).deliveries = [] := rfl
example {X T : Type*} : (authInitialState : AuthState X T).received = 0 := rfl
example {S I O : Type*} (step : S → I → S × O) (s : S) :
testValue step s (.stop true) = 1 := rfl
example {K X T : Type*} (n : ℕ) (recycle : Bool) (k : K)
(makeTag : ℕ → X → T) (valid : AuthState X T → ℕ → X × T → Bool)
(s : AuthState X T) (hs : s.closed = true) (i : AuthInput X T) :
authMachineStep n recycle k makeTag valid s i = (s, silent) := by
simp [authMachineStep, hs]
example {K X : Type*} {m : ℕ} (h : K → X → Tag m) (k : K)
(pads : Fin 1 → Tag m) :
(paddedStep false false h k pads authInitialState .timeout).2.deliveries = [] := rfl
example {K X T : Type*} [Fintype K] [Nonempty K] (h : K → X → T) :
standardIdealValue h authInitialState (.stop false) = 0 := rfl
example {K X T : Type*} (h : K → X → T) (k : K) (x : X) :
(standardStep false h k authInitialState (.submit (x, h k x))).2.deliveries = [some x] := by
simp [standardStep, authMachineStep, authInitialState, silent, verifyTag]
example {K X T : Type*} (h : K → X → T) (k : K) (x : X) (t : T) :
(standardStep true h k authInitialState (.submit (x, t))).2.deliveries = [none] := by
simp [standardStep, authMachineStep, authInitialState, silent]
example {K X : Type*} {m : ℕ} (h : K → X → Tag m) (k : K) (pad : Tag m) (x : X) :
(prematureReleaseView h (fun _ pair => pair) k pad x).2.accepted = true := by
simp [prematureReleaseView]
example {K X : Type*} {m : ℕ} (h : K → X → Tag m)
(a : AdaptiveAttack X (Tag m)) (k : K) (pads : Fin 0 → Tag m) :
attackTrace h a k pads = [] := by
simp [attackTrace, List.finRange]
example : conditionalKeyEntropy (fun _ : Unit × Unit => ()) = 0 := by
simp [conditionalKeyEntropy, posteriorKey, uniformProbability, uniformAverage]
example (K : Type*) [Fintype K] (m : ℕ) :
leakageBound K m (Fintype.card (Tag m)) =
Real.logb 2 ((Fintype.card K : ℝ) / (Fintype.card (Tag m) : ℝ)) := by
simp [leakageBound]
end QAlgorithms.Papers.Independent.Intake100.P41
Read-back
What the Lean code literally says, in plain math · gpt-6.1-sol
QAlgorithms.Papers.Independent.Intake100.P41.AdaptiveAttack
For arbitrary types and , an adaptive attack consists of two functions: a message function assigning an element of to every finite list of round records, and a substitution function assigning a pair in to every such list together with a current pair in . Each round record contains a message in , a tag in , a submitted pair in , and an acceptance Boolean. No consistency, computability, or other restrictions are imposed on these functions or on the histories they receive.
QAlgorithms.Papers.Independent.Intake100.P41.AuthInput
For any message type and tag type , an authentication input is one of three inductively specified forms: a send input carrying a message , a submit input carrying a pair , or a timeout input carrying no additional data. No finiteness or nonemptiness assumptions are imposed on either type.
QAlgorithms.Papers.Independent.Intake100.P41.AuthOutput
For arbitrary key, message, and tag types , an authentication output is a record with four fields: an optional message–tag pair in , a finite list of optional messages in , an optional key in for Alice, and an optional key in for Bob. Each optional value may be absent or present; no additional relationships between the fields or restrictions on the list are imposed.
QAlgorithms.Papers.Independent.Intake100.P41.AuthState
For arbitrary types of messages and of tags, an authentication state consists of a finite list of message–tag pairs in , a natural number , an optional message–tag pair , and a Boolean . These fields have no consistency conditions: the received count need not match the sent-list length, the optional pair need not occur in that list, and either value of the closed flag is allowed with any other fields.
QAlgorithms.Papers.Independent.Intake100.P41.CausalTest
For any types and , the type of causal tests is inductively generated by two constructors: a stopping test carrying a Boolean value, and a step carrying an input together with a function assigning a subsequent causal test to every output . These are well-founded trees; the definition imposes neither finiteness of or nor a common finite bound on tree depth, and the continuation must be specified for every possible output.
QAlgorithms.Papers.Independent.Intake100.P41.HonestInput
For any message type , an honest input is exactly one of two forms: a send input carrying a message , or a timeout input carrying no data. There is no honest-input constructor for submitting a message–tag pair.
QAlgorithms.Papers.Independent.Intake100.P41.IsASU2
For arbitrary types , with finite enumerations of and , a function , and any real number , this property means that for every pair of distinct and every , . No finiteness assumption is made on , and no sign assumption is made on . The condition is vacuous if has no distinct pair or if is empty; when is empty, the fraction on the left is defined to be zero.
QAlgorithms.Papers.Independent.Intake100.P41.IsAXU2
For arbitrary types , a finite enumeration of , any natural number , a function , and any real number , this property means that for every distinct and every Boolean word of length , , where denotes coordinatewise Boolean exclusive-or. No finiteness assumption is made on , and no sign assumption is made on . The condition is vacuous when has no distinct pair; an empty makes the fraction zero. The case is included, with necessarily the unique empty word.
QAlgorithms.Papers.Independent.Intake100.P41.PaddedConstructionSecure
For an arbitrary finite key type , an arbitrary message type , natural numbers , a function , a recycling Boolean, and a real number , this property requires two comparisons of deterministic interaction tests. A test is an inductively generated tree whose leaves carry Booleans and whose internal nodes choose an input and select their next subtree from the entire observed output; its value is or according to its eventual leaf. Outputs contain an optional exposed message–tag pair, a list of optional delivered messages, and optional Alice and Bob keys. Each run starts with an empty sent list, received count zero, no first submitted pair, and closed false, and uses a seed ranging over all keys and all -tuples of -bit pads. The uniform average of a function on a finite seed set means its sum divided by that set’s cardinality. The real machine tags a send at sent-list index with and validates a submission at received index by ; the ideal machine instead tags sends with and validates by exact equality with sent-list entry . Each machine permits at most sends and processed submissions, with those counters independent; every processed submission increments the received count, records the first submitted pair at count zero, and delivers its message or a rejection. If recycling is enabled, the -th processed submission releases Bob’s key even if rejected, and timeout closes the machine, fills the remaining deliveries with rejections, releases Alice’s key, and releases Bob’s key if fewer than submissions had been processed; otherwise timeout does nothing. Closed states and inputs exceeding their relevant count limit produce silent outputs. The first required comparison says that, for every test using only honest sends and timeouts, the real and ideal uniform averages are equal, where an honest send immediately submits any pair exposed by that send and reports only the submission output with its exposed tag cleared. The second says that, for every test allowed arbitrary sends, submissions, and timeouts, the absolute difference between its real and ideal uniform averages is at most . No positivity assumption on or nonemptiness assumption on is included; if is empty, both averages are zero because real division by zero is defined as zero, so the property reduces to . The cases and are also included.
QAlgorithms.Papers.Independent.Intake100.P41.RoundView
For arbitrary message and tag types , a round view consists of a message in , a tag in , a submitted message–tag pair in , and a Boolean accepted flag. There are no constraints relating these fields: the submitted message or tag may differ from the separate message or tag fields, and the accepted flag is unrestricted.
QAlgorithms.Papers.Independent.Intake100.P41.StandardConstructionSecure
For an arbitrary finite nonempty key type , arbitrary message and tag types , a function , and any real number , this property requires an equality for every honest interaction test and an absolute-difference bound for every unrestricted interaction test. Tests are inductively generated deterministic trees with Boolean leaves, inputs at internal nodes, and continuations selected by complete outputs; their values are the final Boolean interpreted as or . Every run starts with an empty sent list, received count zero, no first submitted pair, and closed false. Both real and ideal machines have capacity one and no recycling: a send appends and exposes only while the sent list is empty, and a submission is processed only while the received count is zero, after which the count becomes one and the pair is recorded. The real machine accepts a submitted exactly when ; the ideal machine accepts exactly when that pair equals sent-list entry zero. Processing produces one accepted message or rejection; excess sends or submissions and all timeouts do nothing; no keys are released. A closed state is unchanged and silent. First, for every test restricted to honest sends and timeouts, its real and ideal values averaged uniformly over must be equal, where an honest send immediately submits any exposed pair and returns only that submission’s output with its exposed tag cleared. Second, for every test allowed arbitrary sends, submissions, and timeouts, the absolute difference between its uniformly averaged real value and the following ideal recursive value must be at most : Boolean leaves evaluate to or ; at a send while open with an empty sent list, average the ideal-transition continuation over keys inconsistent with the recorded first submitted pair, using all keys if there is no such pair or if the inconsistent-key set is empty; at every other node, use the ideal transition with a fixed arbitrarily chosen key. All uniform or conditioned averages are sums divided by the relevant number of keys. No nonnegativity assumption on is imposed.
QAlgorithms.Papers.Independent.Intake100.P41.Tag
For every natural number , is the type of Boolean words indexed by , equivalently functions from that index set to . When , there is exactly one such word, the empty word.
QAlgorithms.Papers.Independent.Intake100.P41.attackTrace
For arbitrary types , natural numbers , a function , an adaptive attack , a key , and pads , the attack trace is the list built from the empty history by processing indices in that order. Given the current history , choose , form , and let , where is coordinatewise Boolean XOR. Append the record , where is true exactly when . Thus the resulting list has exactly records, including records following any rejection; when , it is empty. The definition permits , in which case there is only one tag and every recorded tag comparison succeeds.
QAlgorithms.Papers.Independent.Intake100.P41.authConditionedSeedAverage
For any type equipped with a finite enumeration, predicate on , and function , let . The conditioned seed average is defined to be when is nonempty, and when is empty. Thus an empty conditioning set selects the average over all of ; if itself is empty, the value is by the convention .
QAlgorithms.Papers.Independent.Intake100.P41.authInitialState
For arbitrary message and tag types , the initial authentication state has an empty sent list, received count , no first submitted pair, and closed flag false.
QAlgorithms.Papers.Independent.Intake100.P41.authMachineStep
For arbitrary types , a natural number , a Boolean recycling flag, a key , an arbitrary tag-making function , an arbitrary Boolean validation function of a state, a natural-number index, and a message–tag pair, an arbitrary state , and an input that is either “send ,” “submit ,” or “timeout,” this function returns an updated state and an output record. A silent output has no exposed message–tag pair, an empty delivery list, and no Alice or Bob key. If is closed, every input returns and the silent output. Otherwise, sending when appends to the sent list and exposes that pair, with all other state and output fields unchanged from and the silent output respectively; when the inequality fails, nothing changes and the output is silent. Submitting a pair when produces a single delivery: its message if validation at the old state and old received index returns true, or a rejection represented by no message otherwise; it increments the received count and records this submitted pair precisely when the old count was zero, preserving the previous first-submitted field otherwise. This submission releases to Bob precisely when recycling is true and the incremented count equals , independently of validation; it exposes no tag and releases no Alice key. If the received-count inequality fails, submission does nothing. A timeout with recycling true sets closed to true and received to , preserves the sent list and first submitted pair, outputs rejections, releases to Alice, and also releases to Bob exactly when the old received count was below ; subtraction here is natural-number subtraction, so the rejection list is empty if the old count exceeds . Without recycling, timeout does nothing. No relation between sending and submitting is required, and is included: sends and submissions then do nothing, while an open recycling timeout still releases Alice’s key.
QAlgorithms.Papers.Independent.Intake100.P41.conditionalKeyEntropy
For finite types , an arbitrary type , and an observation function , let
with division by zero defined as zero. The defined real number is
Here , with the total real logarithm taking value zero at zero, so zero-probability terms contribute zero. No nonemptiness assumption is made: if either finite type is empty, the outer sum and the resulting value are zero.
QAlgorithms.Papers.Independent.Intake100.P41.corrupts
For arbitrary types and a finite list of records containing a message, tag, submitted message–tag pair, and acceptance Boolean, the predicate holds exactly when some record in has acceptance Boolean true and submitted message different from its recorded message. It imposes no condition on how the acceptance Boolean was obtained and does not require the submitted tag to differ from the recorded tag. It is false for the empty list.
QAlgorithms.Papers.Independent.Intake100.P41.honestStep
For arbitrary types , any supplied transition function from an authentication state and an input—send, submit, or timeout—to a new state and an output record, any state , and an honest input, this function behaves as follows. A timeout is passed directly to the supplied transition. For a send , it first runs that transition on with send . If the resulting output exposes no message–tag pair, it returns this first result exactly. If the first output exposes a pair, it immediately submits that pair using the first resulting state, then returns the second resulting state and the second output with its exposed-tag field replaced by none. The first output’s deliveries and key fields are not combined with the second output; the second output’s deliveries and key fields are retained. No assumptions are imposed on the supplied transition or the starting state.
QAlgorithms.Papers.Independent.Intake100.P41.leakageBound
For any finite type and natural numbers , the defined real number is
The number is the cardinality of the set of -bit tags. There is no restriction requiring to be nonempty or , and is permitted. The subtraction inside the logarithm is real subtraction; when , its argument is negative and the total real logarithm equals the logarithm of its absolute value. At zero the real logarithm is defined as zero.
QAlgorithms.Papers.Independent.Intake100.P41.padAt
For arbitrary natural numbers , a family of pads indexed by , each pad being an -bit word, and any natural-number index , this function returns pad if , and the all-false -bit word otherwise. Thus, when , every index returns the all-false word; when , every returned pad is the unique empty word.
QAlgorithms.Papers.Independent.Intake100.P41.paddedStep
For arbitrary key and message types , natural numbers , Booleans and , a function , a key , and pads of bits each, this defines a state transition accepting sends, submitted message–tag pairs, and timeouts. Write for pad when , and the all-false word otherwise, and let mean coordinatewise Boolean exclusive-or. In ideal mode, sending message at sent-list index makes tag , and a submitted pair at received index is valid exactly when it equals the pair stored at position in the sent list; an absent list entry makes this test false. In real mode, the made tag is , and a submitted pair is valid exactly when , without consulting the sent list. In either mode, a closed state returns unchanged with no tag, no deliveries, and no keys; an open send appends and exposes its made pair only if the sent-list length is below ; and an open submission is processed only if the received count is below , increments that count regardless of validity, records the pair if the old count was zero, and outputs one accepted message or rejection. Such a submission releases Bob’s key exactly when recycling is true and the new count is , regardless of acceptance. An open recycling timeout closes the state, sets its received count to , produces rejections using the old count, releases Alice’s key, and releases Bob’s key if the old count was below ; a timeout without recycling does nothing. All unmentioned fields are preserved, and outputs have no other tags, deliveries, or keys. Both and are allowed.
QAlgorithms.Papers.Independent.Intake100.P41.paddedTag
For arbitrary types , any natural number , a function , a key , a Boolean pad of length , and a message , the padded tag is the Boolean word whose coordinate is , for every . No distributional or independence condition is imposed on the pad. For , the result is the unique empty word.
QAlgorithms.Papers.Independent.Intake100.P41.posteriorKey
For finite types , an arbitrary type , a function , an observation , and , the defined real number is
All divisions are total real divisions, so division by zero gives zero. Consequently, if is nonempty and is attained, this is the fraction of seeds producing whose key is ; if is unattained or the seed space is empty, the value is zero.
QAlgorithms.Papers.Independent.Intake100.P41.prematureReleaseView
For arbitrary types , a natural number , a function , a function , a key , a pad , and a message , form using coordinatewise Boolean XOR and let . The returned value is the pair consisting of itself and the round record , where is true exactly when . Thus the substitution function receives the key as an argument, and the returned view explicitly contains it. No restriction is imposed on ; is allowed and then the tag comparison always succeeds.
QAlgorithms.Papers.Independent.Intake100.P41.silent
For arbitrary types , the silent authentication output is the record with no message–tag pair, an empty list of deliveries, no Alice key, and no Bob key.
QAlgorithms.Papers.Independent.Intake100.P41.standardIdealValue
For an arbitrary finite nonempty key type , arbitrary message and tag types , a function , and any authentication state , this defines a real-valued evaluation of an inductively generated deterministic test whose inputs are sends, submitted message–tag pairs, and timeouts, and whose next subtree depends on the complete output record. At a Boolean leaf, its value is for true and for false. At a send , if the state is open and its sent list is empty, form the set of keys satisfying the following condition: every key qualifies if there is no recorded first submitted pair, and otherwise qualifies exactly when for that recorded pair . Evaluate the continuation after the ideal transition for each qualifying key and take their arithmetic mean; if this qualifying set is empty, take the mean over all keys instead. For every other input, including a send outside that open-and-empty condition, perform the ideal transition using a fixed arbitrarily chosen key and recursively evaluate the selected continuation. Here the ideal transition has capacity one and no recycling: closed states are unchanged and silent; an open send with an empty sent list appends and exposes ; an open submission with received count zero is accepted exactly when it equals sent-list entry zero, then increments the count, records the pair, and produces one delivery or rejection; further sends or submissions exceeding their respective limits and all timeouts do nothing. No keys are released, unmentioned fields are preserved, and a silent output contains no exposed pair and an empty delivery list. The starting state need not be reachable from the initial state, and the empty-conditioning-set fallback is part of the definition.
QAlgorithms.Papers.Independent.Intake100.P41.standardStep
For arbitrary types , a Boolean , a tag function , and a key , this defines a transition on authentication states with capacity one and recycling disabled. A closed state returns unchanged with a silent output, meaning no exposed pair, no deliveries, and no keys. In an open state with an empty sent list, sending appends and exposes ; sending with a nonempty sent list does nothing. In an open state whose received count is zero, submitting increments that count to one, stores the submitted pair as the first submitted pair, and outputs one accepted message or rejection. In ideal mode, acceptance means that sent-list entry zero exists and equals ; in real mode, acceptance means . A submission with received count at least one does nothing. Every timeout does nothing, no transition releases either key, and all unmentioned state fields remain unchanged. The supplied state is arbitrary: in particular, a submission may precede a send, and successful processing does not set the closed flag.
QAlgorithms.Papers.Independent.Intake100.P41.testValue
For arbitrary types , a deterministic transition function , and an initial state , the value of a causal test is defined recursively as follows: a stopping test with Boolean value true has value , and one with value false has value ; at a test step with input and continuation , compute and evaluate from state using the same transition function. Thus evaluation follows the selected continuation to its stopping Boolean and returns its value as a real number, without averaging over outputs.
QAlgorithms.Papers.Independent.Intake100.P41.uniformAverage
For any type equipped with a finite enumeration and any function , its uniform average is defined as . No nonemptiness assumption is imposed on ; if is empty, this expression is , which equals under the real-number division convention used here.
QAlgorithms.Papers.Independent.Intake100.P41.uniformProbability
For any type equipped with a finite enumeration and any predicate on , its uniform probability is defined as . If is empty, both cardinalities are zero and the defined value is , since real division by zero returns zero.
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.