Reputation: 3545
Various Homomorphic Encryption (FHE) schema that use Ring-Learning With Errors (RLWE) problems (and post-quantum, lattice-based cryptography in general) need to perform a polynomial modulo and then a scalar modulo on the coefficients.
I use the polynom package for the polynomials and the polynomial modulo.
Is there a way to perform the scalar modulo on the coefficients?
Upvotes: 0
Views: 56
Reputation: 3545
There is no way in polynom. This is a simple workaround
# define a helper function
CoefMod <- function(x, k)
polynom::polynomial(as.vector(x)%%k)
# create a polynomial
library(polynom)
polynomial = polynomial(c(5, 3, 6))
# apply the helper function (mod 5)
CoefMod(polynomial, 5)
I've create a small R package that also makes the function available:
install.packages('remotes')
remotes::install_github('bquast/HEtools')
Upvotes: 0