I updated the test TrapDoorGaussSampTestSquareMatricesDCRT
as follows → test: update `TrapDoorGaussSampTestSquareMatricesDCRT` · enricobottazzi/openfhe-development@cc3a788 · GitHub
In particular, I updated the parameters m, dcrtBits, size
and set the gadget matrix base to 1024
.
The test is now failing at this assertion
EXPECT_EQ(U, UEst) << "Failure trapdoor sampling test for " << d << "x" << d << " matrices";
Is this an expected behaviour for such a parameter choice?
Thanks
For these parameters, trapdoor sampling produces incorrect results as the perturbation samples become large enough to cause an overflow. For instance, if you reduce the base to 64 or increase dcrtBits to 27 (for base = 1024), the unit test should work. The correctness issue is caused by high values of the distribution parameter for perturbation sampling (which is proportional to SPECTRAL_BOUND_D, which, in its turn, is proportional to base + 1).
The underlying issue is that you are using two 17-bit moduli. Perturbation samples are added to each RNS residue, meaning that perturbation samples become higher than 17 bits for your case and cause an overflow. To fix this problem without changing log q, which is 34 in your case, I suggest changing dcrtBits to 34 and size to 1. Then the unit test should work correctly.
In general, it is better to use the smallest number of RNS moduli as it reduces the runtime (most efficient mode). Each RNS can be up to 60 bits (for default NATIVE_SIZE=64).
1 Like