Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
fixed failing FinitePolyExtElement test
Browse files Browse the repository at this point in the history
having not run the tests with --long, I hadn't noticed that the algorithm didn't work for elements in a finite field modulo a prime power. In these finite fields, adding one won't generate all elements of the field, so the search for an rth non-residue modulo q may terminate on g=0 which will not work. Instead the search now goes over the field/ring elements as generated by the iterator iter(K).
  • Loading branch information
theHawke committed Oct 21, 2019
1 parent 18d1b1a commit 9d6a86e
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/sage/rings/finite_rings/element_base.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ cdef class FiniteRingElement(CommutativeRingElement):
F = factor_cunningham(n)
else:
F = n.factor()
one = K(1)
nthroot = one
nthroot = K(1)
for r, v in F:
g = K(2)
while (g**((q-1)/r)).is_one():
g += one
iter_K = iter(K)
next(iter_K) # ignore 0 / iter(K) always starts at 0
for g in iter_K: # find rth non-residue mod q
if not (g**((q-1)/r)).is_one(): break
nthroot *= g**((q-1)/r**v)
return [nthroot**a for a in range(gcd)] if all else nthroot
n = n % (q-1)
Expand Down Expand Up @@ -117,16 +117,16 @@ cdef class FiniteRingElement(CommutativeRingElement):
else:
return self
elif algorithm == 'AMM':
one = K(1)
nthroot = one
nthroot = K(1)
for r, v in F:
k, h = (q-1).val_unit(r)
g = K(2)
while (g**((q-1)/r)).is_one():
g += one
iter_K = iter(K)
next(iter_K) # ignore 0 / iter(K) always starts at 0
for g in iter_K: # find rth non-residue mod q
if not (g**((q-1)/r)).is_one(): break
nthroot *= g**((q-1)/r**v)
G = g**(r**(k-1)*h)
L = one
L = K(1)
while True:
J = 0 # find smallest J s.t. self**(r**J * h) == 1
find_J = self**h
Expand Down

0 comments on commit 9d6a86e

Please sign in to comment.