https://github.com/serengil/lightdsa
A Lightweight Digital Signature Algorithm Library for Python
https://github.com/serengil/lightdsa
digital-signature dsa ecdsa eddsa edwards-curve-digital-signature-algorithm elliptic-curve-cryptography elliptic-curve-digital-signature-algorithm rsa
Last synced: 10 months ago
JSON representation
A Lightweight Digital Signature Algorithm Library for Python
- Host: GitHub
- URL: https://github.com/serengil/lightdsa
- Owner: serengil
- License: mit
- Created: 2025-03-13T22:08:44.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-07-09T12:42:34.000Z (12 months ago)
- Last Synced: 2025-09-02T11:47:00.016Z (10 months ago)
- Topics: digital-signature, dsa, ecdsa, eddsa, edwards-curve-digital-signature-algorithm, elliptic-curve-cryptography, elliptic-curve-digital-signature-algorithm, rsa
- Language: Python
- Homepage: https://www.youtube.com/watch?v=-a3CwbPopao&list=PLsS_1RYmYQQFgdwq4lCwagnzEGkB9P5Sa&index=1
- Size: 156 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# LightDSA
[](https://pepy.tech/project/lightdsa)
[](https://github.com/serengil/LightDSA/stargazers)
[](https://github.com/serengil/LightDSA/actions/workflows/tests.yml)
[](https://github.com/serengil/LightPHE/blob/master/LICENSE)
[](https://arxiv.org/abs/2505.23773)
[](https://sefiks.com)
[](https://www.youtube.com/@sefiks?sub_confirmation=1)
[](https://twitter.com/intent/user?screen_name=serengil)
[](https://www.patreon.com/serengil?repo=lightdsa)
[](https://github.com/sponsors/serengil)
[](https://buymeacoffee.com/serengil)

LightDSA is a lightweight digital signature algorithm library for Python. It is a hybrid library supporting [Elliptic Curve Digital Signature Algorithm (ECDSA)](https://sefiks.com/2018/02/16/elegant-signatures-with-elliptic-curve-cryptography/) and [Edwards-Curve Digital Signature Algorithm (EdDSA)](https://sefiks.com/2018/12/24/a-gentle-introduction-to-edwards-curve-digital-signature-algorithm-eddsa/), [RSA](https://sefiks.com/2023/03/06/a-step-by-step-partially-homomorphic-encryption-example-with-rsa-in-python/) and [DSA](https://sefiks.com/2023/06/14/digital-signature-algorithm-dsa-in-python-from-scratch/).
# Installation [](https://pypi.org/project/lightdsa/)
The easiest way to install the LightDSA package is to install it from python package index (PyPI).
```shell
pip install lightdsa
```
Then you will be able to import the library and use its functionalities.
```python
from lightdsa import LightDSA
```
# Usage
Once you initialize a LightDSA object with a specific DSA algorithm, such as ECDSA, EdDSA, or RSA, it will generate the private and public keys for your cryptosystem.
```python
# built a cryptosystem
dsa = LightDSA(algorithm_name = "eddsa") # or ecdsa, rsa
# export keys
dsa.export_keys("public.txt", public = True)
# sign a message
message = "Hello, world!"
signature = dsa.sign(message)
```
If you wish to use a pre-existing exported cryptosystem, you should specify the exported key file during initialization. This will allow you to sign messages using the private key and verify messages using the public key as
```python
# restore the cryptosystem for the verifier side
verifier_dsa = LightDSA(algorithm_name = "eddsa", key_file = "public.txt")
verifier_dsa.verify(message, signature)
```
# Elliptic Curve Forms and Pre-Defined Curves
LightDSA supports [Weierstrass](https://sefiks.com/2016/03/13/the-math-behind-elliptic-curve-cryptography/), [Koblitz](https://sefiks.com/2016/03/13/the-math-behind-elliptic-curves-over-binary-field/) and [Edwards](https://sefiks.com/2018/12/19/a-gentle-introduction-to-edwards-curves/) forms and hundreds of pre-defined curves that can be adopted in ECDSA and EdDSA.
By default, ECDSA uses the Weierstrass form with the secp256k1 curve (the curve used by Bitcoin), while EdDSA uses the Edwards form with the ed25519 curve. However, you can switch the elliptic curve form and the specific curve for both ECDSA and EdDSA during the initialization of the LightDSA object. Meanwhile, the hashing algorithm is determined based on [the order of the elliptic curve](https://sefiks.com/2018/02/27/counting-points-on-elliptic-curves-over-finite-field/), which defines the number of points available over the finite field.
```python
dsa = LightDSA(
algorithm_name = "eddsa",
form_name = "edwards",
curve_name = "ed448"
)
```
See [`curves`](https://github.com/serengil/LightECC#supported-curves) page for more details.
# 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](https://github.com/serengil/LightDSA/actions/workflows/tests.yml) 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](https://www.patreon.com/serengil?repo=lightdsa), [GitHub Sponsors](https://github.com/sponsors/serengil) or [Buy Me a Coffee](https://buymeacoffee.com/serengil).
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 LightDSA in your publications if it helps your research. Here is its BibTex entry:
```BibTeX
@article{serengil2025lightdsa,
title={LightDSA: A Python-Based Hybrid Digital Signature Library and Performance Analysis of RSA, DSA, ECDSA and EdDSA in Variable Configurations, Elliptic Curve Forms and Curves},
author={Serengil, Sefik and Ozpinar, Alper},
journal={arXiv preprint arXiv:2505.23773},
note={doi: 10.48550/arXiv.2505.23773. [Online]. Available: \url{https://arxiv.org/abs/2505.23773}},
year={2025}
}
```
# License
LightDSA is licensed under the MIT License - see [`LICENSE`](https://github.com/serengil/LightDSA/blob/master/LICENSE) for more details.
LightDSA [logo](https://thenounproject.com/icon/captain-america-shield-2579667/) is created by [M. Ristiyanto](https://thenounproject.com/creator/masmajnun.studio/) and it is licensed under [Creative Commons: By Attribution 3.0 License](https://creativecommons.org/licenses/by/3.0/).