The up-to-bad abstract call rule (EasyCrypt's call (: bad, invP, invQ)) #
EasyCrypt's abstract call rule has an up-to-bad form (equivF_abs_upto, src/phl/ecPhlFun.ml):
the two oracle instantiations need agree only until a bad event on the right, after which the
runs are unrelated except for an invariant invQ. prhlProc_abstract_call_upto (procedure with
holes) and prhlProc_abstract_call_upto_module (module) are that rule.
The coupling (prhl2_body_upto) is built by induction over the adversary's code, with the
invariant uptoInv: before the bad event, the runs are synchronized as in the plain abstract call
rule (syncInv: ={glob}, invP, equal locals); after it, the two runs of what remains couple
independently (ProgramDenotation.prhl2.product), each side keeping a unary invariant
(satisfies_inv_of_confined). An independent coupling needs both remainders to be lossless:
the induction carries "this statement is lossless here" (ProgramDenotation.LosslessAt), which
the adversary's losslessness gives at the start and LosslessAt.of_bind passes on to almost every
intermediate state. A loop switches to the independent coupling at the start of an iteration
(ProgramDenotation.prhl2.while_upto, Logic/PRHL2Upto.lean), since after the bad event the
two guards need not agree.
The mass of a sub-probability is the sum of its atoms.
The mass of a bind: the continuation's masses, weighted by the atoms.
A lossless bind: its first part is lossless, and its continuation is lossless at every atom of the first part.
c runs without loss from σ.
Equations
- c.LosslessAt σ = (↑(c σ) Set.univ = 1)
Instances For
A program lossless at σ followed by k: lossless at σ, and k is lossless at every
outcome.
Running a lossless sub-probability first does not change the expectation of what follows.
The product coupling: two runs, lossless at the related states, couple independently; the postcondition must hold for every pair of outcomes.
One side at a time: invariants of the L-content #
The diagonal invariant: equal states, and Inv of the L-content.
Equations
- GaudisCrypt.diagInv L Inv g₁ g₂ = (g₁ = g₂ ∧ Inv (L.get g₁))
Instances For
A run confined to a region outside L keeps the L-content.
The adversary's own steps keep the diagonal invariant.
Unary invariance: a statement confined to what A may touch, with oracles that keep
Inv of the L-content, keeps it.
A coupling whose marginals satisfy U₁, U₂ satisfies them on its support.
A loop lossless at σ: at the guard's outcome, the rest (body; loop or nothing) is
lossless.
The up-to-bad induction #
Before the bad event: ={glob} on F, I on the L-contents, and not bad on the right
(EasyCrypt's !bad{2} /\ ={glob A} /\ invP).
Equations
- GaudisCrypt.syncInv L F I bad = GaudisCrypt.globInvF L F fun (ω₁ ω₂ : Ω) => I ω₁ ω₂ ∧ ¬bad ω₂
Instances For
After the bad event: bad on the right, and Q on the L-contents (EasyCrypt's
bad{2} /\ invQ).
Instances For
The invariant of the up-to-bad induction, on procedure states.
Equations
- GaudisCrypt.uptoInv L F I bad Q ps₁ ps₂ = (GaudisCrypt.badInv L bad Q ps₁.globals ps₂.globals ∨ GaudisCrypt.Lib.RO.Instantiate.liftRel (GaudisCrypt.syncInv L F I bad) ps₁ ps₂)
Instances For
After the bad event: the two runs of any statement of A, lossless at the related
states, couple independently; the left keeps Q against the right's state, the right keeps
bad and Q.
Before a statement, the bad event happened (prhl2_badInv_product) or not: it suffices to
treat the synchronized case.
The up-to-bad induction (the body of EasyCrypt's call (: bad, invP, invQ) for an
abstract procedure): every statement of A, lossless at the related states, keeps uptoInv.
Before the bad event the two runs are synchronized (={glob}, invP, equal locals) and the
oracle calls are coupled by horacle; after it, they couple independently
(prhl2_badInv_product); a loop switches to that at the start of an iteration
(prhl2.while_upto).
A Hoare triple about a procedure, as the support of its runs.
A lossless procedure is lossless from every state.
The up-to-bad abstract call rule (EasyCrypt's call (: bad, invP, invQ) on an abstract
procedure, equivF_abs_upto in src/phl/ecPhlFun.ml), for an adversary given as a procedure
with holes:
A lossless with the two instantiations of its oracles (EC: `islossless A`)
equiv[ o₁ ~ o₂ : !bad{2} ∧ ={arg} ∧ ={glob} ∧ invP
==> if bad{2} then invQ else ={res} ∧ ={glob} ∧ invP ] (per oracle)
∀ &2, bad{2} → hoare[ o₁ : invQ ==> invQ ] (per oracle)
∀ &1, hoare[ o₂ : bad ∧ invQ ==> bad ∧ invQ ] (per oracle)
──────────────────────────────────────────────────────────────────────────────────────────
equiv[ A(o₁) ~ A(o₂) : if bad{2} then invQ else ={arg} ∧ ={glob} ∧ invP
==> if bad{2} then invQ else ={res} ∧ ={glob} ∧ invP ]
bad, invP, invQ read the oracle region L (EasyCrypt rejects invariants on glob A);
={glob} is agreement on a region F containing A's footprint, outside L. EasyCrypt asks
the oracles to be lossless after the bad event (its phoare … = 1); here the adversary's
losslessness is asked with the two instantiations directly.
Synchronized means equal #
With ={glob} everything outside L (F = L.compl.footprint) and invP equality on L,
EasyCrypt's ={glob A} /\ invP before the bad event is equality of the global states, and the
per-oracle premise can be stated at equal states (prhlProc_upto_of_eq).
syncInv at F = L.compl.footprint and invP equality: equal states, not bad.
The oracle premise of prhlProc_abstract_call_upto(_module) at F = L.compl.footprint,
invP equality and invQ trivial, from equal arguments and states: after the calls, the bad
event, or equal results and states.
The up-to-bad abstract call rule for a module (EasyCrypt's declare module D <: T {-O},
then call (: bad, invP, invQ)): prhlProc_abstract_call_upto through D's representation.
D's losslessness with the two oracles is EasyCrypt's islossless premise (from D_ll).