def frobenius_trace(curve): """ Compute the trace of the Frobenius endomorphism for the given EllpiticCurve @p curve. This is an implementation of Schoof's original algorithm for counting the points of an elliptic curve over a finite field. @return The trace @f$ t @f$ of the Frobenius endomorphism. The number of points on the curve then is @f$ q + 1 - t @f$, where @f$ q @f$ is the size of the finite field over which the curve was defined. """ # Initialize variables and parameters trace_congruences = [] search_range = possible_frobenius_trace_range(curve.field()) upper_prime_bound = inverse_primorial( len(search_range), shunned=curve.field().characteristic()) # Collect the congruence equations (avoid multivariate # polynomial arithmetic by handling 2-torsion separately) trace_congruences.append(frobenius_trace_mod_2(curve)) torsion_group = LTorsionGroup(curve) for prime in primes_range(3, upper_prime_bound + 1): if prime != curve.field().characteristic(): trace_congruences.append( frobenius_trace_mod_l(torsion_group(prime))) # Recover the unique valid trace representative trace_congruence = solve_congruence_equations(trace_congruences) return representative_in_range(trace_congruence, search_range)
def frobenius_trace(curve): """ Compute the trace of the Frobenius endomorphism for the given EllpiticCurve @p curve. This is an implementation of Schoof's original algorithm for counting the points of an elliptic curve over a finite field. @return The trace @f$ t @f$ of the Frobenius endomorphism. The number of points on the curve then is @f$ q + 1 - t @f$, where @f$ q @f$ is the size of the finite field over which the curve was defined. """ # Initialize variables and parameters trace_congruences = [] search_range = possible_frobenius_trace_range( curve.field() ) upper_prime_bound = inverse_primorial( len(search_range), shunned = curve.field().characteristic() ) # Collect the congruence equations (avoid multivariate # polynomial arithmetic by handling 2-torsion separately) trace_congruences.append( frobenius_trace_mod_2( curve ) ) torsion_group = LTorsionGroup( curve ) for prime in primes_range( 3, upper_prime_bound+1 ): if prime != curve.field().characteristic(): trace_congruences.append( frobenius_trace_mod_l( torsion_group( prime ) ) ) # Recover the unique valid trace representative trace_congruence = solve_congruence_equations( trace_congruences ) return representative_in_range( trace_congruence, search_range )
def test_empty(self): """Empty (too small) input""" self.assert_(inverse_primorial(-1) == 2)
def test_results(self): """Sample results""" self.assert_(inverse_primorial(30) == 5) self.assert_(inverse_primorial(31) == 7)
def test_empty(self): """Empty (too small) input""" self.assert_( inverse_primorial(-1) == 2 )
def test_results(self): """Sample results""" self.assert_( inverse_primorial(30) == 5 ) self.assert_( inverse_primorial(31) == 7 )