LightECC

May 13, 2026 · View on GitHub

PyPI Downloads Stars Tests License

LightECC is a lightweight elliptic curve cryptography library for its arithmetic for python. It is a hybrid library wrapping many elliptic curve forms such as Weierstrass, Koblitz and Edwards, and many pre-defined curves for those forms. LightECC simplifies these arithmetic operations. You don't need to understand the underlying principles forms. Once you define an elliptic curve in a given form, you can perform addition, subtraction, multiplication, and division of points using standard operators.

Installation PyPI

The easiest way to install the LightECC package is to install it from python package index (PyPI).

pip install lightecc

Then you will be able to import the library and use its functionalities.

from lightecc import LightECC

Elliptic Curve Arithmetic

Building an elliptic curve cryptosystem is very straightforward in LightECC. You basically need to initialize a LightECC object with a form name and a curve name. By default, it constructs elliptic curves in Weierstras form.After that, you can retrieve the base point of the curve and perform various elliptic curve arithmetic operations, including addition, subtraction, multiplication, and division.

from lightecc import LightECC

# build an elliptic curve
ec = LightECC(
    form_name = "edwards", # or weierstrass, koblitz. default is weierstrass.
    curve_name = "ed25519", # check out supported curves section
)

# get the base point
G = ec.G

# addition
_2G = G + G
_3G = _2G + G
_5G = _3G + _2G
_10G = _5G + _5G

# subtraction
_9G = _10G - G

# multiplication
_20G = 20 * G
_50G = 50 * G

# division
_25G = _50G / G

Here, addition and subtraction require only basic formulas and can be performed in constant time 𝒪(1).

Supportingly, the double-and-add method is adopted for multiplication, allowing it to be performed very quickly in linear time with 𝒪(log(n)), regardless of the size of the multiplier.

On the other hand, division requires solving the elliptic curve discrete logarithm problem, which is computationally difficult. Its time complexity is 𝒪(n) with brute force.

Point at Infinity or Neutral & Identity Element

The order of the elliptic curve is defined by the argument n in the constructed LightECC object. This represents the total number of points on the curve. It also serves as the neutral or identity element in Edwards curves and point at infinity in Weierstass and Koblitz forms, meaning that adding this point to any other point does not change the result. Additionally, elliptic curves exhibit cyclic group properties beyond this point.

ec = LightECC()

# order of elliptic curve
n = ec.n

# neutral element
neutral = n * G

# scalar multiplication
_17G = 17 * G
minus17G = -1 * _17G

# proof of work for neutralism
assert _17G == _17G + neutral
assert _17G + minus17G == neutral

# proof of work for cyclic group
assert (n + 1) * G == G
assert (n + 2) * G == 2 * G

Supported Curves

Below is a list of elliptic curves supported by LightECC. Each curve has a specific order (n), which defines the number of points in the finite field. The order directly impacts the cryptosystem's security strength. A higher order typically corresponds to a stronger cryptosystem, making it more resistant to cryptographic attacks.

Edwards Curves

formcurvefieldn (bits)
edwardsed25519 (default)prime254
edwardse521prime519
edwardsid-tc26-gost-3410-2012-512-paramsetcprime510
edwardsnumsp512t1prime510
edwardsed448prime446
edwardsed448godilocksprime446
edwardscurve41417prime411
edwardsnumsp384t1prime382
edwardse382prime380
edwardsid-tc26-gost-3410-2012-256-paramsetaprime255
edwardsmdc201601prime254
edwardsnumsp256t1prime254
edwardsjubjubprime252
edwardse222prime220

Weierstass Form

