简体   繁体   中英

SageMathCloud: random elliptic curve

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?

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: eg, 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM