[英]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.