formcurvefieldn (bits)
weierstrasssecp256k1 (default)prime256
weierstrassbn638prime638
weierstrassbn606prime606
weierstrassbn574prime574
weierstrassbn542prime542
weierstrassp521prime521
weierstrassbrainpoolp512r1prime512
weierstrassbrainpoolp512t1prime512
weierstrassfp512bnprime512
weierstrassnumsp512d1prime512
weierstrasseccfrog512ck2prime512
weierstrassgost512prime511
weierstrassbn510prime510
weierstrassbn478prime478
weierstrassbn446prime446
weierstrassbls12-638prime427
weierstrassbn414prime414
weierstrassbrainpoolp384r1prime384
weierstrassbrainpoolp384t1prime384
weierstrassfp384bnprime384
weierstrassnumsp384d1prime384
weierstrassp384prime384
weierstrassbls24-477prime383
weierstrassbn382prime382
weierstrasscurve67254prime380
weierstrassbn350prime350
weierstrassbrainpoolp320r1prime320
weierstrassbrainpoolp320t1prime320
weierstrassbn318prime318
weierstrassbls12-455prime305
weierstrassbls12-446prime299
weierstrassbn286prime286
weierstrassbrainpoolp256r1prime256
weierstrassbrainpoolp256t1prime256
weierstrassfp256bnprime256
weierstrassgost256prime256
weierstrassnumsp256d1prime256
weierstrassp256prime256
weierstrasstom256prime256
weierstrasssm2prime256
weierstrassbls12-381prime255
weierstrasspallasprime255
weierstrasstweedledeeprime255
weierstrasstweedledumprime255
weierstrassvestaprime255
weierstrassbn254prime254
weierstrassfp254bnaprime254
weierstrassfp254bnbprime254
weierstrassbls12-377prime253
weierstrasscurve1174prime249
weierstrassmnt4prime240
weierstrassmnt5-1prime240
weierstrassmnt5-2prime240
weierstrassmnt5-3prime240
weierstrassprime239v1prime239
weierstrassprime239v2prime239
weierstrassprime239v3prime239
weierstrasssecp224k1prime225
weierstrassbrainpoolp224r1prime224
weierstrassbrainpoolp224t1prime224
weierstrasscurve4417prime224
weierstrassfp224bnprime224
weierstrassp224prime224
weierstrassbn222prime222
weierstrasscurve22103prime218
weierstrassbrainpoolp192r1prime192
weierstrassbrainpoolp192t1prime192
weierstrassp192prime192
weierstrassprime192v2prime192
weierstrassprime192v3prime192
weierstrasssecp192k1prime192
weierstrassbn190prime190
weierstrasssecp160k1prime161
weierstrasssecp160r1prime161
weierstrasssecp160r2prime161
weierstrassbrainpoolp160r1prime160
weierstrassbrainpoolp160t1prime160
weierstrassmnt3-1prime160
weierstrassmnt3-2prime160
weierstrassmnt3-3prime160
weierstrassmnt2-1prime159
weierstrassmnt2-2prime159
weierstrassbn158prime158
weierstrassmnt1prime156
weierstrasssecp128r1prime128
weierstrasssecp128r2prime126
weierstrasssecp112r1prime112
weierstrasssecp112r2prime110

Koblitz Form

formcurvefieldn (bits)
koblitzk163 (default)binary163
koblitzb571binary570
koblitzk571binary570
koblitzc2tnb431r1binary418
koblitzb409binary409
koblitzk409binary407
koblitzc2pnb368w1binary353
koblitzc2tnb359v1binary353
koblitzc2pnb304w1binary289
koblitzb283binary282
koblitzk283binary281
koblitzc2pnb272w1binary257
koblitzansit239k1binary238
koblitzc2tnb239v1binary238
koblitzc2tnb239v2binary237
koblitzc2tnb239v3binary236
koblitzb233binary233
koblitzk233binary232
koblitzansit193r1binary193
koblitzansit193r2binary193
koblitzc2pnb208w1binary193
koblitzc2tnb191v1binary191
koblitzc2tnb191v2binary190
koblitzc2tnb191v3binary189
koblitzb163binary163
koblitzc2pnb163v1binary163
koblitzansit163r1binary162
koblitzc2pnb163v2binary162
koblitzc2pnb163v3binary162
koblitzc2pnb176w1binary161
koblitzsect131r1binary131
koblitzsect131r2binary131
koblitzsect113r1binary113
koblitzsect113r2binary113
koblitzwap-wsg-idm-ecid-wtls1binary112

Applications

Explore the LightPHE library for its encryption and decryption implementation, which also demonstrates additive homomorphic properties with Elliptic Curve ElGamal algorithm. Additionally, check out LightDSA for elliptic curve based digital signature implementations such as ECDSA and EdDSA. These are both built on LightECC's fundamentals.

Contributing

All PRs are more than welcome! If you are planning to contribute a large patch, please create an issue first to get any upfront questions or design decisions out of the way first.

You should be able run make test and make lint commands successfully before committing. Once a PR is created, GitHub test workflow will be run automatically and unit test results will be available in GitHub actions before approval.

Support

There are many ways to support a project - starring⭐️ the GitHub repo is just one 🙏

You can also support this work on Patreon, GitHub Sponsors or Buy Me a Coffee.

Also, your company's logo will be shown on README on GitHub if you become sponsor in gold, silver or bronze tiers.

Citation

Please cite LightECC in your publications if it helps your research. Here is its BibTex entry:

@misc{serengil2025lightecc
    author       = {Serengil, Sefik Ilkin},
    title        = {LightECC: A Lightweight Elliptic Curve Cryptography Arithmetic Library for Python with Support for Prime and Binary Fields},
    year         = {2025},
    publisher    = {GitHub},
    howpublished = {https://github.com/serengil/LightECC},
}

License

LightECC is licensed under the MIT License - see LICENSE for more details.

LightECC's logo, designed by Identidea, is inspired from Edwards curves graphs.