p = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f ** 2
K = GF(p)
a = K(0x0000000000000000000000000000000000000000000000000000000000000000)
b = K(0x0000000000000000000000000000000000000000000000000000000000000007)
E = EllipticCurve(K, (a, b))
G = E(0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798, 0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8)
E.set_order(0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141 * 0x1)
Are you sure this works? I'm getting the error:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In [685], line 19
17 E = EllipticCurve(K, (a, b))
18 G = E(Integer(0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798), Integer(0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8))
---> 19 E.set_order(Integer(0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141) * Integer(0x1))
File /private/var/tmp/sage-9.8-current/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/sage/schemes/elliptic_curves/ell_finite_field.py:1302, in EllipticCurve_finite_field.set_order(self, value, check, num_checks)
1300 a,b = Hasse_bounds(q,1)
1301 if not a <= value <= b:
-> 1302 raise ValueError('Value %s illegal (not an integer in the Hasse range)' % value)
1303 # Is value*random == identity?
1304 for i in range(num_checks):
ValueError: Value 115792089237316195423570985008687907852837564279074904382605163141518161494337 illegal (not an integer in the Hasse range)
Also I'm not quite sure this makes any sense when you're trying to define the cardinality, especially trying to set the same cardinality of the initial curve.
Oh sorry I wrote it by phone you can check this code
p = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f ** 2
K = GF(p)
a = K(0x0000000000000000000000000000000000000000000000000000000000000000)
b = K(0x0000000000000000000000000000000000000000000000000000000000000007)
E = EllipticCurve(K, (a, b))
G = E(0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798, 0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8)
print(E.order())