Common Workarounds
Minimum for Two values
import numpy as np
from concrete import fhe
@fhe.compiler({"x": "encrypted", "y": "encrypted"})
def min_two(x, y):
diff = y - x
min_x_y = y - np.maximum(y - x, 0)
return min_x_y
inputset = [tuple(np.random.randint(0, 16, size=2)) for _ in range(50)]
circuit = min_two.compile(inputset)
x, y = np.random.randint(0, 16, size=2)
assert circuit.encrypt_run_decrypt(x, y) == min(x, y)Maximum for Two values
Minimum for several values
Retrieving a value within an encrypted array with an encrypted index
Filter an array with comparison (>)
Matrix Row/Col means
Last updated
Was this helpful?