Observation Oracle for Side-Channel Leakage Modeling #
This file defines an observation oracle that emits side-channel events during computation, enabling formal reasoning about leakage properties such as constant-time execution and distributional trace independence.
The API has two layers:
Layer 1 (generic, HasQuery-based): observation as a monad capability. Any monad m with
HasQuery (ObsSpec Ev) m can emit observation events. Two canonical HasQuery instances are
provided: obsDiscard (silently drops events) and obsAccumulate (accumulates events in a
WriterT ω m layer).
Layer 2 (simulateQ-based): for reinterpreting concrete OracleComp (spec + ObsSpec Ev) α
values. The definitions eraseObs and runObs are parameterized by a base oracle implementation
base : QueryImpl spec m, so they work for any target monad, not just OracleComp spec.
Main Definitions #
ObsSpec Ev: oracle spec where each event typeEvmaps to aPUnitresponse.observe: emit an observation event, generic over any[HasQuery (ObsSpec Ev) m].HasQuery.obsDiscard:HasQuery (ObsSpec Ev) minstance that discards events.HasQuery.obsAccumulate:HasQuery (ObsSpec Ev) (WriterT ω m)instance that accumulates.eraseObs: strip observation queries viasimulateQ, parameterized by base implementation.runObs: execute observed computation with trace accumulation, parameterized by base.
Main Results #
fst_map_runObs: erasure theorem — projecting away the trace recoverseraseObs.probFailure_runObs: observations do not change failure probability ([HasEvalSPMF m]).NeverFail_runObs_iff:NeverFailis preserved by observation ([HasEvalSPMF m]).
Observation Spec #
Oracle spec for observation events: each event maps to a PUnit response.
Observation queries carry no computational payload and exist purely for
side-channel instrumentation.
Instances For
Layer 1: Generic HasQuery-Based Observation #
Layer 2: SimulateQ-Based Erasure and Trace Collection #
Oracle implementation that handles spec + ObsSpec Ev by forwarding base queries to
base and discarding observation events. Parameterized by the base implementation so it
works for any target monad, not just OracleComp spec.
Instances For
Strip observation queries from a computation, retaining only the base oracle queries.
All observe calls become no-ops; the functional behavior of the computation is preserved.
Instances For
Running Observed Computations #
Execute an observed computation, producing the result paired with the accumulated
observation trace. Parameterized by a base oracle implementation base : QueryImpl spec m,
so this works for any target monad.
Instances For
Erasure theorem: projecting away the observation trace recovers the erased computation.
Failure preservation: observations do not change the probability of failure.
NeverFail is preserved by observation.
EvalDist Bridge for runObs #
These lemmas connect the result-marginal distribution of runObs to the distribution
of eraseObs, enabling direct probability-level reasoning about traces without needing
to manually simplify the traced computation into its concrete form.
runObs on a single base-spec query lifted into spec + ObsSpec Ev: the trace is 1.
runObs on a lifted base-spec computation: the trace is 1 (monoid identity).
runObs on observe e: the result is PUnit.unit with trace encode e.