Common Workarounds
Minimum for Two values
In this first example, we compute a minimum by creating the difference between two numbers y
and x
and conditionally remove this diff from y
to either get x
if y>x
or y
if x>y
:
Maximum for Two values
The companion example of above with the maximum value of two integers instead of the minimum:
Minimum for several values
And an extension for more than two values:
Retrieving a value within an encrypted array with an encrypted index
This example shows how to deal with an array and an encrypted index. It will create a "selection" array filled with 0
except for the requested index that will be 1
, and sum the products of all array values by this selection array:
Filter an array with comparison (>)
This example filters an encrypted array with an encrypted condition, here a greater than
with an encrypted value. It packs all values with a selection bit, resulting from the comparison that allow the unpacking of only the filtered values:
Matrix Row/Col means
In this example Matrix operation, we are introducing a key concept when using Concrete: trying to maximize the parallelization. Here instead of sequentially summing all values to create a mean value, we split the values in sub-groups, and do the mean of the sub-group means:
Last updated