Skip to main content

DiffPrivacyEngine

Struct DiffPrivacyEngine 

Source
pub struct DiffPrivacyEngine { /* private fields */ }
Expand description

Differential privacy engine for adding calibrated noise.

Implementations§

Source§

impl DiffPrivacyEngine

Source

pub fn gaussian( epsilon: f64, delta: f64, sensitivity: f64, clipping_norm: f64, ) -> Result<Self, FederationError>

Create a new DP engine with Gaussian mechanism.

Default: epsilon=1.0, delta=1e-5 (strong privacy).

Source

pub fn laplace( epsilon: f64, sensitivity: f64, clipping_norm: f64, ) -> Result<Self, FederationError>

Create a new DP engine with Laplace mechanism.

Source

pub fn with_seed(self, seed: u64) -> Self

Create with a deterministic seed (for testing).

Source

pub fn clip_gradients(&self, gradients: &mut [f64])

Clip a gradient vector to the configured L2 norm bound.

Source

pub fn add_noise(&mut self, params: &mut [f64]) -> DiffPrivacyProof

Add calibrated noise to a vector of parameters.

Clips gradients first, then adds noise per the configured mechanism.

Source

pub fn add_noise_scalar(&mut self, value: &mut f64) -> f64

Add noise to a single scalar value.

Source

pub fn epsilon(&self) -> f64

Current epsilon setting.

Source

pub fn delta(&self) -> f64

Current delta setting.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V