Jump to content

Elliptic curve arithmetic: Difference between revisions

added Sage
(→‎{{header|Java}}: added Java)
(added Sage)
Line 838:
p*12345 #(10.758570529320806 35.387434774282106)
</lang>
 
=={{header|Sage}}==
Examples from C, using the built-in Elliptic curves library.
<lang sage>
Ellie = EllipticCurve(RR,[0,7]) # RR = field of real numbers
 
# a point (x,y) on Ellie, given y
def point ( y) :
x = var('x')
x = (y^2 - 7 - x^3).roots(x,ring=RR,multiplicities = False)[0]
P = Ellie([x,y])
return P
 
print Ellie
P = point(1)
print 'P',P
Q = point(2)
print 'Q',Q
S = P+Q
print 'S = P + Q',S
print 'P+Q-S', P+Q-S
print 'P*12345' ,P*12345
 
</lang>
{{out}}
<pre>
Elliptic Curve defined by y^2 = x^3 + 7.00000000000000 over Real Field
with 53 bits of precision
 
P (-1.81712059283214 : 1.00000000000000 : 1.00000000000000)
Q (-1.44224957030741 : 2.00000000000000 : 1.00000000000000)
S = P + Q (10.3753753892014 : -33.5245090962697 : 1.00000000000000)
P+Q-S (0.000000000000000 : 1.00000000000000 : 0.000000000000000) ## Zero
P*12345 (10.7585721817304 : 35.3874428812067 : 1.00000000000000)
</pre>
 
=={{header|Tcl}}==
Cookies help us deliver our services. By using our services, you agree to our use of cookies.