# 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.

```cpp
    // Define dimensions for the matrices
    size_t n = 8, m = 8, p = 8;

    size_t n = 8, m = 8, p = 8;
    Tensor<CPUCryptoSystem::PlainText*> pt1(n, m, nullptr);
    pt1.flatten();
    for (size_t i = 0; i < n * m; i++) {
        pt1.at(i) = new CPUCryptoSystem::PlainText(cs.make_plaintext(i + 1));
    }

    Tensor<CPUCryptoSystem::PlainText*> pt2(m, p, nullptr);
    pt2.flatten();
    for (size_t i = 0; i < m * p; i++) {
        pt2.at(i) = new CPUCryptoSystem::PlainText(cs.make_plaintext(i + 1));
    }

    pt1.reshape({n, m});
    pt2.reshape({m, p});
    auto ct1 = cs.encrypt_tensor(client_node.network_public_key(), pt1);
    auto ct2 = cs.encrypt_tensor(client_node.network_public_key(), pt2);
```

**Explanation:**

* We define the dimensions for our matrices.
* We create two tensors `ct1` and `ct2` initialized with `nullptr`.
* The `flatten` method simplifies the traversal of all elements.
* We use lambda functions `init_ct1` and `init_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.

```cpp
    // Serialize the tensors of ciphertexts
    std::string serialized_ct1 = cs.serialize_ciphertext_tensor(ct1);
    std::string serialized_ct2 = cs.serialize_ciphertext_tensor(ct2);
```

**Explanation:**

* The `serialize_ciphertext_tensor` method converts the tensor of ciphertexts into a string for transmission.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://openvector.gitbook.io/docs/quick-start/editor-1.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
