# Help with CKKS bootstrapping

**URL:** https://openfhe.discourse.group/t/help-with-ckks-bootstrapping/1951
**Category:** Library Questions
**Tags:** openfhe-help, questions
**Created:** [March 22, 2025, 9:21pm UTC](https://openfhe.discourse.group/t/help-with-ckks-bootstrapping/1951 "2025-03-22T21:21:17Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![sp18](https://avatars.discourse-cdn.com/v4/letter/s/a9adbd/32.png) [@sp18](https://openfhe.discourse.group/u/sp18)
#### Post date: [March 22, 2025, 9:21pm UTC](https://openfhe.discourse.group/t/help-with-ckks-bootstrapping/1951/1 "2025-03-22T21:21:17Z")

</div>

I am trying to understand the openFHE implementation of CKKS bootstrapping and understand the time taken by it. I understand the implementation is of Meta-BTS. When I run the repo example of simple bootstrapping [here](https://github.com/openfheorg/openfhe-development/blob/main/src/pke/examples/simple-ckks-bootstrapping.cpp), I use the below code to understand the time taken for a single bootstrapping (around line-142 of the same code):  
auto start = std::chrono::high\_resolution\_clock::now();  
auto ciphertextAfter = cryptoContext-\>EvalBootstrap(ciph);  
auto end = std::chrono::high\_resolution\_clock::now();  
std::cout \<\<“Time taken for 1 bootstrapping”\<\< std::chrono::duration\_caststd::chrono::milliseconds(end-start).count()\<\<std::endl;

Each time I run the above, I get the runtime for a single bootstrap somewhere in the range of 3000 ms to 7000 ms, as and when I adjust the level-budget and levelsAvailableAfterBootstrap to adjust the multiplicative depth as per my needs. For an example, I have used ring dimension 2^16 and 128 bit security, level budget = {2,2} and levelsAvailableAfterBootstrap=4 for your reference, and get the above bootstrap time ~2500 ms and log PQ around 1800 bits.

Now, I am running this in my laptop, but where I am confused is if this is the expected timing for running CKKS bootstrapping on CPU. I have not changed anything else in the code except for the ring dimension, security bit, level-budget and levels after bootstrap. The meta-BTS paper mentions the runtime for a single CKKS bootstrap with a single iteration for N=16 to be somewhere around 20-40 seconds! Am I going wrong somewhere? I am not using any optimization anywhere.

---

<div class="post-metadata">

### Author: ![andreea.alexandru](https://yyz1.discourse-cdn.com/flex031/user_avatar/openfhe.discourse.group/andreea.alexandru/32/378_2.png) [@andreea.alexandru](https://openfhe.discourse.group/u/andreea.alexandru)
#### Post date: [March 24, 2025, 6:28pm UTC](https://openfhe.discourse.group/t/help-with-ckks-bootstrapping/1951/2 "2025-03-24T18:28:43Z")

</div>

Are you setting the run to be single-threaded instead of using how many threads your laptop has available? You can do this by using -DWITH OPENMP=OFF when running cmake.

Here are some older experiments on CKKS bootstrapping in OpenFHE [https://eprint.iacr.org/2023/149.pdf](https://eprint.iacr.org/2023/149.pdf).

By the way, you can define BOOTSTRAPTIMING and this will print the runtime of bootstrapping split into steps.

---

<div class="post-metadata">

### Author: ![sp18](https://avatars.discourse-cdn.com/v4/letter/s/a9adbd/32.png) [@sp18](https://openfhe.discourse.group/u/sp18)
#### Post date: [March 24, 2025, 7:26pm UTC](https://openfhe.discourse.group/t/help-with-ckks-bootstrapping/1951/3 "2025-03-24T19:26:10Z")

</div>

Thank you. I am using a single thread. But my concern is, even with a single thread, my bootstrap timing is in the order of 10 times faster than the reported timing of each bootstrapping in the Meta-BTS paper, as I shared above. It should be around 20-30 seconds as per the timings reported on the paper, instead of 2-3 seconds that I get now, even with a single threaded computation.

---

<div class="post-metadata">

### Author: ![andreea.alexandru](https://yyz1.discourse-cdn.com/flex031/user_avatar/openfhe.discourse.group/andreea.alexandru/32/378_2.png) [@andreea.alexandru](https://openfhe.discourse.group/u/andreea.alexandru)
#### Post date: [March 24, 2025, 7:50pm UTC](https://openfhe.discourse.group/t/help-with-ckks-bootstrapping/1951/4 "2025-03-24T19:50:50Z")

</div>

Are you using `parameters.SetSecurityLevel(HEStd_128_classic)` instead of `parameters.SetSecurityLevel(HEStd_NotSet)` as in the example you mentioned? For log(PQ) = 1800, the ring dimension should be 2^{17} for 128-bit security.

Can you please provide your code even if it is very similar to the example, so we can ensure all parameters are set correctly?
