# Implement an Add and Multiply function with BinFHE in OpenFHE

**URL:** <https://openfhe.discourse.group/t/implement-an-add-and-multiply-function-with-binfhe-in-openfhe/1484>\
**Category:** Library Questions\
**Created:** [August 10, 2024, 10:49pm UTC](https://openfhe.discourse.group/t/implement-an-add-and-multiply-function-with-binfhe-in-openfhe/1484 "2024-08-10T22:49:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ngesbrian23](https://avatars.discourse-cdn.com/v4/letter/n/f04885/32.png) [@ngesbrian23](https://openfhe.discourse.group/u/ngesbrian23)\
**Post date:** [August 10, 2024, 10:49pm UTC](https://openfhe.discourse.group/t/implement-an-add-and-multiply-function-with-binfhe-in-openfhe/1484/1 "2024-08-10T22:49:07Z")

</div>

I have been looking through OpenFHE library and trying to use BinFHE. I want to evaluate two functions, 1) addition and 2) multiplication using FHEW.

When I try to use the functions shown in [Program Listing for File lwe-pke.h — OpenFHE documentation](https://openfhe-development.readthedocs.io/en/latest/api/program_listing_file_binfhe_include_lwe-pke.h.html?highlight=LWE) for this operations, I run into and error that says the functions does not exist

‘\> class lbcrypto::BinFHEContext’ has no member named ‘EvalAddConstEq’

> 96 | auto ctSum = ccLWE.EvalAddConstEq(ctxtsLWE1, ctxtsLWE2);

Is there any way to implement this type of arithmetic operations in BinFHE??  
N:B, I am not concerned about the cost of evaluation. I just want correct evaluation.

---

<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:** [August 12, 2024, 3:08pm UTC](https://openfhe.discourse.group/t/implement-an-add-and-multiply-function-with-binfhe-in-openfhe/1484/2 "2024-08-12T15:08:53Z")

</div>

It seems you want to add two ciphertexts, but are using a function meant to add a constant to a ciphertext:  
`void EvalAddConstEq(LWECiphertext& ct, NativeInteger cnst) const`

Try to use this function instead:  
`void EvalAddEq(LWECiphertext& ct1, ConstLWECiphertext& ct2) const`.

Note that these functions return void, as they perform the addition in place.

---

<div class="post-metadata">

**Author:** ![ngesbrian23](https://avatars.discourse-cdn.com/v4/letter/n/f04885/32.png) [@ngesbrian23](https://openfhe.discourse.group/u/ngesbrian23)\
**Post date:** [August 12, 2024, 4:51pm UTC](https://openfhe.discourse.group/t/implement-an-add-and-multiply-function-with-binfhe-in-openfhe/1484/3 "2024-08-12T16:51:01Z")

</div>

> [@andreea.alexandru](#):
>
> EvalAddEq

All the functions presented there have the same issue.  
error: ‘class lbcrypto::BinFHEContext’ has no member named ‘EvalAddEq’  
96 | ccLWE.EvalAddEq(ctxtsLWE1, ctxtsLWE2);

---

<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:** [August 12, 2024, 5:07pm UTC](https://openfhe.discourse.group/t/implement-an-add-and-multiply-function-with-binfhe-in-openfhe/1484/4 "2024-08-12T17:07:14Z")

</div>

You should not call them from ccLWE, but from ccLWE-\>GetLWEScheme().
