SageMathCloud: random elliptic curve

350 views Asked by At

load cong.sage defines random_elliptic_curve command in sage but I'm using SageMathCloud. What is I have to write to generate a random elliptic curve?

1

There are 1 answers

0
AudioBubble On

Apparently, the Sage program you are referring to is cong.sage in William Stein's GitHub repository. It is possible to import it into your project: e.g., download from GitHub, change the file extension to .sagews, upload to your project. But it seems tricky (if possible) to import definitions from another Sage file in SageMathCloud, and since you just want this particular function, why not just copy-paste its definition.

It's a simple function found at the very end of the file linked above:

def random_elliptic_curve(p):
    """
    Construct and return a random elliptic curver over the finite
    field of order p.
    """
    p = ZZ(p)
    if not is_prime(p):
        raise ValueError, "p (=%s) must be a prime integer."%p
    F = FiniteField(p)
    while True:
        try:
            return EllipticCurve(F, [F.random_element(), F.random_element()])
        except ArithmeticError:
            pass
    return E