Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check wrong values for belowLVL in packedRecrypt #338

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/recryption.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,7 @@ void packedRecrypt(const CtPtrs& cPtrs,
const std::vector<zzX>& unpackConsts,
const EncryptedArray& ea)
{
if(cPtrs.size() == 0) return; // if there is no entry the next line will throw a exception.
FHEPubKey& pKey = (FHEPubKey&)cPtrs[0]->getPubKey();

// Allocate temporary ciphertexts for the recryption
Expand All @@ -733,6 +734,9 @@ void packedRecrypt(const CtPtrs& array,
const std::vector<zzX>& unpackConsts,
const EncryptedArray& ea, long belowLvl)
{
if(belowLvl == LONG_MAX) //default Value
belowLvl /= ea.getContext().BPL();
assertTrue(belowLvl <= (LONG_MAX / ea.getContext().BPL()),"Level to high overflow of Type LONG");
std::vector<Ctxt*> v;
for (long i=0; i<array.size(); i++)
if ( array.isSet(i) && !array[i]->isEmpty()
Expand All @@ -744,6 +748,9 @@ void packedRecrypt(const CtPtrMat& m,
const std::vector<zzX>& unpackConsts,
const EncryptedArray& ea, long belowLvl)
{
if(belowLvl == LONG_MAX) //default Value
belowLvl /= ea.getContext().BPL();
assertTrue(belowLvl <= (LONG_MAX / ea.getContext().BPL()),"Level to high overflow of Type LONG");
std::vector<Ctxt*> v;
for (long i=0; i<m.size(); i++)
for (long j=0; j<m[i].size(); j++)
Expand Down