There are several points to keep in mind:
- The scheme switching capability implemented in OpenFHE was designed to support large precision, which requires large FHEW plaintext modulus and ciphertext modulus. These moduli are different than the ones supported for the FHEW evaluation of binary gates, but are compatible with FHEW
EvalDecomp
,EvalSign
,EvalFunc
. - For additional context for the disparity of parameters, you can check out this thread.
EvalBinGate
works with Boolean inputs, so for other inputs, the results will be incorrect.- The plaintext modulus for the Boolean case is actually p = 4, see the original paper.
This being said, if you really need to switch Boolean inputs from CKKS, specify logQ_ccLWE = 12
and pLWE1 = 4
, which match the default FHEW parameters for EvalBinGate
(with the caveat that the approximation of values far from 0 or 1 in CKKS to FHEW, can lead to errors in the output of EvalBinGate
. The reason is that the expected sum of the Boolean inputs should be 0, 1 or 2; sum values around 0.5 or 1.5 can be pushed by noise in either direction). Otherwise, you can define your own functionality using EvalFunc
for p\le 8, trying to mimic the logic of EvalBinGate
, where the inputs are first summed, and then there is some lookup table that is applied on the sum.