Valid Packages #
This file defines valid packages - raw packages with proofs that they correctly implement their interface and only access declared locations.
Main definitions #
ValidCode- A computation that only accesses locations in L and imports from IValidPackage- A package that correctly implements interface E using imports from Ifseparate- Two packages have disjoint locations
References #
Specification of location access in code. A full implementation would track this syntactically; this uses a semantic characterization.
Instances For
Code validity: only accesses locations in L and imports from I. This is a predicate on computations asserting they respect the declared locations and import interface.
Note: A full implementation would require tracking access syntactically or using a free monad representation. This uses a Prop-level assertion.
The reads_in_L condition says the return-value distribution is unchanged
when an out-of-scope location is overwritten — the code doesn't read it.
- reads_in_L (l : Core.Location) (v : l.ty) (h : Core.Heap) : l ∉ L → ((c h).bind fun (x : α × Core.Heap) => match x with | (a, snd) => Prob.SDistr.pure a) = (c (h.set l v)).bind fun (x : α × Core.Heap) => match x with | (a, snd) => Prob.SDistr.pure a
The code's return-value distribution does not depend on locations outside L
- writes_in_L (l : Core.Location) (h : Core.Heap) : l ∉ L → ((c h).bind fun (x : α × Core.Heap) => match x with | (a, h₁) => Prob.SDistr.pure (a, h₁.get l)) = (c h).bind fun (x : α × Core.Heap) => match x with | (a, snd) => Prob.SDistr.pure (a, h.get l)
The code only writes to locations in L
Instances
A valid package correctly implements an export interface using an import interface.
- L: the locations the package may access
- I: the interface the package may import
- E: the interface the package exports
The package implements all operations in E
The package only implements operations in E
- valid_impl (e : PackageEntry) : e ∈ P.entries → ∀ (x : e.fun_.src), ValidCode L I e.fun_.tgt (e.fun_.impl x)
All implementations are valid code
Instances For
Two packages have separate (disjoint) locations
Equations
- CatCrypt.Package.fseparate L₁ L₂ = L₁.Separate L₂
Instances For
Valid code for a smaller location set is valid for a larger one. This is mathematically sound: if code only accesses L₁, and L₁ ⊆ L₂, then the code trivially satisfies validity for L₂.
Empty package is valid for empty interface
Parallel composition of valid packages
Location tracking: get the locations from a ValidPackage
Equations
- CatCrypt.Package.ValidPackage.locs L _I _E _P x✝ = L
Instances For
The game import interface (empty for basic games)
Instances For
The adversary export interface (empty for basic adversaries)