Quick Start
Last updated
Last updated
To compute on encrypted data, you first need to define the function you want to compute, then compile it into a Concrete Circuit
, which you can use to perform homomorphic evaluation.
Here is the full example that we will walk through:
Everything you need to perform homomorphic evaluation is included in a single module:
In this example, we compile a simple addition function:
To compile the function, you need to create a Compiler
by specifying the function to compile and the encryption status of its inputs:
An inputset is a collection representing the typical inputs to the function. It is used to determine the bit widths and shapes of the variables within the function.
It should be in iterable, yielding tuples, of the same length as the number of arguments of the function being compiled:
All inputs in the inputset will be evaluated in the graph, which takes time. If you're experiencing long compilation times, consider providing a smaller inputset.
You can use the compile
method of a Compiler
class with an inputset to perform the compilation and get the resulting circuit back:
You can use the encrypt_run_decrypt
method of a Circuit
class to perform homomorphic evaluation:
circuit.encrypt_run_decrypt(*args)
is just a convenient way to do everything at once. It is implemented as circuit.decrypt(circuit.run(circuit.encrypt(*args)))
.