Oblivious-Sequence Word-RAM Implementation Certificates #
This file connects state-free oblivious-sequence specifications
(Cslib.DataStructure.ObliviousSequenceSpec) to concrete randomized Word-RAM subroutines:
Cslib.DataStructure.WordRAM.Randomized.ObliviousSequenceImpl: A reusable Word-RAM subroutine certificate realizing anS : Cslib.DataStructure.ObliviousSequenceSpecat word widthw, base addressbase, and runtime initialization parametersparams. It provides:- fresh zeroed-memory initialization (
initFresh_exec) and dirty-memory clearing initialization (initClear_exec); - multi-step distributional execution
ExecStepsacross any admissible oblivious sequenceops : List S.Op; - end-to-end expected-time and distributional correctness theorems
seq_expectedandseq_expected_clearcertifying bothS.Contract ops (ν_final.map SeqOutcome.transcript)and the total expected instruction bound; - basis simulation transport
mapSimulatesand exact-to-standard liftingtoStandard.
- fresh zeroed-memory initialization (
Canonical embedding
Cslib.DataStructure.WordRAM.Randomized.StateTransitionImpl.toObliviousSequenceImpl: Every relationalCslib.DataStructure.WordRAM.Randomized.StateTransitionImpl P D w base params s₀whose per-operation amortized charge is bounded by a state-independentopCharge : D.Op → ℕon admissible inputs canonically induces anObliviousSequenceImpl P (D.toObliviousSequenceSpec s₀) w base params.
ObliviousSequenceImpl bounds the instruction cost of initialization and of the subroutine
operation bodies across an oblivious sequence ops, excluding external caller argument delivery and
dispatch, with the word width w treated as an external admissible parameter.
Main definitions #
Cslib.DataStructure.WordRAM.Randomized.LatentState,Cslib.DataStructure.WordRAM.Randomized.StepOutcome,Cslib.DataStructure.WordRAM.Randomized.SeqOutcome: named state and transcript records for multi-step distributional execution.Cslib.DataStructure.WordRAM.Randomized.ExecSteps: multi-operation distributional execution relation across an oblivious sequenceops : List S.Op.Cslib.DataStructure.WordRAM.Randomized.ObliviousSequenceImpl: Word-RAM implementation certificate for anObliviousSequenceSpec.Cslib.DataStructure.WordRAM.Randomized.StateTransitionImpl.toObliviousSequenceImpl: canonical embedding of a relationalStateTransitionImplintoObliviousSequenceImpl.
Main results #
Cslib.DataStructure.WordRAM.Randomized.ExecSteps.bounded,Cslib.DataStructure.WordRAM.Randomized.ExecSteps.arguments_fit,Cslib.DataStructure.WordRAM.Randomized.ExecSteps.mapSimulates: preservation ofData.Bounded w, word-admissibility of encoded operation arguments, and basis simulation lifting forExecSteps.Cslib.DataStructure.WordRAM.Randomized.ObliviousSequenceImpl.prepare_bounded,Cslib.DataStructure.WordRAM.Randomized.ObliviousSequenceImpl.initFresh_exec,Cslib.DataStructure.WordRAM.Randomized.ObliviousSequenceImpl.initClear_exec,Cslib.DataStructure.WordRAM.Randomized.ObliviousSequenceImpl.seq_expected,Cslib.DataStructure.WordRAM.Randomized.ObliviousSequenceImpl.seq_expected_clear: word-bounded preparation, initialization, and end-to-end expected-time and distributional-contract theorems.
Named state and transcript bundles for oblivious-sequence execution #
Coupled latent state and concrete Word-RAM register/memory state.
- latent : Latent
Internal latent state (such as a hash seed or coupled relational state).
- data : WordRAM.Data r
Concrete Word-RAM register and memory state.
Instances For
Outcome of a single subroutine operation step: updated latent state, updated concrete Word-RAM state, and decoded operation observation.
- latent : Latent
Updated internal latent state.
- data : WordRAM.Data r
Updated concrete Word-RAM register and memory state.
- result : α
Decoded observation returned by the operation.
Instances For
Outcome of a multi-operation oblivious sequence: current latent state, concrete Word-RAM state,
and accumulated input-output transcript List (Sigma Result).
- latent : Latent
Current internal latent state.
- data : WordRAM.Data r
Current concrete Word-RAM register and memory state.
Accumulated input-output transcript of operations executed so far.
Instances For
Initialize a SeqOutcome from a LatentState with an empty transcript [].
Instances For
Append a single operation outcome q : StepOutcome Latent (Result o) r to t : SeqOutcome.
Instances For
Multi-operation distributional execution relation across an oblivious sequence
ops : List S.Op.
At each operation o, t.data and the encoded arguments are word-bounded (Fits w), arguments
are delivered via (P.toDynamicProgram encode decode).prepare o, P.code executes under
ExecCodeDist preserving Data.Bounded w, the observation q.result is decoded from
q.data.regs, memory outside [base, base + space) is preserved, and ⟨o, q.result⟩ is appended
to the accumulated transcript.
- nil {B : WordRAM.Basis} {r_ds k_init : ℕ} {P : WordRAM.SubroutineCode B r_ds k_init} {S : ObliviousSequenceSpec} {Latent : Type z} {w base space : ℕ} {encode : S.Op → Fin r_ds → ℕ} {decode : (o : S.Op) → (Fin r_ds → ℕ) → Option (S.Result o)} (ν : PMF (SeqOutcome Latent S.Result r_ds)) : ExecSteps P S Latent w base space encode decode [] ν ν 0
- cons {B : WordRAM.Basis} {r_ds k_init : ℕ} {P : WordRAM.SubroutineCode B r_ds k_init} {S : ObliviousSequenceSpec} {Latent : Type z} {w base space : ℕ} {encode : S.Op → Fin r_ds → ℕ} {decode : (o : S.Op) → (Fin r_ds → ℕ) → Option (S.Result o)} {o : S.Op} {ops : List S.Op} {ν ν_final : PMF (SeqOutcome Latent S.Result r_ds)} {μ_step : SeqOutcome Latent S.Result r_ds → PMF (StepOutcome Latent (S.Result o) r_ds)} {T_step : SeqOutcome Latent S.Result r_ds → ENNReal} {T_rest : ENNReal} : (∀ t ∈ ν.support, WordRAM.Data.Bounded w t.data ∧ (∀ (i : Fin r_ds), P.input i = true → WordRAM.Fits w (encode o i)) ∧ WordRAM.Data.Bounded w ((P.toDynamicProgram encode decode).prepare o t.data) ∧ WordRAM.ExecCodeDist w P.code ((P.toDynamicProgram encode decode).prepare o t.data) (PMF.map StepOutcome.data (μ_step t)) (T_step t) ∧ ∀ q ∈ (μ_step t).support, WordRAM.Data.Bounded w q.data ∧ decode o q.data.regs = some q.result ∧ WordRAM.Modifies { base := base, length := space }.footprint t.data.mem q.data.mem) → ExecSteps P S Latent w base space encode decode ops (ν.bind fun (t : SeqOutcome Latent S.Result r_ds) => PMF.map (t.appendStep o) (μ_step t)) ν_final T_rest → ExecSteps P S Latent w base space encode decode (o :: ops) ν ν_final (∑' (t : SeqOutcome Latent S.Result r_ds), ν t * T_step t + T_rest)
Instances For
ExecSteps preserves Data.Bounded w on every state in the support of ν_final whenever
every state in the support of ν is word-bounded.
Every operation o ∈ ops in an ExecSteps derivation has word-bounded encoded arguments on
all input registers of P.
Lift an ExecSteps derivation along a basis simulation φ : B.Simulates B'.
ObliviousSequenceImpl: Word-RAM implementation for an ObliviousSequenceSpec #
Reusable Word-RAM subroutine implementation certificate for a randomized data structure
P : SubroutineCode B r_ds k_init realizing an oblivious-sequence specification
S : DataStructure.ObliviousSequenceSpec at word width w, base address base, and runtime
parameters params.
- Latent : Type z
Internal latent state type (e.g. a hash seed or coupled relational state).
- space : ℕ
Contiguous memory footprint length
[base, base + space). - spanTime : ℕ
Worst-case instruction bound for
P.allocSpan. - setupTime : ENNReal
Expected instruction bound for
P.initSetup. - initPotential : ℕ
Upper bound on initial concrete potential after initialization (
0when unamortized). Per-operation instruction charge.
- initInv : PMF (LatentState self.Latent r_ds) → Prop
Distributional invariant on the initial coupled state distribution produced by
P.initSetup. Predicate on a latent state and an operation under which
arguments_fitbounds the encoded arguments (fun _ _ => Truewhen operation encoding is unconditionally word-bounded). No field relates it toS.ValidOpSeq, andsteps_execdoes not use it.Standalone register encoding for argument delivery.
Output decoder reading typed operation observations from final registers.
- bounded {ν : PMF (LatentState self.Latent r_ds)} : self.initInv ν → ∀ t ∈ ν.support, WordRAM.Data.Bounded w t.data
Initial distributions satisfying
initInvare supported on word-bounded states. - arguments_fit {z : self.Latent} (o : S.Op) : self.validOp z o → ∀ (i : Fin r_ds), P.input i = true → WordRAM.Fits w (self.encode o i)
Standalone encoded arguments fit in
w-bit words on operations satisfyingvalidOpat some latent state. Distinctness of registers used by
zeroFillCoderelative tobaseRegandfrontierReg.Initialization parameter registers are not overwritten by
zeroFillCode.- incCur_eval {x : WordRAM.Data r_ds} : x.regs P.oneReg = 1 → WordRAM.Fits w (x.regs P.curReg + 1) → WordRAM.Op.eval w P.incCur x = some (x.set P.curReg (x.regs P.curReg + 1))
P.incCurincrementsP.curRegby1whenP.oneReg = 1and the sum fits inwbits. - span_exec {x : WordRAM.Data r_ds} : WordRAM.Data.Bounded w x → x.regs P.frontierReg = base → (∀ (j : Fin k_init), x.regs (P.initParams j) = params j) → ∃ (x₁ : WordRAM.Data r_ds), WordRAM.ExecWithin w P.allocSpan x x₁ self.spanTime ∧ x₁.mem = x.mem ∧ x₁.regs P.baseReg = base ∧ x₁.regs P.frontierReg = base + self.space ∧ ∀ (j : Fin k_init), x₁.regs (P.initParams j) = params j
Execution of
P.allocSpan: recordsbaseReg = baseand advancesfrontierReg. - setup_exec {x₁ : WordRAM.Data r_ds} : WordRAM.Data.Bounded w x₁ → x₁.regs P.baseReg = base → x₁.regs P.frontierReg = base + self.space → (∀ (j : Fin k_init), x₁.regs (P.initParams j) = params j) → (∀ a ∈ { base := base, length := self.space }.footprint, x₁.mem a = 0) → ∃ (ν₀ : PMF (LatentState self.Latent r_ds)), WordRAM.ExecCodeDist w P.initSetup x₁ (PMF.map LatentState.data ν₀) self.setupTime ∧ self.initInv ν₀ ∧ ∀ t ∈ ν₀.support, WordRAM.Data.Bounded w t.data ∧ t.data.regs P.frontierReg = base + self.space ∧ WordRAM.Modifies { base := base, length := self.space }.footprint x₁.mem t.data.mem
- steps_exec (ops : List S.Op) (ν₀ : PMF (LatentState self.Latent r_ds)) : S.ValidOpSeq ops → self.initInv ν₀ → ∃ (ν_final : PMF (SeqOutcome self.Latent S.Result r_ds)) (T_ops : ENNReal), ExecSteps P S self.Latent w base self.space self.encode self.decode ops (PMF.map SeqOutcome.ofLatentState ν₀) ν_final T_ops ∧ S.Contract ops (PMF.map SeqOutcome.transcript ν_final) ∧ T_ops ≤ ↑self.initPotential + ↑(List.map self.charge ops).sum
Instances For
Argument preparation preserves Data.Bounded w on operations satisfying C.validOp.
Total expected instruction bound for P.initFresh (spanTime + setupTime).
Instances For
Total expected instruction bound for P.initClear (spanTime + (4 * space + 6) + setupTime).
Instances For
Total operation charge summed across an operation sequence ops : List S.Op.
Instances For
Specialization of ExecSteps to an ObliviousSequenceImpl certificate C.
Instances For
Transport an ObliviousSequenceImpl certificate along a basis simulation φ : B.Simulates B'.
Instances For
Lift an exact-basis ObliviousSequenceImpl certificate to Basis.standard.
Instances For
Expected-time execution of P.initFresh when [base, base + C.space) already holds zeros.
Expected-time execution of P.initClear on arbitrary dirty memory.
End-to-end expected-time and distributional correctness theorem from fresh initialization
(seq_expected).
Starting from zeroed [base, base + C.space), P.initFresh followed by any admissible oblivious
operation sequence ops : List S.Op (S.ValidOpSeq ops) executes in expected time at most
C.initTime + C.initPotential + C.totalCharge ops, preserves Data.Bounded w on ν_final.support,
and induces an output transcript distribution ν_final.map SeqOutcome.transcript satisfying
S.Contract ops.
End-to-end expected-time and distributional correctness theorem from dirty memory
(seq_expected_clear).
Coupled latent seed, current abstract state, and accumulated relational transcript prefix for
embedding Cslib.DataStructure.WordRAM.Randomized.StateTransitionImpl into
ObliviousSequenceImpl.
- seed : Seed
Latent random seed from the underlying
StateTransitionImpl. - state : D.State
Current abstract state of
D. - trace : D.Transcript
Relational execution transcript accumulated since
s₀.
Instances For
Canonical Embedding of StateTransitionImpl into ObliviousSequenceImpl #
Canonical embedding of any relational
Cslib.DataStructure.WordRAM.Randomized.StateTransitionImpl certificate into
ObliviousSequenceImpl realizing D.toObliviousSequenceSpec s₀, given a state-independent
operation charge bound opCharge : D.Op → ℕ such that
∀ s o, D.valid s o → C.charge s o ≤ opCharge o.