I’m trying to implement sorting algorithms using Concrete to sort encrypted arrays. The algorithm seems to be working fine but problem is that the compilation time becomes extremely long as the array size increases (>=15). Here’s a snippet of the relevant code (odd/even sort algorithm)
@fhe.compiler({“arr”: “encrypted”})
def sort_array(arr):
n = arr.sizefor phase in range(n): start = phase % 2 for i in range(start, n - 1, 2): a, b = arr[i], arr[i+1] c = (a > b) arr[i] = c * b + (1 - c) * a arr[i+1] = c * a + (1 - c) * b return arr
lrange = int(input("Please enter the upper range limit: "))
lsize = int(input("Please enter the size of the list: "))inputset = [np.random.randint(0, lrange, size=lsize) for _ in range(50)]
sort_compile = sort_array.compile(inputset)
My questions:
- Is there any way to reduce the compilation time for larger input sizes?
- Is the long compilation time primarily due to the
inputset
, the algorithm’s structure, or both?
Thank you