Elliptic curve arithmetic: Difference between revisions

Content added Content deleted
(OCaml implementation)
m (→‎{{header|Sage}}: updated to work with Python 3)
Line 1,932: Line 1,932:
=={{header|Sage}}==
=={{header|Sage}}==
Examples from C, using the built-in Elliptic curves library.
Examples from C, using the built-in Elliptic curves library.
<lang sage>Ellie = EllipticCurve(RR,[0,7]) # RR = field of real numbers
<lang sage>
Ellie = EllipticCurve(RR,[0,7]) # RR = field of real numbers


# a point (x,y) on Ellie, given y
# a point (x,y) on Ellie, given y
Line 1,942: Line 1,941:
return P
return P


print Ellie
print(Ellie)
P = point(1)
P = point(1)
print 'P',P
print('P',P)
Q = point(2)
Q = point(2)
print 'Q',Q
print('Q',Q)
S = P+Q
S = P+Q
print 'S = P + Q',S
print('S = P + Q',S)
print 'P+Q-S', P+Q-S
print('P+Q-S', P+Q-S)
print 'P*12345' ,P*12345
print('P*12345' ,P*12345)</lang>

</lang>
{{out}}
{{out}}
<pre>
<pre>