Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Reading through a Python tutorial would be helpful, I think. You could catch the ValueError using a try/except pair:

p=(10^34+1000).next_prime() 
E=EllipticCurve(GF(p),[0,57])

for i in range(10):
    print i,
    try:
        print E.lift_x(i)
    except ValueError:  
        print 'is not on the curve'

gives

0 is not on the curve
1 is not on the curve
2 is not on the curve
3 is not on the curve
4 (4 : 11 : 1)
5 is not on the curve
6 is not on the curve
7 (7 : 20 : 1)
8 (8 : 4398486930972910766515963067497788 : 1)
9 (9 : 1034823061610515416790842872226417 : 1)

If you simply want a random point on the curve and you don't care about it being the 'next' one, you can use .random_element():

sage: E.random_element()
(9537865290021818371758914785117256 : 7089648854090040163853290659008613 : 1)
sage: E.random_element()
(8894960861306214748776439558874048 : 5076442993216186749708177737959875 : 1)
sage: E.random_element()
(713560432970815994889067437364213 : 4835570217047194554079202261200998 : 1)