Build New Curves with tinyec

This section provides a tutorial example on how to create elliptic curve, actually a reduced elliptic curve group, with tinyec Python library.

If you want to build a new elliptic curve (a reduced elliptic curve group) with tinyec Python library, you must do it in two steps.

1. Create an ec.SubGroup object with the curve modulo and other parameters. For example:

>>> s = ec.SubGroup(
   p = 97,    # the modulo used in the modular arithmetic
   g = (0,0), # the base point
   n = 1,     # the order of the subgroup
   h = 1      # the cofactor of the subgroup
   )

Parameters g, n, and h are all required. But they have no impact on the elliptic curve group. So you can provide any values at the beginning.

2. Create an ec.Curve object with curve coefficients and an ec.SubGroup object. For example:

>>> c = ec.Curve(
   a = 2,            # the 'a' coefficient of the curve
   b = 3,            # the 'b' coefficient of the curve
   field = s,        # a subgroup to provide the modulo
   name = 'My Curve' # a name given to the curve, optional
   )

Here is the Python script to create the elliptic curve, E97(2,3):

>>> 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')
C:\Python\Python36-32\lib\site-packages\tinyec\ec.py:119:
    UserWarning: Point (0, 0) is not on curve
    ""p97a2b3" => y^2 = x^3 + 2x + 3 (mod 97)"
    ...

>>> print(c)
"p97a2b3" => y^2 = x^3 + 2x + 3 (mod 97)

Ok. The elliptic curve, c, is created. But the base point given in the Subgroup, s.g, is not on the curve. This is why we are getting the warning message. However the curve is good.

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