Hello,
I’m a beginner so very sorry about my ignorance (I’m even not sure if my question makes sense).
Using Zama’s concrete, I write the following function:
import numpy as np
@fhe.function({"v": "encrypted"})
def count(v):
return np.sum(v == 1)
which aims to count the number of element of value 1
in a vector v
. Then use a data set:
inputset = [np.random.randint(0, 256, size=(100)) for _ in 200]
to compile a circuit:
circuit = count. Compile(inputset)
and play with it:
v_plain = np.random.randint(0, 256, size=(100))
v_enc = circuit.client.encrypt(v_plain)
c = count(v_enc)
Now I want to implement the function count
using Zama’s tfhe-rs, an imagined implementation is as follows:
fn count(v: Vec<uint8>) -> usize {
v.iter().....
}
Since tfhe-rs supports basically primitive types, then I cannot have an FHE type of Vec, so what should I do? Could I naively use v
as Vec<FheUint8>
or is there a specific data type for an encrypted vector of data?
Obviously, if I do that then at least the length of vector is leaked. I suppose that it is not the case for the Python version.
I may imagine that FHE simply does not care about that since it focuses on operations on data and the way data is encrypted depends on the users. If this is not true, then what happens under the hood for the initial case of v
? Concretely, in the call to encrypt
v_enc = circuit.client.encrypt(v)
does Zama’s concrete encrypts element by element of v
?
Many thanks for help.