# Two point addition in elliptic curve using sjcl library in javascript [closed]

I am new to SJCL library and I am working on elliptic curve cryptography at very basic level. I can't implement the add function for two points on the elliptic curve.

The signature of add function which I found on internet is curve.a.add(b), where a and b are points.

When I implemented this function syntax, I got this error

TypeError: Cannot read property 'add' of undefined

Here P and Q are points on elliptic curve k256.

• Please refrain from cross-posting the same question to multiple stackexchange sites. Programming questions belong on StackOverflow, even if they are using cryptography. – Ella Rose Oct 10 at 14:18

Assuming curve is an instance of sjcl.ecc.curve:

(1) curve.Q is undefined, there is no field named Q in the curve class.

(2) Q must be a point in Jacobian coordinates and P must be a point in affine coordinates. See the documentation.

So if P and Q are created by new point(curve, x, y), do this:

BTW: curve.a.add(b) does not do point addition. It takes the parameter a of the curve, i.e. the constant a in the equation of the curve $$y^2 = x^3 + ax + b$$, which is a big integer, and adds it to b (which presumably is also a big integer).