Two-stage adversaries and the left-or-right experiment #
Many attack games run the adversary twice. It first receives the challenger's public input and
chooses a challenge request, then receives the challenge and answers. Between the two calls it
keeps a saved state. TwoStage I₁ O₁ I₂ O σ is such an adversary: choose maps the first input
to a request and a state of type σ, and guess maps the state and the challenge to the answer.
The state type is a parameter, so a saved state can be a typed record.
TwoStage.IsPPT states that a family of two-stage adversaries, one for each security parameter,
is uniform strict PPT: one finite machine for each stage, reading the unary security parameter
and the encoded stage input, including the full encoded saved state. Security definitions over
two-stage adversaries quantify over every state type and state encoding. The word-level
adversaries with state List Bool are the instance σ := List Bool, encσ := encBits, so a
typed definition quantifying over every σ implies the word-level one. The converse is not free:
it needs a word-level adversary that simulates the second stage on the encσ codewords.
lrExperiment is the left-or-right experiment. The adversary chooses two messages from the drawn
public input; the challenger checks the pair with an admissibility predicate, encrypts the message
selected by the bit and gives the challenge to the adversary, whose guess is the output. An
inadmissible pair outputs false on both sides. This is the challenge phase of single-challenge
IND-CPA ([BS23], Section 11.2, Attack Game 11.1, p. 436); key generation belongs to the
scheme's own experiment, which draws the public input and then runs lrExperiment.
Main definitions #
Cslib.Crypto.TwoStage: an adversary with a choice stage and a guessing stage.Cslib.Crypto.TwoStage.IsPPT: uniform strict PPT for a family of two-stage adversaries.Cslib.Crypto.MessagePair,Cslib.Crypto.MessagePair.select,Cslib.Crypto.MessagePair.equivProd: a pair of challenge messages, the message selected by a bit, and the equivalence withM × M.Cslib.Crypto.encMessagePair: the encoding of a message pair, laid out asencPair encM encM.Cslib.Crypto.lrExperiment: the left-or-right experiment on a drawn public input.
Main results #
Cslib.Crypto.encMessagePair_msg₀_polyTime,Cslib.Crypto.encMessagePair_msg₁_polyTime,Cslib.Crypto.encMessagePair_mk_polyTime: polynomial-time projections and construction of an encoded message pair.Cslib.Crypto.eval_lrExperiment: the output distribution of the left-or-right experiment.
References #
- D. Boneh, V. Shoup, A Graduate Course in Applied Cryptography, Section 11.2 (Attack Game 11.1, p. 436).
A two-stage adversary. choose receives the first input, of type I₁, and returns a request
of type O₁ together with a saved state of type σ; guess receives the saved state and the
second input, of type I₂, and returns its answer, of type O. The state is all that the
adversary retains between the stages.
Receive the first input and return a request and a saved state.
- guess : σ → I₂ → ProbComp O
Receive the saved state and the second input and return the answer.
A family of two-stage adversaries, one for each security parameter, is uniform strict PPT: one finite machine runs each stage at every parameter. The choice stage reads the unary security parameter and the encoded first input; the guessing stage reads the unary security parameter, the encoded saved state and the encoded second input. Each clock charges the complete encoded input, including the saved state.
- choose : Probability.IsPPTOn (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encUnary encI₁) (Turing.MultiTapeTM.encPair encO₁ encσ) fun (x : ℕ × I₁) => (A x.1).choose x.2
The choice stage is uniform strict PPT on the parameter and the first input.
- guess : Probability.IsPPTOn (Turing.MultiTapeTM.encPair Turing.MultiTapeTM.encUnary (Turing.MultiTapeTM.encPair encσ encI₂)) encO fun (x : ℕ × σ × I₂) => match x with | (n, state, input) => (A n).guess state input
The guessing stage is uniform strict PPT on the parameter, the state and the second input.
A pair of challenge messages.
- msg₀ : M
The message encrypted when the challenge bit is
false. - msg₁ : M
The message encrypted when the challenge bit is
true.
A message pair is the ordered pair (msg₀, msg₁).
The first message of a computed message pair is computed in polynomial time.
The second message of a computed message pair is computed in polynomial time.
A message pair of two computed messages is computed in polynomial time.
The left-or-right experiment ([BS23], Attack Game 11.1, challenge phase) on the
drawn public input x. The adversary chooses a message pair and a state from x. If
valid x msg₀ msg₁ holds, the challenger encrypts the message selected by b under x and
returns the adversary's guess on the state and the challenge; otherwise it returns false, on
both sides.
The output distribution of the left-or-right experiment: the adversary chooses a message pair
and a state; on an admissible pair the challenge encrypts the message selected by b and the
output is the adversary's guess, and on an inadmissible pair the output is false.