Skip to content

Latest commit

 

History

History

utils

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Utils

Overview

This module provides functionality to filter the set of elliptic curves found by all algorithms in the library. The methods are designed to be overriden by the user.

Throughout, q denotes the prime size of the base field; t denotes the trace of Frobenius; r denotes the prime size of the group; k denotes the embedding degree; D denotes the (negative) fundamental discriminant.

Methods

Here is an overview of the methods in utils.py:

is_valid_curve(q, t, r, k, D)

Checks that (q,t,r,k,D) is a valid elliptic curve.

is_suitable_curve(q, t, r, k, D, num_bits)

All algorithms that output an elliptic curve call this method to check if the curve found is suitable. If not, then the algorithm will retry to find a new curve. By default, the method returns true if (q,t,r,k,D) is a valid elliptic curve and r has at least num_bits bits

is_suitable_q(q)

All algorithms that search for q separately from the rest of the parameters call this method to determine if q is suitable. By default, the method returns true if q is prime.

is_suitable_r(r)

All algorithms that search for r separately from the rest of the parameters call this method to determine if r is suitable. By default, the method returns true if r is prime.

print_curve(q, t, k, r, D):

Prints the curve (q,t,r,k,D).

curve_to_string(q, t, k, r, D):

Returns a string representation of the curve (q,t,r,k,D).

Examples

All of the methods above are designed to be overriden by the user. The following code shows how to do this for is_suitable_q. All other methods can be overriden in the same way. WARNING Overriding methods improperly may cause algorithms to loop indefinitely. Take care to check that there are curves that will satisfy the constraints implied by the 3 methods.

Overriding is_suitable_q

import ecfactory.utils as utils
utils.is_suitable_q = lambda q: is_prime(q) and q % 6 == 1

Now all algorithms that search for q will only find primes congruent to 1 mod 6. Check that this is true with DEM

import ecfactory.dupont_enge_morain as dem
q, t, r, k, D = dem.run(50, 5)
assert q % 6 == 1