Lazy-vs-Fresh Random Function Hybrid and Shared Block-Mode CPA Utilities #
Shared random-function hybrid and left-or-right block-mode CPA experiment machinery for symmetric block-cipher modes of operation (such as OFB, CTR and CBC):
- replaces a lazily sampled random function (
PRF.idealExperiment) by fresh independent uniform sampling (freshStep) up to the repetition bad event that an oracle query hits a previously sampled input; - provides the mode-independent left-or-right block-mode query/cost/ideal-experiment interface
(
BlockModeQuery,BlockModeSpec,BlockModeAdversary,blockModeSelect,blockModeBlocks,blockModeCost,blockModeOracle,blockModeIdealOracle,blockModeCpaExperiment,blockModeIdealExperiment), generic PRF distinguisher builder (blockModeQueryProgram,blockModeReduction, aProbOracleComp.simulatesubstitution), real-experiment / query-bound / ideal-experiment lifting lemmas (blockModeCpaExperiment_eq_realExperiment,isQueryBounded_blockModeReduction,freshGame_eq_blockModeIdealExperiment), and advantage triangle helpers; - for an arbitrary per-query program run by
ProbOracleComp.simulate, identifies the real experiment when each program computes the encryption oracle (blockModeCpaExperiment_eq_realExperiment_simulate), and reduces the random-function step to three per-query facts under fresh sampling: each answer has the law ofblockModeIdealOracle, and a query ofkblocks against a table oftentries adds at mostkentries and raises the flag with probability at most(k t + k.choose 2) / 2 ^ n(freshGame_simulate_eq_blockModeIdealExperiment,advantage_idealExperiment_simulate_le).
Main definitions #
Cslib.Crypto.FlagState,Cslib.Crypto.FlagState.repeated: association list of queriedBitString npairs paired with a Boolean repetition flag and its named accessor.Cslib.Crypto.lazyStep: lazy random-function handler that returns cached outputs on repeats and latches the repetition flag.Cslib.Crypto.freshStep: fresh uniform random-function handler that always samples uniformly and latches the repetition flag on repeats.Cslib.Crypto.BlockModeQuery,Cslib.Crypto.BlockModeSpec,Cslib.Crypto.BlockModeAdversary: left-or-right block-mode queries, oracle spec, and adaptive adversaries.Cslib.Crypto.blockModeSelect,Cslib.Crypto.blockModeBlocks,Cslib.Crypto.blockModeCost: query selection, block count, and query-block cost.Cslib.Crypto.blockModeOracle,Cslib.Crypto.blockModeIdealOracle,Cslib.Crypto.blockModeCpaExperiment,Cslib.Crypto.blockModeIdealExperiment: generic real and ideal random-IV block-mode left-or-right experiments.Cslib.Crypto.blockModeQueryProgram,Cslib.Crypto.blockModeReduction: generic PRF distinguisher from a left-or-right block-mode adversary and keystream oracle program.
Main results #
Cslib.Crypto.idealExperiment_eq_runWith_lazyStep:PRF.idealExperimentequals runninglazyStepfrom([], false).Cslib.Crypto.advantage_lazy_fresh_le: the advantage betweenlazyStepandfreshStepis at most the bad-flag probability underfreshStep.Cslib.Crypto.advantage_idealExperiment_freshStep_le: the advantage betweenPRF.idealExperimentandfreshStepis at most the bad-flag probability underfreshStep.Cslib.Crypto.length_blockModeSelect,Cslib.Crypto.blockModeBlocks_le,Cslib.Crypto.blockModeCpaExperiment_eq_realExperiment,Cslib.Crypto.isQueryBounded_blockModeReduction,Cslib.Crypto.freshGame_eq_blockModeIdealExperiment: shared left-or-right block-mode CPA lemmas.Cslib.Crypto.eval_blockModeIdealOracle: the ideal oracle is a uniform initialization vector andblockModeBlocks ℓ quniform blocks.Cslib.Crypto.blockModeCpaExperiment_eq_realExperiment_simulate: a per-query program that computes the encryption oracle gives the real PRF experiment.Cslib.Crypto.freshGame_simulate_eq_blockModeIdealExperiment: a per-query program whose fresh-sampling answers have the ideal law gives exactlyblockModeIdealExperimentunder fresh sampling.Cslib.Crypto.advantage_idealExperiment_simulate_le: if in addition a query ofkblocks adds at mostktable entries and, from a table oftentries, raises the flag with probability at most(k t + k.choose 2) / 2 ^ n, the program run against a uniform random function is withinK.choose 2 / 2 ^ nofblockModeIdealExperimentwhen the queries ask at mostKblocks in total.Cslib.Crypto.advantage_le_two,Cslib.Crypto.advantage_le_four: two-step and four-step triangle-inequality bounds forGame.advantage.
References #
- J. Katz, Y. Lindell, Introduction to Modern Cryptography, 3rd ed., Section 3.6.3 (Definition 3.22, Theorem 3.33).
- D. Boneh, V. Shoup, A Graduate Course in Applied Cryptography, Chapter 4.
A lazily sampled random-function table and a flag recording a repeated input.
PRF.idealExperiment against a uniform random function on BitString n equals the output of
ProbOracleComp.runWith lazyStep program ([], false).
The advantage between lazyStep and freshStep is bounded by the probability of raising the
repetition flag under freshStep.
The advantage between PRF.idealExperiment and fresh independent sampling freshStep is
bounded by the probability of raising the repetition flag under freshStep.
Shared Left-or-Right Block-Mode CPA Experiment #
A left-or-right query: two candidate plaintexts, each a list of n-bit blocks.
The answer to a left-or-right block-mode query: an initialization vector and ciphertext blocks.
An adaptive adversary in a left-or-right block-mode experiment, with private coins.
The plaintext encrypted for query q under challenge bit b: the right message if b = true
and the left one otherwise. Queries whose messages differ in length or exceed ℓ blocks encrypt
the empty message.
The number of blocks encrypted for query q: the common length of a valid query, or 0.
The encrypted plaintext has blockModeBlocks ℓ q blocks, regardless of the challenge bit.
Every query encrypts at most ℓ blocks.
The cost of a call in a left-or-right block-mode experiment: private draws are free and each encryption query costs its block length.
Generic random-IV left-or-right encryption oracle for block encryption operator enc and
challenge bit b.
The ideal left-or-right oracle: a uniform initialization vector and blockModeBlocks ℓ q
independent uniform ciphertext blocks, independent of the challenge bit.
Generic random-IV left-or-right experiment for keyed block encryption enc and challenge bit
b: sample one uniform key and answer every query with blockModeOracle (enc key) ℓ b
([KL20], Definition 3.22).
The ideal left-or-right experiment: the adversary receives fresh uniform ciphertext blocks.
One block-mode encryption computed from a keystream oracle program keystream iv k.
Generic PRF distinguisher built from a left-or-right block-mode adversary and keystream
program: the adversary with each encryption query replaced by blockModeQueryProgram.
The real experiment of a block-mode query program. If program q, run with F key as its
oracle, is the encryption oracle blockModeOracle (enc key) ℓ b q, then
blockModeCpaExperiment enc is PRF.realExperiment F for the adversary run with program.
When keystream iv ms.length evaluates with F key to the mask XORed by enc key iv ms,
blockModeCpaExperiment enc is PRF.realExperiment F (blockModeReduction keystream ℓ b adversary).
If keystream iv k makes at most k oracle calls for every k ≤ ℓ, and adversary asks
at most K blocks in total, then blockModeReduction keystream ℓ b adversary makes at most K
oracle calls.
The law of the ideal oracle: a uniform initialization vector and blockModeBlocks ℓ q
independent uniform blocks.
Fresh sampling of a block-mode query program. If every answer of program, under fresh
sampling and with the table forgotten, has the law of the ideal oracle, then the adversary run
with program under fresh sampling is blockModeIdealExperiment.
Under fresh sampling, whenever the keystream program outputs uniform blocks on every query,
blockModeReduction has the exact same output distribution as blockModeIdealExperiment.
A block-mode query program against a uniform random function. Suppose that under fresh
sampling every answer of program has the law of the ideal oracle, adds at most
k = blockModeBlocks ℓ q entries to the table, and from a table of t entries raises the flag
with probability at most (k t + k.choose 2) / 2 ^ n. Then against a uniform random function the
adversary run with program, if its queries ask at most K blocks in total, is within
K.choose 2 / 2 ^ n of blockModeIdealExperiment.