# Polynomial ring modulus integer to univariate polynomial ring over the Integers

I want to use the DiscreteGaussianDistributionPolynomialSampler library:

from sage.stats.distributions.discrete_gaussian_polynomial import DiscreteGaussianDistributionPolynomialSampler
sage: DiscreteGaussianDistributionPolynomialSampler(ZZ['x'], 8, 3.0)()
3*x^7 + 3*x^6 - 3*x^5 - x^4 - 5*x^2 + 3

DiscreteGaussianDistributionPolynomialSampler(P, n, sigma)
P - a univariate polynomial ring over the Integers
n - number of coefficients to be sampled
sigma -


However, it takes a univariate polynomial ring over the Integers but I want to use a quotient ring of integers modulus instead. Something like this:

Quotient polynomial ring of: (x^1024 + 1) modulus 13:

modulus = 13
R = PolynomialRing(GF(modulus), "X")
X = R.gen()
Y = R.quotient(X^1024 + 1, "x")
x = Y.gen()


Question: Is it possible? if it is not possible is there a way to manually mod the result with x^1024 +1 and then with 13 afterwards?

Any help would be appreciated.

edit retag close merge delete

Link of the library (I didn't have sufficient points to have URL in my question): http://doc.sagemath.org/html/en/reference/stats/sage/stats/distributions/discrete_gaussian_polynomial.html#sage.stats.distributions.discrete_gaussian_polynomial.DiscreteGaussianDistributionPolynomialSampler.__init__ (link)

Sort by » oldest newest most voted

Your code is almost there, probably you need the following:

from sage.stats.distributions.discrete_gaussian_polynomial import DiscreteGaussianDistributionPolynomialSampler
f=DiscreteGaussianDistributionPolynomialSampler(ZZ['x'], 8, 3.0)()
R.<X> = PolynomialRing(GF(13))
Y.<t> = R.quotient(X^1024 + 1)
Y(f)


Here you obtain

10*t^7 + 5*t^6 + 3*t^4 + 7*t^3 + 12*t^2 + 2*t + 1

more

It seems DiscreteGaussianDistributionPolynomialSampler is flexible enough to accept the quotient ring in the question instead of a polynomial ring over the integers.

So one could do directly:

sage: from sage.stats.distributions.discrete_gaussian_polynomial import DiscreteGaussianDistributionPolynomialSampler

sage: R.<X> = PolynomialRing(GF(13))
sage: Y.<x> = R.quotient(X^1024 + 1)
sage: Y
Univariate Quotient Polynomial Ring in x over Finite Field of size 13 with modulus X^1024 + 1

sage: Q = DiscreteGaussianDistributionPolynomialSampler(Y, 8, 3.0)()
sage: Q
2*x^6 + 10*x^5 + 2*x^4 + 5*x^3 + 9*x + 7
sage: Q.parent()
Univariate Quotient Polynomial Ring in x over Finite Field of size 13 with modulus X^1024 + 1


Or, having started with ZZ['x'], one could convert to Y afterwards as in @castor's answer.

sage: P = DiscreteGaussianDistributionPolynomialSampler(ZZ['x'], 8, 3.0)()
sage: Q = Y(P)

sage: P
-6*x^7 - x^6 - 2*x^5 - 3*x^4 - 3*x^3 + 3*x + 2
sage: Q
7*x^7 + 12*x^6 + 11*x^5 + 10*x^4 + 10*x^3 + 3*x + 2

sage: P.parent()
Univariate Polynomial Ring in x over Integer Ring
sage: Q.parent()
Univariate Quotient Polynomial Ring in x over Finite Field of size 13 with modulus X^1024 + 1

sage: Q = DiscreteGaussianDistributionPolynomialSampler(Y, 8, 3.0)()
sage: Q
2*x^6 + 10*x^5 + 2*x^4 + 5*x^3 + 9*x + 7
sage: Q.parent()
Univariate Quotient Polynomial Ring in x over Finite Field of size 13 with modulus X^1024 + 1

more