Lazily-Sampled Random Oracle with a Heap-Resident Query Log #
A random oracle whose query log lives in a single heap cell at a GLocation. The
log is an association list, so it grows by one entry per fresh query; its type
List (D × R) carries no Fintype instance and therefore cannot be the value type
of a CatCrypt.Core.Location.
Because the log is state rather than a threaded argument, the oracle has type
SPComp R — the type of any other stateful computation — so it can be composed
with, and handed to, an arbitrary SPComp adversary.
Main definitions #
logFind— lookup in a query loglogLoc— the heap cell holding the logquery— the lazily-sampled oracleprogram— reprogram the oracle at one point
Main results #
query_apply_cached— a repeated query is deterministic and leaves the log alonequery_apply_fresh— a fresh query samples uniformly and appends one entryquery_answer_uniform— the answer to a fresh query is uniform onR, whatever the log holdsquery_consistent— two successive queries on the same point agreequery_after_program— a programmed point answers with the programmed valuepreservesOutside_query— the oracle writes only its own cellmsgLog_no_fintype— the log type of a random oracle on arbitrary-length bit strings is not finite
Query logs #
Query log: an association list of query/response pairs.
Equations
- CatCrypt.Core.RandomOracle.Log D R = List (D × R)
Instances For
Lookup in a query log; the leftmost entry for x wins.
Equations
Instances For
The oracle #
Heap cell holding the random-oracle log.
Equations
- CatCrypt.Core.RandomOracle.logLoc D R id = { id := id, ty := CatCrypt.Core.RandomOracle.Log D R, countable := ⋯, inhabited := instInhabitedList }
Instances For
One oracle step, given the current log: return the cached answer, or sample a fresh one and append it.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The lazily-sampled random oracle: read the log from the heap, answer, write back.
Equations
- CatCrypt.Core.RandomOracle.query D R id x = (CatCrypt.Core.SPComp.gget (CatCrypt.Core.RandomOracle.logLoc D R id)).bind (CatCrypt.Core.RandomOracle.queryStep D R id x)
Instances For
A cached query is deterministic #
A fresh query samples uniformly #
The answer to a fresh query is uniform on R, independently of the log contents.
This is the marginal of query on its result component.
Every query is fresh on the empty heap, so the freshness hypothesis of
query_answer_uniform is satisfiable.
Two heaps on which x is fresh give the same answer distribution: the marginal
does not depend on the log.
The log makes the oracle consistent #
After a fresh query, the point is cached: the freshly written log answers x.
Querying the same point twice returns the same value. The second query reads the entry the first one wrote, so this holds on every heap.
Programming the oracle #
A programmed point answers with the programmed value.
Programming a point the oracle has not yet been asked about does not change the answers already fixed at other points.
Footprint #
Monotonicity of PreservesOutside in the footprint.
The oracle writes only its own cell.
pRHL #
The judgment is CatCrypt.Relational.rHoare over the same two Heaps as for any
other computation, and the core frame rule applies to the oracle unchanged.
The reprogramming step as a pRHL judgment: after programming x to r, the
oracle and the constant r are related on equal heaps.
The core frame rule applies to the oracle: an assertion about a finite-typed location at a different id survives the oracle's step.
The log type is outside the range of Location #
A random oracle on arbitrary-length bit strings is the shape FDH and Fiat–Shamir
need. Neither its log type nor its domain is finite, so neither can be the value
type of a CatCrypt.Core.Location.
For a finite query domain the total table D → Option R is itself finite, so a
bounded-domain oracle table is already a legal Location value type. The cases the
Fintype bound excludes are the log-shaped state and the unbounded query domain.
Equations
- CatCrypt.Core.RandomOracle.boundedTableLoc D R id = { id := id, ty := D → Option R, fintype := Pi.instFintype, inhabited := Pi.instInhabited }
Instances For
BitVec w is equivalent to Fin (2 ^ w). This toolchain's Mathlib ships no
Fintype (BitVec w) instance.
Equations
- CatCrypt.Core.RandomOracle.instFintypeBitVec w = Fintype.ofEquiv (Fin (2 ^ w)) { toFun := BitVec.ofFin, invFun := BitVec.toFin, left_inv := ⋯, right_inv := ⋯ }
Instances For
Log of a random oracle from arbitrary-length bit strings to 256-bit digests.
Equations
Instances For
The heap cell for that oracle's log.
Equations
Instances For
The oracle on arbitrary-length bit strings.
Equations
- CatCrypt.Core.RandomOracle.msgQuery id x = CatCrypt.Core.RandomOracle.query (List Bool) (BitVec 256) id x