Store some of the values in Montgomery representation. Good candidates are the keys and perhaps bootstrap values? We can prevent mistakes by creating a RNSPolynomialTransformedM type in addition to RNSPolynomialTransformed, and making sure that only operators non-M + non-M = non-M, M + M = M, non-M * M = non-M and M * M = M are defined.
If non-M * non-M is necessary somewhere after step 1, Barrett reduction can be used there.
More convenient moduli can be chosen (close to 2^64, with small number of bits set). This will require support from DarkIntegers.
Two ways are possible:
Store some of the values in Montgomery representation. Good candidates are the keys and perhaps bootstrap values? We can prevent mistakes by creating a
RNSPolynomialTransformedM
type in addition toRNSPolynomialTransformed
, and making sure that only operatorsnon-M + non-M = non-M
,M + M = M
,non-M * M = non-M
andM * M = M
are defined.If
non-M * non-M
is necessary somewhere after step 1, Barrett reduction can be used there.More convenient moduli can be chosen (close to 2^64, with small number of bits set). This will require support from
DarkIntegers
.