# Deserializing a vector of type Ciphertext\<DCRTPoly\>

**URL:** https://openfhe.discourse.group/t/deserializing-a-vector-of-type-ciphertext-dcrtpoly/1689
**Category:** Library Questions
**Created:** [November 4, 2024, 3:34pm UTC](https://openfhe.discourse.group/t/deserializing-a-vector-of-type-ciphertext-dcrtpoly/1689 "2024-11-04T15:34:51Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![DenisRed](https://yyz1.discourse-cdn.com/flex031/user_avatar/openfhe.discourse.group/denisred/32/303_2.png) [@DenisRed](https://openfhe.discourse.group/u/DenisRed)
#### Post date: [November 4, 2024, 3:34pm UTC](https://openfhe.discourse.group/t/deserializing-a-vector-of-type-ciphertext-dcrtpoly/1689/1 "2024-11-04T15:34:51Z")

</div>

Hello guys,

the following code performs some computations with encrypted geo coordinates (latitude and longitude) in form of a vector of type `double`. All points are stored in another vector `encPoints` of type `Ciphertext<DCRTPoly>`. The variable `serverC` is the current location from which I want to query all locations in the vector `encPoints` within a radius of 1000m. So I’m checking the distance point by point, which works fine with scheme switch. I would like to store the results of `ctCompareDist` in a vector of type `Ciphertext<DCRTPoly>` and serialize them for forwarding to a client. When I try to deserialize the vector of type Ciphertext I get the following message:

![Screenshot 2024-11-04 at 16.28.42](https://canada1.discourse-cdn.com/flex031/uploads/openfhe/original/1X/c2e2d5b100a62ec1fd0fbc96542a4aad7f9ce534.png)

```auto
std::cout << "Running computations for euclidian distance ... " << '\n' << std::endl;
    vector<Ciphertext<DCRTPoly>> euclidDistanceComparisons(encPoints.size());
    for (int i = 0; i < encPoints.size(); i++) {
        
        cout << i;
        // Computations on the ciphertext
        auto ctSubs = serverCC->EvalSub(encPoints[i], serverC);
        auto ctSquares = serverCC->EvalSquare(ctSubs);
        auto ctSum1 = serverCC->EvalSum(ctSquares, 2);

        vector<double> mask = {1, 0, 0};
        auto ctSum2 = serverCC->EvalMult(ctSum1, serverCC->MakeCKKSPackedPlaintext(mask));
        double lowerBound = 0;
        double upperBound = 0.09;

        auto ctDistance = serverCC->EvalChebyshevFunction([](double x) -> double { return std::sqrt(x); }, ctSum2, lowerBound, upperBound, 10);

        vector<double> mask2 = {0, 0, 1};
        auto ct = serverCC->EvalMult(serverC, serverCC->MakeCKKSPackedPlaintext(mask2));
        auto ctRadius = serverCC->EvalSum(ct, 3);
        auto ctCompareDist = serverCC->EvalCompareSchemeSwitching(ctRadius, ctDistance);

        euclidDistanceComparisons[i] = ctCompareDist;

    }

Serial::SerializeToFile(DATAFOLDER + encCompareDistLocation, euclidDistanceComparisons, SerType::BINARY);

```

---

<div class="post-metadata">

### Author: ![dsuponitskiy-duality](https://avatars.discourse-cdn.com/v4/letter/d/c68b51/32.png) [@dsuponitskiy-duality](https://openfhe.discourse.group/u/dsuponitskiy-duality)
#### Post date: [November 5, 2024, 4:58pm UTC](https://openfhe.discourse.group/t/deserializing-a-vector-of-type-ciphertext-dcrtpoly/1689/2 "2024-11-05T16:58:51Z")

</div>

@DenisRed From the given code, it is not clear exactly what you are doing to get that error. Could you provide the entire file or, at least, a simplified example that produces the same exception?

---

<div class="post-metadata">

### Author: ![DenisRed](https://yyz1.discourse-cdn.com/flex031/user_avatar/openfhe.discourse.group/denisred/32/303_2.png) [@DenisRed](https://openfhe.discourse.group/u/DenisRed)
#### Post date: [November 7, 2024, 2:57pm UTC](https://openfhe.discourse.group/t/deserializing-a-vector-of-type-ciphertext-dcrtpoly/1689/3 "2024-11-07T14:57:59Z")

</div>

Hi @dsuponitskiy-duality i solved the issue myself! Thank you anyway =)

---

<div class="post-metadata">

### Author: ![dsuponitskiy-duality](https://avatars.discourse-cdn.com/v4/letter/d/c68b51/32.png) [@dsuponitskiy-duality](https://openfhe.discourse.group/u/dsuponitskiy-duality)
#### Post date: [November 7, 2024, 9:44pm UTC](https://openfhe.discourse.group/t/deserializing-a-vector-of-type-ciphertext-dcrtpoly/1689/4 "2024-11-07T21:44:50Z")

</div>

@DenisRed No problem
