Barebones P256

The basic form of an elliptic curve is y² = x² + ax +b, and a plot of y² = x³-3x+10 is [here]:

Barebones P256: There Is Beauty in Elliptic Curves

The basic form of an elliptic curve is y² = x² + ax +b, and a plot of y² = x³-3x+10 is [here]:

For the NIST P256 curve, we have a finite field defined by the prime number of p=2²⁵⁶−2²²⁴+2¹⁹²+2⁹⁶−1. The other parameters are x=-3, b=41058363725152142129326129780047268409114441015993725554835256314039467401291 and the base point is at:

(48439561293906451759052585252797914202762949526041747995844080717082404635286,36134250956749795798585127919587881956611106672985015071877198253568414405109).

The simplest operations we have is to take a base point G on this curve, and then perform point addition. We always end up with another point on the curve. So 2G is equal to G+G and where we get a new point on the elliptic curve. For 3G we can have G+2G, and so on. We can also perform a scalar multiplication, such as taking a scalar of 3 and finding 3G. In the following code we have three scalar values of 1, 2 and 3, and then use point addition and scalar multiplication to find 2G and 3G, and where we should get the same values as G+G and G+2G, respectively:

suite := suites.MustFind("P256")
one := suite.Scalar().SetInt64(1)
two := suite.Scalar().SetInt64(2)
three := suite.Scalar().SetInt64(3)
G:=suite.Point().Base()

n := suite.Scalar().Pick(suite.RandomStream())
G_1 := suite.Point().Mul(one,G)  
G_2 := suite.Point().Mul(two,G)
G_3 := suite.Point().Mul(three,G)
G_T1 := suite.Point().Add(G_1,G_1)
G_T2 := suite.Point().Add(G_1,G_2)

Note in Curve NIDT, we have an (x,y) point. A sample run shows that 2G is equal to G+G, and 3G is equal to G+2G:

Curve: P256
Point G (48439561293906451759052585252797914202762949526041747995844080717082404635286,36134250956749795798585127919587881956611106672985015071877198253568414405109)
Point 1G (48439561293906451759052585252797914202762949526041747995844080717082404635286,36134250956749795798585127919587881956611106672985015071877198253568414405109)
Point 2G (56515219790691171413109057904011688695424810155802929973526481321309856242040,3377031843712258259223711451491452598088675519751548567112458094635497583569)
Point 3G (42877656971275811310262564894490210024759287182177196162425349131675946712428,61154801112014214504178281461992570017247172004704277041681093927569603776562)

Point G+G (56515219790691171413109057904011688695424810155802929973526481321309856242040,3377031843712258259223711451491452598088675519751548567112458094635497583569)
Point G+2G (42877656971275811310262564894490210024759287182177196162425349131675946712428,61154801112014214504178281461992570017247172004704277041681093927569603776562)

An outline of the code is:

and here is an online demo that you can add your own scalar to:

A sample run gives for a user entered value of 4 is:

Curve: P256
Point G (48439561293906451759052585252797914202762949526041747995844080717082404635286,36134250956749795798585127919587881956611106672985015071877198253568414405109)
Point 1G (48439561293906451759052585252797914202762949526041747995844080717082404635286,36134250956749795798585127919587881956611106672985015071877198253568414405109)
Point 2G (56515219790691171413109057904011688695424810155802929973526481321309856242040,3377031843712258259223711451491452598088675519751548567112458094635497583569)
Point 3G (42877656971275811310262564894490210024759287182177196162425349131675946712428,61154801112014214504178281461992570017247172004704277041681093927569603776562)

Point G+G (56515219790691171413109057904011688695424810155802929973526481321309856242040,3377031843712258259223711451491452598088675519751548567112458094635497583569)
Point G+2G (42877656971275811310262564894490210024759287182177196162425349131675946712428,61154801112014214504178281461992570017247172004704277041681093927569603776562)

Value 05
Point vG (36794669340896883012101473439538929759152396476648692591795318194054580155373,101659946828913883886577915207667153874746613498030835602133042203824767462820)


Random scale (n) 310f986f0f00a77455666c5eae9562a05302af5117ba52e491d5304f59e9014f
Point nG (78494224767026010845293406669882772940749287347599241954953609326585048933324,91347054593758823544042866206920974212996319719285507232050206961209393062005)

Conclusions

Beauty exists in many forms, and for cybersecurity, elliptic curves are the nearest thing to providing beauty.