Boolean Scheme Decrypt Error

Hi OpenFHE team!

While running the below code, segmentation faults will occur.

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.

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:

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

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

cc.EvalSign()
cc.BTKeyGen()
cc.EvalNOT()
cc.EvalDecomp()
cc.EvalBinGate()
cc.EvalFloor()
cc.EvalFunc()

@wowblk8 hank you for reporting this bug. We created an issue for it.