opendp.core module#
The core
module provides functions for accessing the fields of transformations and measurements.
For more context, see core in the User Guide.
For convenience, all the functions of this module are also available from opendp.prelude
.
We suggest importing under the conventional name dp
:
>>> import opendp.prelude as dp
- opendp.core.function_eval(this, arg, TI=None)[source]#
Eval the
function
witharg
.- Parameters:
this (Function) – Function to invoke.
arg – Input data to supply to the measurement. A member of the measurement’s input domain.
TI (str) – Input Type.
- Raises:
TypeError – if an argument’s type differs from the expected type
UnknownTypeException – if a type argument fails to parse
OpenDPException – packaged error from the core OpenDP library
- opendp.core.measurement_check(measurement, distance_in, distance_out)[source]#
Check the privacy relation of the
measurement
at the givend_in
,d_out
- Parameters:
measurement (Measurement) – Measurement to check the privacy relation of.
distance_in –
distance_out –
- Returns:
True indicates that the relation passed at the given distance.
- Raises:
TypeError – if an argument’s type differs from the expected type
UnknownTypeException – if a type argument fails to parse
OpenDPException – packaged error from the core OpenDP library
- opendp.core.measurement_function(this)[source]#
Get the function from a measurement.
- Parameters:
this (Measurement) – The measurement to retrieve the value from.
- Return type:
- Raises:
TypeError – if an argument’s type differs from the expected type
UnknownTypeException – if a type argument fails to parse
OpenDPException – packaged error from the core OpenDP library
- opendp.core.measurement_input_carrier_type(this)[source]#
Get the input (carrier) data type of
this
.- Parameters:
this (Measurement) – The measurement to retrieve the type from.
- Return type:
str
- Raises:
TypeError – if an argument’s type differs from the expected type
UnknownTypeException – if a type argument fails to parse
OpenDPException – packaged error from the core OpenDP library
- opendp.core.measurement_input_distance_type(this)[source]#
Get the input distance type of
measurement
.- Parameters:
this (Measurement) – The measurement to retrieve the type from.
- Return type:
str
- Raises:
TypeError – if an argument’s type differs from the expected type
UnknownTypeException – if a type argument fails to parse
OpenDPException – packaged error from the core OpenDP library
- opendp.core.measurement_input_domain(this)[source]#
Get the input domain from a
measurement
.- Parameters:
this (Measurement) – The measurement to retrieve the value from.
- Return type:
- Raises:
TypeError – if an argument’s type differs from the expected type
UnknownTypeException – if a type argument fails to parse
OpenDPException – packaged error from the core OpenDP library
- opendp.core.measurement_input_metric(this)[source]#
Get the input domain from a
measurement
.- Parameters:
this (Measurement) – The measurement to retrieve the value from.
- Return type:
- Raises:
TypeError – if an argument’s type differs from the expected type
UnknownTypeException – if a type argument fails to parse
OpenDPException – packaged error from the core OpenDP library
- opendp.core.measurement_invoke(this, arg)[source]#
Invoke the
measurement
witharg
. Returns a differentially private release.- Parameters:
this (Measurement) – Measurement to invoke.
arg – Input data to supply to the measurement. A member of the measurement’s input domain.
- Raises:
TypeError – if an argument’s type differs from the expected type
UnknownTypeException – if a type argument fails to parse
OpenDPException – packaged error from the core OpenDP library
- opendp.core.measurement_map(measurement, distance_in)[source]#
Use the
measurement
to map a givend_in
tod_out
.- Parameters:
measurement (Measurement) – Measurement to check the map distances with.
distance_in – Distance in terms of the input metric.
- Raises:
TypeError – if an argument’s type differs from the expected type
UnknownTypeException – if a type argument fails to parse
OpenDPException – packaged error from the core OpenDP library
- opendp.core.measurement_output_distance_type(this)[source]#
Get the output distance type of
measurement
.- Parameters:
this (Measurement) – The measurement to retrieve the type from.
- Return type:
str
- Raises:
TypeError – if an argument’s type differs from the expected type
UnknownTypeException – if a type argument fails to parse
OpenDPException – packaged error from the core OpenDP library
- opendp.core.measurement_output_measure(this)[source]#
Get the output domain from a
measurement
.- Parameters:
this (Measurement) – The measurement to retrieve the value from.
- Return type:
- Raises:
TypeError – if an argument’s type differs from the expected type
UnknownTypeException – if a type argument fails to parse
OpenDPException – packaged error from the core OpenDP library
- opendp.core.new_function(function, TO)[source]#
Construct a Function from a user-defined callback. Can be used to build a post-processor.
Required features:
contrib
,honest-but-curious
new_function in Rust documentation.
Why honest-but-curious?:
An OpenDP
function
must satisfy two criteria. These invariants about functions are necessary to show correctness of other algorithms.First,
function
must not use global state. For instance, a postprocessor that accesses the system clock time can be used to build a measurement that reveals elapsed execution time, which escalates a side-channel vulnerability into a direct vulnerability.Secondly,
function
must only raise data-independent exceptions. For instance, raising an exception with the value of a DP release will both reveal the DP output and cancel the computation, potentially avoiding privacy accounting.- Parameters:
function – A function mapping data to a value of type
TO
TO (Type Argument) – Output Type
- Return type:
- Raises:
TypeError – if an argument’s type differs from the expected type
UnknownTypeException – if a type argument fails to parse
OpenDPException – packaged error from the core OpenDP library
- opendp.core.new_queryable(transition, Q='ExtrinsicObject', A='ExtrinsicObject')[source]#
Construct a queryable from a user-defined transition function.
Required features:
contrib
- Parameters:
transition – A transition function taking a reference to self, a query, and an internal/external indicator
Q (Type Argument) – Query Type
A (Type Argument) – Output Type
- Raises:
TypeError – if an argument’s type differs from the expected type
UnknownTypeException – if a type argument fails to parse
OpenDPException – packaged error from the core OpenDP library
- opendp.core.queryable_eval(queryable, query)[source]#
Invoke the
queryable
withquery
. Returns a differentially private release.- Parameters:
queryable – Queryable to eval.
query – Input data to supply to the measurement. A member of the measurement’s input domain.
- Raises:
TypeError – if an argument’s type differs from the expected type
UnknownTypeException – if a type argument fails to parse
OpenDPException – packaged error from the core OpenDP library
- opendp.core.queryable_query_type(this)[source]#
Get the query type of
queryable
.- Parameters:
this – The queryable to retrieve the query type from.
- Return type:
str
- Raises:
TypeError – if an argument’s type differs from the expected type
UnknownTypeException – if a type argument fails to parse
OpenDPException – packaged error from the core OpenDP library
- opendp.core.transformation_check(transformation, distance_in, distance_out)[source]#
Check the privacy relation of the
measurement
at the givend_in
,d_out
- Parameters:
transformation (Transformation) –
distance_in –
distance_out –
- Returns:
True indicates that the relation passed at the given distance.
- Raises:
TypeError – if an argument’s type differs from the expected type
UnknownTypeException – if a type argument fails to parse
OpenDPException – packaged error from the core OpenDP library
- opendp.core.transformation_function(this)[source]#
Get the function from a transformation.
- Parameters:
this (Transformation) – The transformation to retrieve the value from.
- Return type:
- Raises:
TypeError – if an argument’s type differs from the expected type
UnknownTypeException – if a type argument fails to parse
OpenDPException – packaged error from the core OpenDP library
- opendp.core.transformation_input_carrier_type(this)[source]#
Get the input (carrier) data type of
this
.- Parameters:
this (Transformation) – The transformation to retrieve the type from.
- Return type:
str
- Raises:
TypeError – if an argument’s type differs from the expected type
UnknownTypeException – if a type argument fails to parse
OpenDPException – packaged error from the core OpenDP library
- opendp.core.transformation_input_distance_type(this)[source]#
Get the input distance type of
transformation
.- Parameters:
this (Transformation) – The transformation to retrieve the type from.
- Return type:
str
- Raises:
TypeError – if an argument’s type differs from the expected type
UnknownTypeException – if a type argument fails to parse
OpenDPException – packaged error from the core OpenDP library
- opendp.core.transformation_input_domain(this)[source]#
Get the input domain from a
transformation
.- Parameters:
this (Transformation) – The transformation to retrieve the value from.
- Return type:
- Raises:
TypeError – if an argument’s type differs from the expected type
UnknownTypeException – if a type argument fails to parse
OpenDPException – packaged error from the core OpenDP library
- opendp.core.transformation_input_metric(this)[source]#
Get the input domain from a
transformation
.- Parameters:
this (Transformation) – The transformation to retrieve the value from.
- Return type:
- Raises:
TypeError – if an argument’s type differs from the expected type
UnknownTypeException – if a type argument fails to parse
OpenDPException – packaged error from the core OpenDP library
- opendp.core.transformation_invoke(this, arg)[source]#
Invoke the
transformation
witharg
. Returns a differentially private release.- Parameters:
this (Transformation) – Transformation to invoke.
arg – Input data to supply to the transformation. A member of the transformation’s input domain.
- Raises:
TypeError – if an argument’s type differs from the expected type
UnknownTypeException – if a type argument fails to parse
OpenDPException – packaged error from the core OpenDP library
- opendp.core.transformation_map(transformation, distance_in)[source]#
Use the
transformation
to map a givend_in
tod_out
.- Parameters:
transformation (Transformation) – Transformation to check the map distances with.
distance_in – Distance in terms of the input metric.
- Raises:
TypeError – if an argument’s type differs from the expected type
UnknownTypeException – if a type argument fails to parse
OpenDPException – packaged error from the core OpenDP library
- opendp.core.transformation_output_distance_type(this)[source]#
Get the output distance type of
transformation
.- Parameters:
this (Transformation) – The transformation to retrieve the type from.
- Return type:
str
- Raises:
TypeError – if an argument’s type differs from the expected type
UnknownTypeException – if a type argument fails to parse
OpenDPException – packaged error from the core OpenDP library
- opendp.core.transformation_output_domain(this)[source]#
Get the output domain from a
transformation
.- Parameters:
this (Transformation) – The transformation to retrieve the value from.
- Return type:
- Raises:
TypeError – if an argument’s type differs from the expected type
UnknownTypeException – if a type argument fails to parse
OpenDPException – packaged error from the core OpenDP library
- opendp.core.transformation_output_metric(this)[source]#
Get the output domain from a
transformation
.- Parameters:
this (Transformation) – The transformation to retrieve the value from.
- Return type:
- Raises:
TypeError – if an argument’s type differs from the expected type
UnknownTypeException – if a type argument fails to parse
OpenDPException – packaged error from the core OpenDP library