# Wrong level after bootstrap

**URL:** <https://openfhe.discourse.group/t/wrong-level-after-bootstrap/584>\
**Category:** FHE Questions\
**Created:** [May 25, 2023, 1:17pm UTC](https://openfhe.discourse.group/t/wrong-level-after-bootstrap/584 "2023-05-25T13:17:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![marc-alonso](https://avatars.discourse-cdn.com/v4/letter/m/6f9a4e/32.png) [@marc-alonso](https://openfhe.discourse.group/u/marc-alonso)\
**Post date:** [May 25, 2023, 1:17pm UTC](https://openfhe.discourse.group/t/wrong-level-after-bootstrap/584/1 "2023-05-25T13:17:48Z")

</div>

Hello, I’m trying to choose the right parameters for my application (in ckks). I am using

security = 128 bit  
ring = 2^16  
full packing  
levelBudget = {3, 3}  
approxBootstrapDepth = 4  
levelsUsedBeforeBootstrap = 11

So the depth of the circuit is 15+11=26.

When i bootstrap though, the result is at level 20. Is that right or am i missing something? I think it should be at 15.  
Thank you

---

<div class="post-metadata">

**Author:** ![ypolyakov](https://yyz1.discourse-cdn.com/flex031/user_avatar/openfhe.discourse.group/ypolyakov/32/47_2.png) [@ypolyakov](https://openfhe.discourse.group/u/ypolyakov)\
**Post date:** [May 26, 2023, 9:46pm UTC](https://openfhe.discourse.group/t/wrong-level-after-bootstrap/584/2 "2023-05-26T21:46:52Z")

</div>

I am not sure I follow your calculations. Why is `approxBootstrapDepth` set to 4, and where do you get 15?

I suggest looking at the [simple CKKS bootstrapping example](https://github.com/openfheorg/openfhe-development/blob/v1.0.3/src/pke/examples/simple-ckks-bootstrapping.cpp). Below is the relevant code.

```auto
    std::vector<uint32_t> levelBudget = {4, 4};
    uint32_t approxBootstrapDepth = 8;

    uint32_t levelsUsedBeforeBootstrap = 10;
    usint depth =
        levelsUsedBeforeBootstrap + FHECKKSRNS::GetBootstrapDepth(approxBootstrapDepth, levelBudget, secretKeyDist);
    parameters.SetMultiplicativeDepth(depth);

```

---

<div class="post-metadata">

**Author:** ![marc-alonso](https://avatars.discourse-cdn.com/v4/letter/m/6f9a4e/32.png) [@marc-alonso](https://openfhe.discourse.group/u/marc-alonso)\
**Post date:** [May 27, 2023, 11:25am UTC](https://openfhe.discourse.group/t/wrong-level-after-bootstrap/584/3 "2023-05-27T11:25:33Z")

</div>

15 is approxBootstrapDepth + levelBudget[0] + levelBudget[1] + 5 (just like is computed by FHECKKSRNS::GetBootstrapDepth)

I thought approxBootstrapDepth can be chosen by the user, so 8 is a fixed value?

---

<div class="post-metadata">

**Author:** ![ypolyakov](https://yyz1.discourse-cdn.com/flex031/user_avatar/openfhe.discourse.group/ypolyakov/32/47_2.png) [@ypolyakov](https://openfhe.discourse.group/u/ypolyakov)\
**Post date:** [June 2, 2023, 12:33am UTC](https://openfhe.discourse.group/t/wrong-level-after-bootstrap/584/4 "2023-06-02T00:33:04Z")

</div>

8 is a fixed value. We will simplify the bootstrapping interface in a later version where `approxBootstrapDepth` is automatically chosen by OpenFHE.
