# Toy example BV keyswitch

**URL:** <https://openfhe.discourse.group/t/toy-example-bv-keyswitch/1807>\
**Category:** FHE Questions\
**Created:** [December 26, 2024, 5:23pm UTC](https://openfhe.discourse.group/t/toy-example-bv-keyswitch/1807 "2024-12-26T17:23:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mmazz](https://avatars.discourse-cdn.com/v4/letter/m/50afbb/32.png) [@mmazz](https://openfhe.discourse.group/u/mmazz)\
**Post date:** [December 26, 2024, 5:23pm UTC](https://openfhe.discourse.group/t/toy-example-bv-keyswitch/1807/1 "2024-12-26T17:23:34Z")

</div>

Hi!

I’m trying to understand the BV keyswitch technique, in particular it RNS implementation.  
I read some articles, in particular appendix B of [Revisiting Homomorphic Encryption Schemes for Finite Fields](https://eprint.iacr.org/2021/204.pdf), but I can’t get the hole idea.

Basically each RNS polynomial of a ciphertext is then split in dnum polynomials?

Someone know a toy example of this techinque?

---

<div class="post-metadata">

**Author:** ![Caesar](https://yyz1.discourse-cdn.com/flex031/user_avatar/openfhe.discourse.group/caesar/32/63_2.png) [@Caesar](https://openfhe.discourse.group/u/Caesar)\
**Post date:** [December 27, 2024, 4:08pm UTC](https://openfhe.discourse.group/t/toy-example-bv-keyswitch/1807/2 "2024-12-27T16:08:45Z")

</div>

I do not think there is a numerical example of BV out there, but generating one should be straightforward (though laborious) if you trace one of the examples in OpenFHE - make sure to set the user parameter `keySwitchTechnique` to BV as follows.  
`parameters.SetKeySwitchTechnique(KeySwitchTechnique::BV);`

We could help you better if you could narrow down the scope of your question and ask about specific details of BV.

To me, the single-level-decomposition BV is just like the hybrid mode, but dnum is equal to k\_l - the number of limbs in the input ciphertext to be key-switched.

Have you also checked this [resource](https://eprint.iacr.org/2023/1642.pdf) (Section 2.2) while researching key switching? It provides a more accessible overview of the topic that might help.

---

<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:** [December 28, 2024, 7:09pm UTC](https://openfhe.discourse.group/t/toy-example-bv-keyswitch/1807/3 "2024-12-28T19:09:01Z")

</div>

Another paper that could also be useful for explaining BV key switching: [An Improved RNS Variant of the BFV Homomorphic Encryption Scheme](https://eprint.iacr.org/2018/117) Section 3.1 introduces BV key switching in Brakerski’s scheme for the simplest case (see Key Generation and Relinearization). Then it gradually explains a more complex version (leading to the RNS version at the end).
