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. """ trace_congruences = [] search_range = hasse_frobenius_trace_range(curve.field()) torsion_primes = greedy_prime_factors(len(search_range), curve.field().characteristic()) # To avoid multivariate polynomial arithmetic, make l=2 a special case. if 2 in torsion_primes: trace_congruences.append(frobenius_trace_mod_2(curve)) torsion_primes.remove(2) torsion_group = LTorsionGroup(curve) for prime in torsion_primes: trace_congruences.append(frobenius_trace_mod_l(torsion_group(prime))) 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. """ trace_congruences = [] search_range = hasse_frobenius_trace_range( curve.field() ) torsion_primes = greedy_prime_factors( len(search_range), curve.field().characteristic() ) # To avoid multivariate polynomial arithmetic, make l=2 a special case. if 2 in torsion_primes: trace_congruences.append( frobenius_trace_mod_2( curve ) ) torsion_primes.remove( 2 ) torsion_group = LTorsionGroup( curve ) for prime in torsion_primes: trace_congruences.append( frobenius_trace_mod_l( torsion_group( prime ) ) ) 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 )