Anonymous user
Elliptic curve arithmetic: Difference between revisions
m
→{{header|REXX}}: changed whitespace.
(→{{header|zkl}}: added code) |
m (→{{header|REXX}}: changed whitespace.) |
||
Line 1,217:
<lang rexx>/*REXX program defines (for any 2 points on the curve), returns the sum of the 2 points.*/
numeric digits 100 /*try to ensure a min. of accuracy loss*/
a= func(1)
b= func(2)
c= add(a, b)
d= neg(c)
e= add(c, d)
g= add(a, add(b, d))
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
Line 1,238:
add: procedure; parse arg px py, qx qy; if px=qx & py=qy then return dbl(px py)
if isZ(px py) then return qx qy; if isZ(qx qy) then return px py
z= qx - px;
else do; $= (qy-py) / z;
ry= $ * (px-rx) - py;
/*──────────────────────────────────────────────────────────────────────────────────────*/
dbl: procedure; parse arg px py; if isZ(px py) then return px py;
if z=0 then $= inf()
else $= (3*px*py) / (py+py)
rx= $*$ - px*px; ry= $ * (px-rx) - py; return rx ry
/*──────────────────────────────────────────────────────────────────────────────────────*/
rootI: ox=x; oy=y; x=abs(x); y=abs(y); a=digits()+5; numeric form; g=rootG(); m=y-1
|