dp.nx
buildroot/runtime/dp.nx
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
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
structs
| 35 | struct DPBudget { |
consts
| 44 | const DP_ERR_BUDGET: i64 = -1 |
| 45 | const DP_ERR_PENDING: i64 = -2 |
functions
| 47 | func dp_budget_new(eps_thou: i64, delta_nano: i64) -> *DPBudget {
called by 1: main |
| 60 | func dp_charge(b: *DPBudget, eps_thou: i64) -> i64 { |
| 79 | func dp_noisy_count(b: *DPBudget, true_count: i64, |
| 104 | func dp_noisy_sum(b: *DPBudget, true_sum: i64, |
| 124 | func dp_remaining(b: *DPBudget) -> i64 {
called by 1: main |
| 129 | func main() -> i64 { |