# Boolean Scheme Decrypt Error

**URL:** <https://openfhe.discourse.group/t/boolean-scheme-decrypt-error/1704>\
**Category:** Library Questions\
**Tags:** bugs, questions, openfhe-help\
**Created:** [November 8, 2024, 10:09am UTC](https://openfhe.discourse.group/t/boolean-scheme-decrypt-error/1704 "2024-11-08T10:09:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![wowblk8](https://avatars.discourse-cdn.com/v4/letter/w/e79b87/32.png) [@wowblk8](https://openfhe.discourse.group/u/wowblk8)\
**Post date:** [November 8, 2024, 10:09am UTC](https://openfhe.discourse.group/t/boolean-scheme-decrypt-error/1704/1 "2024-11-08T10:09:23Z")

</div>

Hi OpenFHE team!

While running the below code, segmentation faults will occur.

```c++
cc.Decrypt(nullptr, ctResult, &result);
cc.Decrypt(sk, nullptr, &result);
cc.Decrypt(sk, ctResult, nullptr);

```

And in these three different lines of code, the points where the segmentation fault occurs are different.

```c++
openfhe-development/src/binfhe/lib/lwe-pke.cpp:195
openfhe-development/src/binfhe/lib/lwe-pke.cpp:188
openfhe-development/src/binfhe/lib/lwe-pke.cpp:215

```

In other modes (BFV, BGV, CKKS), the Decrypt function performs type checking, as shown in the following code:

```c++
DecryptResult CryptoContextImpl<DCRTPoly>::Decrypt(ConstCiphertext<DCRTPoly> ciphertext,
                                                   const PrivateKey<DCRTPoly> privateKey, Plaintext* plaintext) {
    if (ciphertext == nullptr)
        OPENFHE_THROW("ciphertext is empty");
    if (plaintext == nullptr)
        OPENFHE_THROW("plaintext is empty");
    if (privateKey == nullptr || Mismatched(privateKey->GetCryptoContext()))
        OPENFHE_THROW("Information was not generated with this crypto context");

```

Therefore, we believe that similar type-checking code should be added to this function as well.

Are these bugs?

Thank you for taking the time to look into this issue. Please let us know if any further details or clarification would be helpful!

Best regards,  
wowblk

---

<div class="post-metadata">

**Author:** ![wowblk8](https://avatars.discourse-cdn.com/v4/letter/w/e79b87/32.png) [@wowblk8](https://openfhe.discourse.group/u/wowblk8)\
**Post date:** [November 10, 2024, 1:01pm UTC](https://openfhe.discourse.group/t/boolean-scheme-decrypt-error/1704/2 "2024-11-10T13:01:43Z")

</div>

It was also found that the following function may cause a segmentation fault and does not check if the parameter is a nullptr.

```c++
cc.EvalSign()
cc.BTKeyGen()
cc.EvalNOT()
cc.EvalDecomp()
cc.EvalBinGate()
cc.EvalFloor()
cc.EvalFunc()

```

---

<div class="post-metadata">

**Author:** ![dsuponitskiy-duality](https://avatars.discourse-cdn.com/v4/letter/d/c68b51/32.png) [@dsuponitskiy-duality](https://openfhe.discourse.group/u/dsuponitskiy-duality)\
**Post date:** [November 15, 2024, 11:40pm UTC](https://openfhe.discourse.group/t/boolean-scheme-decrypt-error/1704/3 "2024-11-15T23:40:28Z")

</div>

@wowblk8 hank you for reporting this bug. We created [an issue](https://github.com/openfheorg/openfhe-development/issues/907) for it.
