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)
示例#2
0
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 )
示例#3
0
 def test_empty(self):
     """Empty (too small) input"""
     self.assert_(inverse_primorial(-1) == 2)
示例#4
0
 def test_results(self):
     """Sample results"""
     self.assert_(inverse_primorial(30) == 5)
     self.assert_(inverse_primorial(31) == 7)
示例#5
0
 def test_empty(self):
     """Empty (too small) input"""
     self.assert_( inverse_primorial(-1) == 2 )
示例#6
0
 def test_results(self):
     """Sample results"""
     self.assert_( inverse_primorial(30) == 5 )
     self.assert_( inverse_primorial(31) == 7 )