Skip to content

Instantly share code, notes, and snippets.

@vhxs
Created March 20, 2022 21:48
Show Gist options
  • Save vhxs/42c630ae623bf1459d6a2b62596104b2 to your computer and use it in GitHub Desktop.
Save vhxs/42c630ae623bf1459d6a2b62596104b2 to your computer and use it in GitHub Desktop.
Checking the cardinality of RLWE rings
# iterate over primes
for i, p in enumerate(Primes()):
# iterate over cyclotomics
for n in range(1, i+1):
# GF(p) is the finite field of order p
S = PolynomialRing(GF(p), 'x')
f = cyclotomic_polynomial(n)
R = QuotientRing(S, f)
assert R.cardinality() == p ** (f.degree())
print(f"Checked equality for p == {p}, n == {n}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment