opendp.smartnoise.core.api package

class opendp.smartnoise.core.api.LibraryWrapper[source]

Bases: object

accuracy_to_privacy_usage(privacy_definition, component, properties, accuracies, public_arguments)[source]

FFI Helper. Estimate the privacy usage necessary to bound accuracy to a given value. This function is data agnostic. It calls the validator rust FFI with protobuf objects.

Parameters
  • privacy_definition – A descriptive object defining neighboring, distance definitions

  • component – The component to compute accuracy for

  • properties – Properties about all of the arguments to the component

  • accuracies – A value and alpha to convert to privacy usage for each column

  • public_arguments – Public inputs to the component (like lower/upper for snapping)

Returns

A privacy usage response

analytic_gaussian_mechanism(value, epsilon, delta, sensitivity, enforce_constant_time)[source]

Direct api to access the analytic gaussian mechanism.

Parameters
  • value – float scalar to privatize

  • epsilon – float privacy parameter

  • delta – float privacy parameter

  • sensitivity – float L2 sensitivity

  • enforce_constant_time – ensure all calls take the same elapsed time

Returns

privatized float

compute_privacy_usage(analysis, release)[source]

FFI Helper. Compute the overall privacy usage of an analysis. This function is data agnostic. It calls the validator rust FFI with protobuf objects.

Parameters
  • analysis – A description of computation

  • release – A collection of public values

Returns

A privacy usage response

compute_release(analysis, release, stack_trace, filter_level)[source]

FFI Helper. Evaluate an analysis and release the differentially private results. This function touches private data. It calls the runtime rust FFI with protobuf objects.

Parameters
  • analysis – A description of computation

  • release – A collection of public values

  • stack_trace – Set to False to suppress stack traces

  • filter_level – Configures how much data should be included in the release

Returns

A response containing an updated release

gaussian_mechanism(value, epsilon, delta, sensitivity, enforce_constant_time)[source]

Direct api to access the gaussian mechanism.

Parameters
  • value – float scalar to privatize

  • epsilon – float privacy parameter

  • delta – float privacy parameter

  • sensitivity – float L2 sensitivity

  • enforce_constant_time – ensure all calls take the same elapsed time

Returns

privatized float

generate_report(analysis, release)[source]

FFI Helper. Generate a json string with a summary/report of the Analysis and Release This function is data agnostic. It calls the validator rust FFI with protobuf objects.

Parameters
  • analysis – A description of computation

  • release – A collection of public values

Returns

A protobuf response containing a json summary string

get_properties(analysis, release, node_ids=None)[source]

FFI Helper. Derive static properties for all components in the graph. This function is data agnostic. It calls the validator rust FFI with protobuf objects.

Parameters
  • analysis – A description of computation

  • release – A collection of public values

  • node_ids – An optional list of node ids to derive properties for

Returns

A dictionary of property sets, one set of properties per component

laplace_mechanism(value, epsilon, sensitivity, enforce_constant_time)[source]

Direct api to access the laplace mechanism.

Parameters
  • value – float scalar to privatize

  • epsilon – float privacy parameter

  • sensitivity – float L1 sensitivity

  • enforce_constant_time – ensure all calls take the same elapsed time

Returns

privatized float

privacy_usage_to_accuracy(privacy_definition, component, properties, public_arguments, alpha)[source]

FFI Helper. Estimate the accuracy of the release of a component, based on a privacy usage. This function is data agnostic. It calls the validator rust FFI with protobuf objects.

Parameters
  • privacy_definition – A descriptive object defining neighboring, distance definitions

  • component – The component to compute accuracy for

  • properties – Properties about all of the arguments to the component

  • public_arguments – Public inputs to the component (like lower/upper for snapping)

  • alpha – Used to set the confidence level for the accuracy

Returns

Accuracy estimates

simple_geometric_mechanism(value, epsilon, sensitivity, min, max, enforce_constant_time)[source]

Direct api to access the simple geometric mechanism.

Parameters
  • value – integer scalar to privatize

  • epsilon – float privacy parameter

  • sensitivity – float L1 sensitivity

  • min – lower bound on the statistic

  • max – upper bound on the statistic

  • enforce_constant_time – ensure all calls take the same elapsed time

Returns

privatized integer

snapping_mechanism(value, epsilon, sensitivity, min, max, enforce_constant_time, binding_probability=None)[source]

Direct api to access the snapping mechanism.

Parameters
  • value – float scalar to privatize

  • epsilon – float privacy parameter

  • sensitivity – float L1 sensitivity

  • min – lower bound on the statistic

  • max – upper bound on the statistic

  • enforce_constant_time – ensure all calls take the same elapsed time

  • binding_probability – optional float to scale clamping bounds based on the probability of the clamp binding

Returns

privatized float

validate_analysis(analysis, release)[source]

FFI Helper. Check if an analysis is differentially private, given a set of released values. This function is data agnostic. It calls the validator rust FFI with protobuf objects.

Parameters
  • analysis – A description of computation

  • release – A collection of public values

Returns

A success or failure response

opendp.smartnoise.core.api.format_error(error)[source]