简体   繁体   English

SageMathCloud:随机椭圆曲线

[英]SageMathCloud: random elliptic curve

load cong.sage defines random_elliptic_curve command in sage but I'm using SageMathCloud. load cong.sage在sage中定义了random_elliptic_curve命令,但是我正在使用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. 显然,您所指的Sage程序是William Stein的GitHub存储库中的cong.sage It is possible to import it into your project: eg, download from GitHub, change the file extension to .sagews , upload to your project. 可以将其导入到您的项目中:例如,从GitHub下载,将文件扩展名更改为.sagews ,然后上传到您的项目。 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. 但是从SageMathCloud中的另一个Sage文件导入定义似乎很困难(如果可能的话),并且由于您只想要此特定功能,所以为什么不直接复制粘贴其定义。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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