Common tips
Retrieving a value within an encrypted array with an encrypted index
import numpy as np
from concrete import fhe
@fhe.compiler({"array": "encrypted", "index": "encrypted"})
def indexed_value(array, index):
all_indices = np.arange(array.size)
index_selection = index == all_indices
selection_and_zeros = array * index_selection
selection = np.sum(selection_and_zeros)
return selection
inputset = [(np.random.randint(0, 16, size=5), np.random.randint(0, 5)) for _ in range(50)]
circuit = indexed_value.compile(inputset)
array = np.random.randint(0, 16, size=5)
index = np.random.randint(0, 5)
assert circuit.encrypt_run_decrypt(array, index) == array[index]Filter an array with comparison (>)
Matrix Row/Col means
Last updated
Was this helpful?