code wiki / (root) / dp.nx

dp.nx

buildroot/runtime/dp.nx

5394 B151 linesdepth 4pulls 4 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

syscalls.nx rand.nx dp.nx

imports: syscalls.nxrand.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 dp_remaining dp_noisy_count dp_charge rand_bytes rand_open_urandom sys_read

structs

35struct DPBudget {

consts

44const DP_ERR_BUDGET: i64 = -1
45const DP_ERR_PENDING: i64 = -2

functions

47func dp_budget_new(eps_thou: i64, delta_nano: i64) -> *DPBudget {
called by 1: main
60func dp_charge(b: *DPBudget, eps_thou: i64) -> i64 {
79func dp_noisy_count(b: *DPBudget, true_count: i64,
called by 1: main calls 2: dp_chargerand_bytes
104func dp_noisy_sum(b: *DPBudget, true_sum: i64,
124func dp_remaining(b: *DPBudget) -> i64 {
called by 1: main
129func main() -> i64 {