Reusing arguments
This document explains how to reuse encrypted arguments in applications where the same arguments are used repeatedly.
Encrypting data can be resource-intensive, especially when the same argument or set of arguments is used multiple times. In such cases, it’s inefficient to encrypt and transfer the arguments repeatedly. Instead, you can encrypt the arguments separately and reuse them as needed. By encrypting the arguments once and reusing them, you can optimize performance by reducing encryption time, memory usage, and network bandwidth.
Here is an example:
Note when you use encrypt
method:
If you have multiple arguments, the
encrypt
method would return atuple
.If you specify
None
as one of the arguments,None
is placed at the same location in the resultingtuple
.For example,
circuit.encrypt(a, None, b, c, None)
returns(encrypted_a, None, encrypted_b, encrypted_c, None)
.
Each value returned by
encrypt
can be stored and reused anytime.
The order of arguments must be consistent when encrypting and using them. Encrypting an x
and using it as a y
could result in undefined behavior.
Last updated