Perform Point Addition with tinyec

This section provides a tutorial example on how to perform the point addition operation on a given elliptic curve with tinyec Python library.

If you want to perform point addition operation on an elliptic curve with tinyec Python library, you must do it in three steps.

1. Create the elliptic curve. For example:

>>> import tinyec.ec as ec

>>> s = ec.SubGroup(p=97,g=(0,0),n=1,h=1)

>>> c = ec.Curve(a=2,b=3,field=s,name='p97a2b3')

2. Create ec.Point objects with their x and y coordinates an ec.Curve object. For example:

>>> p = ec.Point(curve=c,x=3,y=6)
>>> q = ec.Point(curve=c,x=80,y=10)

>>> print(p)
(3, 6) on "p97a2b3" => y^2 = x^3 + 2x + 3 (mod 97)

>>> print(q)
(80, 10) on "p97a2b3" => y^2 = x^3 + 2x + 3 (mod 97)

3. Perform the point addition with the "+" operator. For example:

>>> r = p + q

>>> print(r)
(80, 87) on "p97a2b3" => y^2 = x^3 + 2x + 3 (mod 97)

Ok. The point addition is performed correctly, you can verify it manually.

If you create an ec.Point object with an invalid curve point, tinyec will tell you the point is off the curve:

>>> t = ec.Point(curve=c,x=1,y=1)

>>> print(t)
(1, 1) off "p97a2b3" => y^2 = x^3 + 2x + 3 (mod 97)

Or you can verify if a given point is on or off the curve with the ec.curve.on_curve() method:

>>> c.on_curve(1,1)
False

>>> c.on_curve(3,6)
True

Table of Contents

 About This Book

 Geometric Introduction to Elliptic Curves

 Algebraic Introduction to Elliptic Curves

 Abelian Group and Elliptic Curves

 Discrete Logarithm Problem (DLP)

 Finite Fields

 Generators and Cyclic Subgroups

 Reduced Elliptic Curve Groups

 Elliptic Curve Subgroups

tinyec - Python Library for ECC

 What Is tinyec

 Download and Install tinyec

 Build New Curves with tinyec

Perform Point Addition with tinyec

 Find Subgroup with Point Addition

 Set Subgroup Order to Higher Value

 EC (Elliptic Curve) Key Pair

 ECDH (Elliptic Curve Diffie-Hellman) Key Exchange

 ECDSA (Elliptic Curve Digital Signature Algorithm)

 ECES (Elliptic Curve Encryption Scheme)

 EC Cryptography in Java

 Standard Elliptic Curves

 Terminology

 References

 Full Version in PDF/EPUB