Word-RAM Hash-Family Implementation Interface #
Cslib.DataStructure.HashFamily.WordRAM.Impl packages a Word-RAM hash-function data structure at
[base, base + space) with a finite seed type Seed, pure evaluation map
eval : Seed → Fin U → Fin m, optional deterministic table initialization initTableCode
(initTableSteps), randomized seed resampling resampleCode (resampleSteps, inducing
PMF.uniformOfFintype Seed), and deterministic query evaluation evalCode (evalSteps, computing
(eval θ u).val without modifying memory).
Every H : Impl canonically induces an ObliviousSequenceImpl certificate over
H.subroutineCode:
H.toKWiseObliviousSequenceImplrealizingDataStructure.HashFamily.kWiseSpec k U mwhenIsKWiseIndependentHash k H.eval;H.toWhpKWiseObliviousSequenceImplrealizingDataStructure.HashFamily.whpKWiseSpec k U m δwhenHhas a two-level(1 - δ)-good top-seed decomposition.
Main definitions #
Cslib.DataStructure.HashFamily.WordRAM.coreReg,opReg,curReg,zeroReg,oneReg,frontierReg: register embeddings for the 5-register subroutine wrapper aroundr_corecore hash registers.Cslib.DataStructure.HashFamily.WordRAM.Impl: Word-RAM hash-family implementation interface.Cslib.DataStructure.HashFamily.WordRAM.Impl.subroutineCode,encode,decode,charge,initInv: canonicalSubroutineCodewrapper and operation encoding/decoding forHashFamily.Op U.Cslib.DataStructure.HashFamily.WordRAM.Impl.toObliviousSequenceImpl,toKWiseObliviousSequenceImpl,toWhpKWiseObliviousSequenceImpl: canonicalObliviousSequenceImplcertificates induced byH : Impl.
Main results #
Cslib.DataStructure.HashFamily.WordRAM.Impl.resample_exec_of_execRand: builds theresample_execfield ofImplfrom anExecRandcomputation and a memory seed extractor.Cslib.DataStructure.HashFamily.WordRAM.Impl.arguments_fit: encodedHashFamily.Op Uarguments fit inw-bit words on all input registers ofH.subroutineCode.Cslib.DataStructure.HashFamily.WordRAM.Impl.evalOps_execSteps: executing anyops : List (HashFamily.Op U)onH.subroutineCodeinduces the exact pure transcript distributionHashFamily.evalOps (PMF.uniformOfFintype H.Seed) H.eval ops.
References #
Scratch pointer register r_core + 1 for zeroFillCode and allocSpan.
Constant-0 scratch register r_core + 2 for zeroFillCode and operation dispatch.
Constant-1 scratch register r_core + 3 for zeroFillCode.
Bump-pointer frontier register r_core + 4 for allocSpan and zeroFillCode.
Reusable Word-RAM implementation certificate for a resamplable hash-family data structure over
universe Fin U and codomain Fin m at word width w, base address base, and runtime
initialization parameters params : Fin k_init → ℕ.
Separates deterministic table precomputation (initTableCode, establishing tableRep), randomized
seed resampling (resampleCode, preserving tableRep and sampling Seed uniformly into
seedRep), and deterministic evaluation (evalCode, computing (eval θ u).val in outReg without
modifying memory).
- Seed : Type
Finite type of hash seeds.
Finiteness instance on
Seed.Nonemptiness instance on
Seed.- space : ℕ
Contiguous memory footprint length
[base, base + space). Deterministic precomputed table invariant on memory (
fun _ => Truewhen none).Seed representation invariant linking
θ : Seedto memory.- baseReg : Fin r_core
Persistent base-address register in
Fin r_core. - keyReg : Fin r_core
- outReg : Fin r_core
Registers carrying runtime parameters
paramsintoinitTableCode.The input key register is distinct from
baseRegso key preparation preservesbase.Runtime parameter registers are distinct from
baseRegsoallocSpanpreservesparams.The end of the allocated footprint
base + spacefits in aw-bit word.- fits_tag : WordRAM.Fits w 1
The evaluation dispatch tag
1fits in aw-bit word. - fits_key (u : Fin U) : WordRAM.Fits w ↑u
Every universe key
u : Fin Ufits in aw-bit word. Single-instruction register addition
d ← a + boverBonData (r_core + 5).- addReg_eval {x : WordRAM.Data (r_core + 5)} (d a b : Fin (r_core + 5)) : WordRAM.Fits w (x.regs a + x.regs b) → WordRAM.Op.eval w (self.addReg d a b) x = some (x.set d (x.regs a + x.regs b))
addReg d a bsets registerdtox.regs a + x.regs bwhen the sum fits inwbits. - initTableCode : WordRAM.Code B r_core
Deterministic table initialization program on
Data r_core. - initTableSteps : ℕ
Worst-case instruction bound for
initTableCode. - resampleCode : WordRAM.Code B r_core
Randomized seed-resampling program on
Data r_core. - resampleSteps : ℕ
Expected instruction bound for
resampleCode. - evalCode : WordRAM.Code B r_core
Deterministic hash-evaluation program on
Data r_core. - evalSteps : ℕ
Worst-case instruction bound for
evalCode. - initTable_exec {x : WordRAM.Data r_core} : WordRAM.Data.Bounded w x → x.regs self.baseReg = base → (∀ (j : Fin k_init), x.regs (self.initParams j) = params j) → (∀ a ∈ { base := base, length := self.space }.footprint, x.mem a = 0) → ∃ (x₁ : WordRAM.Data r_core), WordRAM.ExecWithin w self.initTableCode x x₁ self.initTableSteps ∧ x₁.regs self.baseReg = base ∧ self.tableRep x₁.mem ∧ WordRAM.Modifies { base := base, length := self.space }.footprint x.mem x₁.mem
Correctness and complexity of
initTableCode: establishestableRepand preservesbaseRegwhile modifying only[base, base + space). - resample_exec {x : WordRAM.Data r_core} : WordRAM.Data.Bounded w x → x.regs self.baseReg = base → self.tableRep x.mem → ∃ (ν : PMF (WordRAM.Randomized.LatentState self.Seed r_core)), WordRAM.ExecCodeDist w self.resampleCode x (PMF.map WordRAM.Randomized.LatentState.data ν) ↑self.resampleSteps ∧ PMF.map WordRAM.Randomized.LatentState.latent ν = Probability.PMF.uniformOfFintype self.Seed ∧ ∀ p ∈ ν.support, p.data.regs self.baseReg = base ∧ self.tableRep p.data.mem ∧ self.seedRep p.latent p.data.mem ∧ WordRAM.Modifies { base := base, length := self.space }.footprint x.mem p.data.mem
Correctness and complexity of
resampleCode: from any word-bounded state withx.regs baseReg = baseandtableRep x.mem, produces a coupled distributionν : PMF (LatentState Seed r_core)whose seed marginal isPMF.uniformOfFintype Seed, preservingbaseRegandtableRep, establishingseedRep, and modifying only[base, base + space). - eval_exec (θ : self.Seed) (u : Fin U) {x : WordRAM.Data r_core} : WordRAM.Data.Bounded w x → x.regs self.baseReg = base → x.regs self.keyReg = ↑u → self.tableRep x.mem → self.seedRep θ x.mem → ∃ (y : WordRAM.Data r_core), WordRAM.ExecWithin w self.evalCode x y self.evalSteps ∧ y.mem = x.mem ∧ y.regs self.baseReg = base ∧ y.regs self.outReg = ↑(self.eval θ u)
Build the resample_exec obligation of Impl from an ExecRand computation
m : ProbComp (Data r_core × ℕ) and a memory seed-extraction function
extractSeed : (ℕ → ℕ) → Seed.
Lift an Impl certificate along a basis simulation φ : B.Simulates B'.
Lift an Impl certificate from Basis.exact to Basis.standard.
Canonical SubroutineCode on Data (r_core + 5) wrapping H : Impl:
allocSpancopiesfrontierRegintocoreReg H.baseRegand advancesfrontierRegbyH.space;initSetuprunsH.initTableCodefollowed byH.resampleCodeon the core registers;codesetszeroReg r_core ← 0and branches onopReg r_core == 0betweenH.resampleCode(.resample) andH.evalCode(.eval u).
Standalone register encoding for HashFamily.Op U on H.subroutineCode:
Every encoded HashFamily.Op U argument fits in a w-bit word on all input registers of
H.subroutineCode.
Output decoder for HashFamily.Op U on H.subroutineCode: returns some PUnit.unit on
.resample and reads regs (coreReg H.outReg) < m on .eval u.
Per-operation instruction charge on H.subroutineCode: H.resampleSteps + 2 for .resample
and H.evalSteps + 3 for .eval u.
Distributional invariant on the initial state distribution produced by
H.subroutineCode.initSetup.
Executing any ops : List (HashFamily.Op U) on H.subroutineCode from an initial distribution
ν₀ satisfying H.initInv ν₀ produces a final state distribution ν_final whose transcript
marginal equals HashFamily.evalOps (PMF.uniformOfFintype H.Seed) H.eval ops.
Package H : Impl into an ObliviousSequenceImpl certificate for any oblivious-sequence
specification ⟨HashFamily.Op U, HashFamily.Result m, ValidOpSeq, Contract⟩ satisfied by
HashFamily.evalOps (PMF.uniformOfFintype H.Seed) H.eval.
Canonical ObliviousSequenceImpl certificate for HashFamily.kWiseSpec k U m:
every H : Impl whose evaluation map satisfies IsKWiseIndependentHash k H.eval
canonically realizes DataStructure.HashFamily.kWiseSpec k U m.
Canonical ObliviousSequenceImpl certificate for HashFamily.whpKWiseSpec k U m δ:
every H : Impl with a two-level seed decomposition e : H.Seed ≃ (TopSeed × BotSeed) and
a good top-seed set GoodTop : Finset TopSeed on which fun β => H.eval (e.symm (α, β)) is
k-wise independent canonically realizes DataStructure.HashFamily.whpKWiseSpec k U m δ with
δ = (#(Finset.univ \ GoodTop) : ℝ≥0∞) / (Fintype.card TopSeed : ℝ≥0∞).