gpt4 book ai didi

python - SageMathCloud : random elliptic curve

转载 作者:太空宇宙 更新时间:2023-11-03 17:39:50 24 4
gpt4 key购买 nike

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

最佳答案

显然,您所指的Sage程序是cong.sage在 William Stein 的 GitHub 存储库中。可以将其导入到您的项目中:例如,从 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

关于python - SageMathCloud : random elliptic curve,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30727065/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com