Encrypting Data
In this article we continue our quick start series. We assume that you are following from the previous article.
3. Create Tensors of Encrypted Data
We will create two tensors (ct1
and ct2
) of encrypted data to perform matrix multiplication.
Explanation:
We define the dimensions for our matrices.
We create two tensors
ct1
andct2
initialized withnullptr
.The
flatten
method simplifies the traversal of all elements.We use lambda functions
init_ct1
andinit_ct2
to initialize each element:Create a plaintext with an incremented float value.
Encrypt the plaintext using the network's public key.
Store the ciphertext in the tensor.
After initialization, we reshape the tensors back to their matrix dimensions.
4. Serialize Tensors
Before creating a compute request, we need to serialize the tensors.
Explanation:
The
serialize_ciphertext_tensor
method converts the tensor of ciphertexts into a string for transmission.
Last updated