intel / hexl

Intel:registered: Homomorphic Encryption Acceleration Library accelerates modular arithmetic operations used in homomorphic encryption

Home Page:https://intel.github.io/hexl

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

EltwiseReduceMod Fails with Larger Moduli on 1.2.2 With DQ Processor

bryan113 opened this issue · comments

I discovered the following when tracking a test failure on a DQ processor. When passing a larger modulus and at least 8 input elements to the EltwiseReduceMod function, incorrect results are returned.

I wrote a quick test in the test-eltwise-reduce-mod.cpp file to replicate the issue:

TEST(EltwiseReduceMod, LargeModError) {
  uint64_t num = 8;
  std::vector<uint64_t> op;
  for(uint64_t i = 0; i < num; i++) op.push_back(124498721298790);
  std::vector<uint64_t> exp_out;
  for(uint64_t i = 0; i < num; i++) exp_out.push_back(253924022517);
  std::vector<uint64_t> result;
  for(uint64_t i = 0; i < num; i++) result.push_back(0);

  const uint64_t modulus = 1099511480321;
  const uint64_t input_mod_factor = modulus;
  const uint64_t output_mod_factor = 1;
  EltwiseReduceMod(result.data(), op.data(), op.size(), modulus,
                   input_mod_factor, output_mod_factor);
  CheckEqual(result, exp_out);
}

When compiling and executing the above on my computer with no processor enhancements, it passes, but with a DQ processor it fails. For our testing we were simply using an AWS c5.4xlarge instance. I've tested on an IFMA processor and the test passes where.

We built the project using the flags: -DCMAKE_BUILD_TYPE=Debug -DHEXL_TESTING=ON.