繁体   English   中英

SageMathCloud:随机椭圆曲线

[英]SageMathCloud: random elliptic curve

load cong.sage在sage中定义了random_elliptic_curve命令,但是我正在使用SageMathCloud。 我必须写什么才能生成随机椭圆曲线?

显然,您所指的Sage程序是William Stein的GitHub存储库中的cong.sage 可以将其导入到您的项目中:例如,从GitHub下载,将文件扩展名更改为.sagews ,然后上传到您的项目。 但是从SageMathCloud中的另一个Sage文件导入定义似乎很困难(如果可能的话),并且由于您只想要此特定功能,所以为什么不直接复制粘贴其定义。

这是一个简单的函数,位于上面链接的文件的最后:

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