microsoft / SEAL

Microsoft SEAL is an easy-to-use and powerful homomorphic encryption library.
https://www.microsoft.com/en-us/research/group/cryptography-research/
MIT License
3.62k stars 711 forks source link

BFV Example – printing incorrect results when x=6? #605

Open iavssw opened 1 year ago

iavssw commented 1 year ago

Hello, I am new to the code base and HE in general. As a learning experience, I was following the 1_bfv_basics.cpp and tried computing “4(x^2+1)(x+1)^2”. Out of the box, the decrypted results are printed as 0X54, even though the correct value should be 0X1C54. As a sanity check, when X=2, I find that the BFV example is working correctly and printing out the correct result.

Not sure where the problem is at the moment (maybe to_string() is broken), and any help on this would be appreciated.

fionser commented 1 year ago

BFV has a parameter to define the range of plaintext say t Any thing that overflow that maximum value >=t will be rounded as mod t So check whether 0x1c54 = 0x54 mod t in your case.