I've been implementing point addition into a c++ program I've written but I don't see how this can be done right. When I do slope = (y1 - y2)/(x1 - x2)
I get a freaking decimal, which doesn't produce the proper points when applied to the other parts of the equation due to it not retaining its fractional qualities. Anyone have any ideas how how to get past that?
Point Addition being defined by the following equation:
slope = (y1 - y2) / (x1 - x2)
xsum = slope ^ 2 - (x1 + x2)
ysum = slope * (x1 - xsum) - y1
Whereby Private Address x02 with x,y coordinates respectively:
89565891926547004231252920425935692360644145829622209833684329913297188986597
12158399299693830322967808612713398636155367887041628176798871954788371653930
with the Point Addition of Private Address x01 with x,y coordinates respectively:
55066263022277343669578718895168534326250603453777594175500187360389116729240
32670510020758816978083085130507043184471273380659243275938904335757337482424
applied to the above equation produce the result of Private Address x03 with x,y coordinates respectively:
112711660439710606056748659173929673102114977341539408544630613555209775888121
25583027980570883691656905877401976406448868254816295069919888960541586679410
http://en.wikipedia.org/wiki/Elliptic_curve_point_multiplication
EDIT:
I put this C++ program together, and I've modified in every way I can think of (moving %p around, doing it too many times, breaking up the equations and the like). I can't get it to result in the proper results. Anyone mind checking it out and see what you can find please?