Pyfhel icon indicating copy to clipboard operation
Pyfhel copied to clipboard

RuntimeError: keyswitching is not supported by the context

Open ffrusli opened this issue 11 months ago • 1 comments

Hi I am doing my master thesis and trained a neural network model. These models and Test Set supposed to be encrypted using BFV FHE Pyfhel. I did validate my contextGen(), output shows Success:valid. But I am experiencing issues saying keyswitching is not supported by the context when the code arrived at he.relinKeyGen(). I don't understand. I read, it said by default BFV Pyfhel does support keyswitching and I don't need to enable anywhere. Please help, I am stucked.

Code To Reproduce Error import Pyfhel self.he = Pyfhel.Pyfhel() self.he.contextGen(scheme="bfv", n=2048, t_bits=14, sec=128) self.he.keyGen() self.he.relinKeyGen()

Traceback (most recent call last): File "", line 1, in File "Pyfhel/Pyfhel.pyx", line 323, in Pyfhel.Pyfhel.Pyfhel.relinKeyGen File "Pyfhel/Pyfhel.pyx", line 339, in Pyfhel.Pyfhel.Pyfhel.relinKeyGen RuntimeError: keyswitching is not supported by the context

Setup:

  • OS: Kali Linux
  • Python: 3.9
  • C compiler version: 13.3.0
  • Pyfhel Version: 3.4.2

ffrusli avatar Jan 18 '25 22:01 ffrusli

I think the issue might be that you're manually specifying a very small parameter setting (n=2048), and there's just not enough "room" (coefficient modulus q) to do relinearization (a form of keyswitching) with such small parameters. Try either not specifying these values (n, t_bits) or choose larger values (e.g., n=2^13 or 2^14)

AlexanderViand-Intel avatar Jan 19 '25 08:01 AlexanderViand-Intel