HElib icon indicating copy to clipboard operation
HElib copied to clipboard

EXC_BAD_ACCESS when calling recrypt method in v2.0.0

Open s-naveen opened this issue 5 years ago • 3 comments

Please let me know how to solve this.

Stack Trace:

helib::EvalMap::apply(helib::Ctxt&) const EvalMap.cpp:173
helib::PubKey::reCrypt(helib::Ctxt&) const recryption.cpp:513
main test.cpp:135

s-naveen avatar Jan 21 '21 11:01 s-naveen

Hi @s-naveen Can you give us more information on what you are trying to do in your test.cpp program and also the parameters you used to build the context ?

-Flavio

faberga avatar Jan 21 '21 16:01 faberga

@faberga

  // Plaintext prime modulus
  unsigned long p = 131;
  // Cyclotomic polynomial - defines phi(m)
  unsigned long m = 10075;
  // Hensel lifting (default = 1)
  unsigned long r = 1;
  // Number of bits of the modulus chain
  unsigned long bits = 2000;
  // Number of columns of Key-Switching matrix (default = 2 or 3)
  unsigned long c = 2;
  // Generating set of Zm* group.
  std::vector<long> gens = {3876, 6852, 1301};
  // Orders of the previous generators.
  std::vector<long> ords = {12, 20, 2};
  NTL::Vec<long> mvec;
  mvec.SetLength(3);
  mvec[0] = 13;
  mvec[1] = 25;
  mvec[2] = 31;

    helib::Context context = helib::ContextBuilder<helib::BGV>()
      .m(m)
      .p(p)
      .r(r)
      .gens(gens)
      .ords(ords)
      .bits(bits)
      .c(c)
      .bootstrappable(true)
      .mvec(mvec)
      .build();

Just a simple test of addition and couple of multiplications

helib::Ptxt<helib::BGV> query_ptxt(context);
query_ptxt[0] = 20;
public_key.Encrypt(encrypted_text, query_ptxt);
public_key.Encrypt(encrypted_text2, query_ptxt);
public_key.Encrypt(encrypted_text3, query_ptxt);
public_key.Encrypt(encrypted_text4, query_ptxt);
encrypted_text.addCtxt(encrypted_text2);
encrypted_text.multiplyBy(encrypted_text3);
encrypted_text.multiplyBy(encrypted_text4);
public_key.ReCrypt(encrypted_text);  <--- Error Line
helib::Ptxt<helib::BGV> result(context);
secret_key.Decrypt(result, encrypted_text);

s-naveen avatar Jan 22 '21 07:01 s-naveen

@s-naveen Hi Naveen, please refer to comment @jlhcrawford posted to Issue #418 .

faberga avatar Apr 08 '21 22:04 faberga