pub struct PrivacyBudget { /* private fields */ }not differentially private (predictable xorshift64 state, time-derived seed, floating-point inverse transform); use alice_crypto::dp instead. Removed in 0.5.0
Expand description
Track cumulative privacy budget (composition theorem)
Under sequential composition, ε values add up. Under parallel composition over disjoint data, use max.
Implementations§
Source§impl PrivacyBudget
impl PrivacyBudget
Sourcepub fn try_spend(&mut self, epsilon: f64) -> bool
pub fn try_spend(&mut self, epsilon: f64) -> bool
Try to spend epsilon from budget
Returns true and charges the ledger if the request is well formed and
fits in the remaining budget; returns false and leaves every field
untouched otherwise.
A request is well formed when epsilon is finite and not negative.
0.0 (and -0.0) is well formed: it charges nothing and counts a
query.
Rejecting a negative epsilon is the whole point of the type. Until
2026-10-07 the guard was only the budget comparison
total + epsilon <= max, which a negative value passes trivially, so
try_spend(-10.0) returned true and raised the remaining budget
from 1 to 11; -inf raised it to infinity. A caller that spends a
negative epsilon between two honest queries escapes the limit the
budget exists to enforce. NaN and +inf were already refused,
though only as a side effect of the comparison being false — they are
now refused by the same explicit check.
Sourcepub const fn query_count(&self) -> u64
pub const fn query_count(&self) -> u64
Get query count
Sourcepub fn is_exhausted(&self) -> bool
pub fn is_exhausted(&self) -> bool
Check if budget is exhausted