Elliptic Curve Crypto , The Basics by@garciaj.uk

June 27th 2017 14,339 reads

Alright!Â , so weâ€™ve talked about **D-H** and **RSA**Â , and those weâ€™re sort of easy to followÂ , you didnâ€™t need to know a lot of math to sort of grasp the the ideaÂ , I think that would be a fair statement.

Well things are a little bit steeper when facing **ECC**Â , to say the leastÂ , itâ€™s got multiple properties and thereâ€™s a lot more math in itÂ . I want to divide these series into 3 parts because I am discovering it myself as I go.

**ECC** is a **public key** basedÂ , such as **RSA**Â , but it is sort of represented in an algebraic structureÂ , **ECC** offers the same security than **RSA** but at a **smaller footprint**Â , also itâ€™s less cpu intensive so itâ€™s ideal for mobile devices and faster acting networks.

By definitionÂ :

In mathematics, anelliptic curveis a plane algebraiccurvedefined by an equation of the form. that is non-singular; that is, it has no cusps or self-intersections.

So it really a curve where all the **points** (x,y coordinates) satisfy an **equationÂ , **it is really that simpleÂ , well not that simple.

**How does it look and whatâ€™s the equation?**

Well the nice way to represent it is something like:

The equation that all points in this Curve should satisfy would be something like

y ** 2 = x ** 3 + ax +b

So in theoryÂ , if you make a list of a lot of â€śyâ€ť coordinates (real numbers) and apply that equation to all of themÂ , you should obtain a curve looking sort of like that.

**Now for most of this work Iâ€™ve been usingÂ :**

**I highly recommend theseÂ .**

Before we plot a list of points of **real numbers** that honour the equation letâ€™s clarify that when the fact that the equation suggest **y square**Â , means that the **negative and positive Y axis of the curve will be the sameÂ **, that is that if a point exists in **y:4** it will also exit in **y:-4Â , **you can see it in the curve above:

CoolÂ , so now letâ€™s see if this thing is trueÂ , the following code is what Iâ€™ve used in jupyter to get thee graphs Iâ€™m showing here

Iâ€™ll go step by step:

f(x) = x ** 3 + 3x + 4

This is the most important part reallyÂ , remember the equation that defined the curve? So this is one side of itÂ , as you can see **â€śa = 3â€ť** and **â€śb = 4â€ť**Â , these parameters are called **domain parameters**Â , and they decide a various attributes of the curve.

AlsoÂ , the equation has to return something else than 0Â , so we can sort of graph it out hence:

if res > 0

**One more thingÂ , notice that the result of the equation has to be square rooted becase y was squareÂ , so we do the following**:

ys.append(np.sqrt(res))

So what does this look like?

Yea okÂ , it isnâ€™t great but it sort of resemble the curve we were looking at before.

Matplotlib comes with a really fancy function called contourÂ , which accepts an equationÂ , so we can do the following:

And this turns into this:

This is probably the most important property of this curveÂ , and it is that **if a line intersects two points in the curve it will always intersect a third.**

This is very importantÂ , since that third point will be the representation of the public keyÂ , remember that all this hassle is to create public keys from a private keyÂ , that at this point are massive prime numbers.

So you see how one line crossing two points in the curve **(P,Q)** always intersects another **(R).**

- Points in a curve satisfy an equation
- Based on the equation knowing
**â€śXâ€ť**you will ultimately know**â€śYâ€ť** - The curve is identical on the Y axis
- If a line can intersect two points in the curve will also intersect a third one
- Domain parameters affect various attributes of a given curve
- Use Jupyter!

Join Hacker Noon

Create your free account to unlock your custom reading experience.