Hi,
Today was released concrete-ml 0.3.0
and I would like to ask some doubts related to time execution and size of encrypted values.
First, I used the example from the Concrete-ml GitHub repository. Then, I edited the file circuit.py
, specifically the encrypt_run_decrypt
function like this:
def encrypt_run_decrypt(self, *args: Any) -> Any:
"""
Encrypt inputs, run the circuit, and decrypt the outputs in one go.
Args:
*args (Union[int, numpy.ndarray]):
inputs to the circuit
Returns:
Union[int, np.ndarray, Tuple[Union[int, np.ndarray], ...]]:
clear result of homomorphic evaluation
"""
if self.configuration.virtual:
return self.graph(*args)
print("Values:", *args)
start_time_encrypt = time.time()
public_args = self.encrypt(*args)
print("--- %s seconds encrypt ---" % (time.time() - start_time_encrypt))
print("Size of encrypted values:", sys.getsizeof(public_args.serialize()))
start_time_run = time.time()
encrypted_result = self.run(public_args)
print("--- %s seconds run ---" % (time.time() - start_time_run))
start_time_decrypt = time.time()
decrypted_result = self.decrypt(encrypted_result)
print("--- %s seconds decrypt ---" % (time.time() - start_time_decrypt))
return decrypted_result
#return self.decrypt(self.run(self.encrypt(*args)))
And these are the results (Only the first three elements):
Values: [[25 25 19 9]]
--- 68.07132411003113 seconds (encrypt) ---
Size of encrypted values: 65633
--- 0.6150095462799072 seconds (run) ---
--- 0.000396728515625 seconds (decrypt) ---
Values: [[ 5 6 16 20]]
--- 0.004143953323364258 seconds (encrypt) ---
Size of encrypted values: 65633
--- 0.6125960350036621 seconds (run) ---
--- 0.0003757476806640625 seconds (decrypt) ---
Values: [[ 5 10 28 6]]
--- 0.004086494445800781 seconds (encrypt) ---
Size of encrypted values: 65633
--- 0.6059427261352539 seconds (run) ---
--- 0.0003662109375 seconds (decrypt) ---
...
Doubts:
- Why is the first encrytion so much longer than the rest?
- Why is the encrypted size the same if the values are different? What does the size depend on?
- Is there an error in my edited code?
Thank you very much. I greatly appreciate your effort in adding functionalities to the library.