# BFV Ciphertext multiplication

**URL:** <https://openfhe.discourse.group/t/bfv-ciphertext-multiplication/1508>\
**Category:** Library Questions\
**Tags:** questions\
**Created:** [August 22, 2024, 6:05pm UTC](https://openfhe.discourse.group/t/bfv-ciphertext-multiplication/1508 "2024-08-22T18:05:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Atwo](https://avatars.discourse-cdn.com/v4/letter/a/e99b99/32.png) [@Atwo](https://openfhe.discourse.group/u/Atwo)\
**Post date:** [August 22, 2024, 6:05pm UTC](https://openfhe.discourse.group/t/bfv-ciphertext-multiplication/1508/1 "2024-08-22T18:05:43Z")

</div>

Hello,

I am reading [Revisiting Homomorphic Encryption Schemes for Finite Fields](https://eprint.iacr.org/2021/204)  
Revisiting Homomorphic Encryption for finite field.

Algorithm 2, New BFV Multiplication Algorithm, there is modulus error '\epsilon\_{round}".  
Means first ct\_{2} is mod switch by P then it is multiplied to ct\_{1}.

 ![图片1](https://canada1.discourse-cdn.com/flex031/uploads/openfhe/original/1X/3bb1e8c4b614e9c6b1ddec9c85e6cd5c2f1861b8.png)

Can you show me the code where it shows mod switch of second ciphertext and “\epsilon\_{round}” error in code

> <https://github.com/openfheorg/openfhe-development/blob/main/src/pke/examples/simple-integers.cpp>

Thanks in advance.

---

<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:** [August 22, 2024, 8:00pm UTC](https://openfhe.discourse.group/t/bfv-ciphertext-multiplication/1508/2 "2024-08-22T20:00:52Z")

</div>

Looks like you are referring to this [function](https://github.com/openfheorg/openfhe-development/blob/13bf46f683483da1fe77f591b98035fa455740c6/src/pke/lib/scheme/bfvrns/bfvrns-leveledshe.cpp#L182).  
It might be helpful to you to build the codebase in _Debug_ model and step through the code until you reach the functionality you need. Any tutorial on debugging _C++_ code should show how to do that.

---

<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:** [August 28, 2024, 9:25pm UTC](https://openfhe.discourse.group/t/bfv-ciphertext-multiplication/1508/3 "2024-08-28T21:25:55Z")

</div>

The main code is [here](https://github.com/openfheorg/openfhe-development/blob/v1.2.0/src/pke/lib/scheme/bfvrns/bfvrns-leveledshe.cpp#L251)

---

<div class="post-metadata">

**Author:** ![Atwo](https://avatars.discourse-cdn.com/v4/letter/a/e99b99/32.png) [@Atwo](https://openfhe.discourse.group/u/Atwo)\
**Post date:** [August 29, 2024, 4:45am UTC](https://openfhe.discourse.group/t/bfv-ciphertext-multiplication/1508/4 "2024-08-29T04:45:48Z")

</div>

Thanks for your reply.

Theoretically we pick “P” is slightly smaller than Q.  
What are the default parameter value of “P” and “Q”.

Thanks in advance.

---

<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:** [August 31, 2024, 12:24am UTC](https://openfhe.discourse.group/t/bfv-ciphertext-multiplication/1508/5 "2024-08-31T00:24:53Z")

</div>

By default, both P and Q are products of 60-bit moduli. The value of Q is chosen based on the correctness constraint (depends on the multiplicative depth and other parameters).
