code wiki / (root) / nx_dp.nx

nx_dp.nx

buildroot/runtime/nx_dp.nx

5552 B158 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind tooltopic dp
docsdependenciesstructsconstsfunctions

about

dp.nx -- differential privacy accounting + noise. EFFICIENCY_ROADMAP ยง6.3. Typed epsilon budgets; the compiler (phase B) tracks accumulated privacy loss across queries + refuses to compile a pipeline whose epsilon sum exceeds the declared bound. Phase A: runtime DP budget tracker + Laplace/Gaussian noise primitives. Callers manually account for their queries. (epsilon, delta)-DP: a mechanism M is (eps, delta)-DP if for all neighbouring datasets D, D' and all outputs S: Pr[M(D) in S] <= exp(eps) * Pr[M(D') in S] + delta Laplace mechanism: add Lap(sensitivity/epsilon) noise to a query result. Gives pure-eps DP (delta=0). Gaussian mechanism: add N(0, sigma^2) where sigma = sqrt(2 ln 1.25/delta) * sensitivity / epsilon. (eps, delta)-DP. Invariants: DP1 Every query charges the budget BEFORE returning a result. DP2 Over-budget queries return DP_ERR_BUDGET and do NOT leak any data. DP3 Noise is drawn from rand.nx (cryptographic entropy) -- not xoshiro -- so noise is non-adversarial. DP4 Sensitivity is caller-declared; wrong sensitivity invalidates the DP guarantee (out-of-band contract).

dependencies 2 imports · 0 importers

nx_syscalls.nx nx_rand.nx nx_dp.nx

imports: nx_syscalls.nxnx_rand.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main dp_budget_new sys_mmap dp_remaining dp_noisy_count dp_charge sys_mmap ↻ rand_bytes rand_open_urandom sys_openat_rd sys_read sys_close

structs

42struct DPBudget

consts

38const DP_MAGIC_10000: i64 = 10000
51const DP_ERR_BUDGET: i64 = -1
52const DP_ERR_PENDING: i64 = -2

functions

54func dp_budget_new(eps_thou: i64, delta_nano: i64) -> *DPBudget
called by 1: main calls 1: sys_mmap
67func dp_charge(b: *DPBudget, eps_thou: i64) -> i64
86func dp_noisy_count(b: *DPBudget, true_count: i64,
called by 1: main calls 3: dp_chargesys_mmaprand_bytes
111func dp_noisy_sum(b: *DPBudget, true_sum: i64,
131func dp_remaining(b: *DPBudget) -> i64
called by 1: main
136func main() -> i64